Events with only one event creator participant can't be left

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-02-07 17:57:49 +01:00
parent d1d3beeb35
commit dfa25e0d21
3 changed files with 119 additions and 7 deletions

View File

@@ -582,6 +582,28 @@ defmodule Mobilizon.Events do
)
end
@doc """
Returns the list of organizers participants for an event.
## Examples
iex> list_organizers_participants_for_event(id)
[%Participant{role: :creator}, ...]
"""
def list_organizers_participants_for_event(id, page \\ nil, limit \\ nil) do
Repo.all(
from(
p in Participant,
join: e in Event,
on: p.event_id == e.id,
where: e.id == ^id and p.role == ^:creator,
preload: [:actor]
)
|> paginate(page, limit)
)
end
@doc """
Gets a single participant.