fix: owner event bookings list and paid plan durations from plan_to_months.
CI / test (push) Successful in 6m55s
CI / deploy-ift (push) Successful in 3m33s
CI / e2e-ift (push) Failing after 1m4s
CI / deploy-stage (push) Has been skipped
CI / e2e-stage (push) Has been skipped

Fixes EventHub/EventHubBack#51
Fixes EventHub/EventHubBack#52

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-21 20:18:49 +03:00
parent 7368adfb37
commit 5ac23219ca
6 changed files with 133 additions and 26 deletions
+27 -2
View File
@@ -3,7 +3,8 @@
-export([create_booking/2, confirm_booking/2, confirm_booking/3,
cancel_booking/2, cancel_booking/3, get_booking/2,
list_bookings/2, list_user_bookings/1, delete_booking/2,
list_bookings_admin/0, get_booking_admin/1, list_event_bookings/1]).
list_bookings_admin/0, get_booking_admin/1,
list_event_bookings/1, list_event_bookings/2]).
%%%-------------------------------------------------------------------
%%% @doc Создание бронирования со статусом `pending`.
@@ -151,13 +152,37 @@ get_booking_admin(BookingId) ->
core_booking:get_by_id(BookingId).
%%%-------------------------------------------------------------------
%%% @doc Список бронирований события (административный).
%%% @doc Список бронирований события (административный / внутренний).
%%% @end
%%%-------------------------------------------------------------------
-spec list_event_bookings(EventId :: binary()) -> {ok, [#booking{}]}.
list_event_bookings(EventId) ->
core_booking:list_by_event(EventId).
%%%-------------------------------------------------------------------
%%% @doc Список бронирований события для владельца календаря (или admin).
%%% Возвращает полный список заявок без фильтрации по участнику.
%%% @end
%%%-------------------------------------------------------------------
-spec list_event_bookings(UserId :: binary(), EventId :: binary()) ->
{ok, [#booking{}]} | {error, not_found | access_denied}.
list_event_bookings(UserId, EventId) ->
case core_event:get_by_id(EventId) of
{ok, Event} ->
case core_calendar:get_by_id(Event#event.calendar_id) of
{ok, Calendar} ->
case admin_utils:is_admin(UserId)
orelse Calendar#calendar.owner_id =:= UserId of
true -> core_booking:list_by_event(EventId);
false -> {error, access_denied}
end;
{error, not_found} ->
{error, not_found}
end;
{error, not_found} ->
{error, not_found}
end.
%%%-------------------------------------------------------------------
%%% @doc Список всех бронирований (административный).
%%% @end