Add ability to add message for participation and improve participation

management interface

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-03-05 19:32:34 +01:00
parent 130a3cf23f
commit c732ec7f87
34 changed files with 736 additions and 368 deletions

View File

@@ -759,7 +759,7 @@ defmodule Mobilizon.Events do
Default behaviour is to not return :not_approved or :not_confirmed participants
"""
@spec list_participants_for_event(String.t(), list(atom()), integer | nil, integer | nil) ::
[Participant.t()]
Page.t()
def list_participants_for_event(
id,
roles \\ @default_participant_roles,
@@ -769,8 +769,7 @@ defmodule Mobilizon.Events do
id
|> list_participants_for_event_query()
|> filter_role(roles)
|> Page.paginate(page, limit)
|> Repo.all()
|> Page.build_page(page, limit)
end
@spec list_actors_participants_for_event(String.t()) :: [Actor.t()]

View File

@@ -18,11 +18,15 @@ defmodule Mobilizon.Events.Participant do
role: ParticipantRole.t(),
url: String.t(),
event: Event.t(),
actor: Actor.t()
actor: Actor.t(),
metadata: Map.t()
}
@required_attrs [:url, :role, :event_id, :actor_id]
@attrs @required_attrs
@metadata_attrs [:email, :confirmation_token, :cancellation_token, :message]
@timestamps_opts [type: :utc_datetime]
@primary_key {:id, :binary_id, autogenerate: true}
schema "participants" do
@@ -33,6 +37,7 @@ defmodule Mobilizon.Events.Participant do
field(:email, :string)
field(:confirmation_token, :string)
field(:cancellation_token, :string)
field(:message, :string)
end
belongs_to(:event, Event, primary_key: true)
@@ -70,7 +75,7 @@ defmodule Mobilizon.Events.Participant do
defp metadata_changeset(schema, params) do
schema
|> cast(params, [:email, :confirmation_token, :cancellation_token])
|> cast(params, @metadata_attrs)
|> Checker.validate_changeset()
end