2019-09-13 01:01:17 +02:00
|
|
|
defmodule Mobilizon.Events.EventOptions do
|
2019-08-28 11:28:27 +02:00
|
|
|
@moduledoc """
|
2019-09-13 01:01:17 +02:00
|
|
|
Represents an event options.
|
2019-08-28 11:28:27 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
use Ecto.Schema
|
|
|
|
|
2019-09-13 01:01:17 +02:00
|
|
|
import Ecto.Changeset
|
2019-08-28 11:28:27 +02:00
|
|
|
|
|
|
|
alias Mobilizon.Events.{
|
2019-09-22 16:26:23 +02:00
|
|
|
CommentModeration,
|
2019-08-28 11:28:27 +02:00
|
|
|
EventOffer,
|
2019-09-22 16:26:23 +02:00
|
|
|
EventParticipationCondition
|
2019-08-28 11:28:27 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 01:01:17 +02:00
|
|
|
@type t :: %__MODULE__{
|
|
|
|
maximum_attendee_capacity: integer,
|
|
|
|
remaining_attendee_capacity: integer,
|
|
|
|
show_remaining_attendee_capacity: boolean,
|
|
|
|
attendees: [String.t()],
|
|
|
|
program: String.t(),
|
|
|
|
comment_moderation: CommentModeration.t(),
|
|
|
|
show_participation_price: boolean,
|
|
|
|
offers: [EventOffer.t()],
|
|
|
|
participation_condition: [EventParticipationCondition.t()]
|
|
|
|
}
|
|
|
|
|
|
|
|
@attrs [
|
|
|
|
:maximum_attendee_capacity,
|
|
|
|
:remaining_attendee_capacity,
|
|
|
|
:show_remaining_attendee_capacity,
|
|
|
|
:attendees,
|
|
|
|
:program,
|
|
|
|
:comment_moderation,
|
|
|
|
:show_participation_price
|
|
|
|
]
|
|
|
|
|
2019-08-28 11:28:27 +02:00
|
|
|
@primary_key false
|
2019-09-09 09:31:08 +02:00
|
|
|
@derive Jason.Encoder
|
2019-08-28 11:28:27 +02:00
|
|
|
embedded_schema do
|
|
|
|
field(:maximum_attendee_capacity, :integer)
|
|
|
|
field(:remaining_attendee_capacity, :integer)
|
|
|
|
field(:show_remaining_attendee_capacity, :boolean)
|
|
|
|
field(:attendees, {:array, :string})
|
|
|
|
field(:program, :string)
|
|
|
|
field(:comment_moderation, CommentModeration)
|
|
|
|
field(:show_participation_price, :boolean)
|
2019-09-13 01:01:17 +02:00
|
|
|
|
|
|
|
embeds_many(:offers, EventOffer)
|
|
|
|
embeds_many(:participation_condition, EventParticipationCondition)
|
2019-08-28 11:28:27 +02:00
|
|
|
end
|
|
|
|
|
2019-09-13 01:01:17 +02:00
|
|
|
@doc false
|
|
|
|
@spec changeset(t, map) :: Ecto.Changeset.t()
|
2019-09-13 01:55:45 +02:00
|
|
|
def changeset(%__MODULE__{} = event_options, attrs) do
|
2019-09-13 01:01:17 +02:00
|
|
|
cast(event_options, attrs, @attrs)
|
2019-08-28 11:28:27 +02:00
|
|
|
end
|
|
|
|
end
|