mobilizon.chapril.org-mobil.../lib/eventos/events/event.ex
Thomas Citharel 90ceb4f6fe initial commit
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2017-12-08 09:58:14 +01:00

27 lines
714 B
Elixir

defmodule Eventos.Events.Event do
use Ecto.Schema
import Ecto.Changeset
alias Eventos.Events.{Event, EventAccount, EventRequest}
alias Eventos.Accounts.Account
schema "events" do
field :begin_on, :utc_datetime
field :description, :string
field :ends_on, :utc_datetime
field :title, :string
has_one :organizer_id, Account
many_to_many :participants, Account, join_through: EventAccount
has_many :event_request, EventRequest
timestamps()
end
@doc false
def changeset(%Event{} = event, attrs) do
event
|> cast(attrs, [:title, :description, :begin_on, :ends_on])
|> validate_required([:title, :description, :begin_on, :ends_on, :organizer_id])
end
end