2018-01-13 23:33:03 +01:00
|
|
|
defmodule Eventos.Events.Track do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
|
|
|
Represents a track for an event (such as a theme) having multiple sessions
|
|
|
|
"""
|
2018-01-13 23:33:03 +01:00
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
alias Eventos.Events.{Track, Event, Session}
|
|
|
|
|
|
|
|
schema "tracks" do
|
2018-07-27 10:45:35 +02:00
|
|
|
field(:color, :string)
|
|
|
|
field(:description, :string)
|
|
|
|
field(:name, :string)
|
|
|
|
belongs_to(:event, Event)
|
|
|
|
has_many(:sessions, Session)
|
2018-01-13 23:33:03 +01:00
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
def changeset(%Track{} = track, attrs) do
|
|
|
|
track
|
|
|
|
|> cast(attrs, [:name, :description, :color, :event_id])
|
|
|
|
|> validate_required([:name, :description, :color])
|
|
|
|
end
|
|
|
|
end
|