fix: gate calendar reviews on confirmed booking. Refs EventHub/EventHubFront#8
This commit is contained in:
Regular → Executable
+16
-1
@@ -216,7 +216,22 @@ can_review(UserId, TargetType, TargetId) ->
|
||||
{ok, false}
|
||||
end;
|
||||
calendar ->
|
||||
{ok, true};
|
||||
case core_booking:list_by_user(UserId) of
|
||||
{ok, Bookings} ->
|
||||
Has = lists:any(
|
||||
fun(B) ->
|
||||
B#booking.status =:= confirmed andalso
|
||||
case core_event:get_by_id(B#booking.event_id) of
|
||||
{ok, Event} -> Event#event.calendar_id =:= TargetId;
|
||||
_ -> false
|
||||
end
|
||||
end,
|
||||
Bookings
|
||||
),
|
||||
{ok, Has};
|
||||
_ ->
|
||||
{ok, false}
|
||||
end;
|
||||
_ ->
|
||||
{ok, false}
|
||||
end.
|
||||
|
||||
Regular → Executable
+5
@@ -324,9 +324,14 @@ format_event(Event) ->
|
||||
#location{address = Addr, lat = Lat, lon = Lon} ->
|
||||
#{address => Addr, lat => Lat, lon => Lon}
|
||||
end,
|
||||
CalendarTitle = case core_calendar:get_by_id(Event#event.calendar_id) of
|
||||
{ok, Cal} -> Cal#calendar.title;
|
||||
_ -> null
|
||||
end,
|
||||
#{
|
||||
id => Event#event.id,
|
||||
calendar_id => Event#event.calendar_id,
|
||||
calendar_title => CalendarTitle,
|
||||
title => Event#event.title,
|
||||
description => Event#event.description,
|
||||
event_type => Event#event.event_type,
|
||||
|
||||
Reference in New Issue
Block a user