2021-09-10 11:27:59 +02:00
|
|
|
defmodule Mobilizon.Events.Participant.Metadata do
|
|
|
|
@moduledoc """
|
|
|
|
Participation stats on event
|
|
|
|
"""
|
|
|
|
|
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
alias Mobilizon.Web.Email.Checker
|
|
|
|
|
|
|
|
@type t :: %__MODULE__{
|
|
|
|
email: String.t(),
|
|
|
|
confirmation_token: String.t(),
|
|
|
|
cancellation_token: String.t(),
|
|
|
|
message: String.t(),
|
|
|
|
locale: String.t()
|
|
|
|
}
|
|
|
|
|
|
|
|
@attrs [:email, :confirmation_token, :cancellation_token, :message, :locale]
|
|
|
|
|
|
|
|
@derive Jason.Encoder
|
|
|
|
embedded_schema do
|
|
|
|
field(:email, :string)
|
|
|
|
field(:confirmation_token, :string)
|
|
|
|
field(:cancellation_token, :string)
|
|
|
|
field(:message, :string)
|
|
|
|
field(:locale, :string)
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
2021-09-24 16:46:42 +02:00
|
|
|
@spec changeset(t | Ecto.Schema.t(), map) :: Ecto.Changeset.t()
|
2021-09-10 11:27:59 +02:00
|
|
|
def changeset(schema, params) do
|
|
|
|
schema
|
|
|
|
|> cast(params, @attrs)
|
|
|
|
|> Checker.validate_changeset()
|
|
|
|
end
|
|
|
|
end
|