2018-10-11 17:37:39 +02:00
|
|
|
defmodule Mobilizon.Events.Session do
|
2018-01-14 17:56:50 +01:00
|
|
|
@moduledoc """
|
2019-09-13 01:01:17 +02:00
|
|
|
Represents a session for an event (such as a talk at a conference).
|
2018-01-14 17:56:50 +01:00
|
|
|
"""
|
2019-09-13 01:01:17 +02:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
use Ecto.Schema
|
2019-09-13 01:01:17 +02:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
import Ecto.Changeset
|
2019-09-13 01:01:17 +02:00
|
|
|
|
2019-09-13 01:55:45 +02:00
|
|
|
alias Mobilizon.Events.{Event, Track}
|
2019-09-13 01:01:17 +02:00
|
|
|
|
|
|
|
@type t :: %__MODULE__{
|
|
|
|
audios_urls: String.t(),
|
|
|
|
language: String.t(),
|
|
|
|
long_abstract: String.t(),
|
|
|
|
short_abstract: String.t(),
|
|
|
|
slides_url: String.t(),
|
|
|
|
subtitle: String.t(),
|
|
|
|
title: String.t(),
|
|
|
|
videos_urls: String.t(),
|
|
|
|
begins_on: DateTime.t(),
|
|
|
|
ends_on: DateTime.t(),
|
|
|
|
event: Event.t(),
|
|
|
|
track: Track.t()
|
|
|
|
}
|
|
|
|
|
|
|
|
@required_attrs [
|
|
|
|
:title,
|
|
|
|
:subtitle,
|
|
|
|
:short_abstract,
|
|
|
|
:long_abstract,
|
|
|
|
:language,
|
|
|
|
:slides_url,
|
|
|
|
:videos_urls,
|
|
|
|
:audios_urls
|
|
|
|
]
|
|
|
|
@optional_attrs [:event_id, :track_id]
|
|
|
|
@attrs @required_attrs ++ @optional_attrs
|
2018-01-13 23:33:03 +01:00
|
|
|
|
|
|
|
schema "sessions" do
|
2018-07-27 10:45:35 +02:00
|
|
|
field(:audios_urls, :string)
|
|
|
|
field(:language, :string)
|
|
|
|
field(:long_abstract, :string)
|
|
|
|
field(:short_abstract, :string)
|
|
|
|
field(:slides_url, :string)
|
|
|
|
field(:subtitle, :string)
|
|
|
|
field(:title, :string)
|
|
|
|
field(:videos_urls, :string)
|
2019-02-14 14:19:55 +01:00
|
|
|
field(:begins_on, :utc_datetime)
|
|
|
|
field(:ends_on, :utc_datetime)
|
2019-09-13 01:01:17 +02:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
belongs_to(:event, Event)
|
|
|
|
belongs_to(:track, Track)
|
2018-01-13 23:33:03 +01:00
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
2019-09-13 01:01:17 +02:00
|
|
|
@spec changeset(t, map) :: Ecto.Changeset.t()
|
2019-09-13 01:55:45 +02:00
|
|
|
def changeset(%__MODULE__{} = session, attrs) do
|
2018-01-13 23:33:03 +01:00
|
|
|
session
|
2019-09-13 01:01:17 +02:00
|
|
|
|> cast(attrs, @attrs)
|
|
|
|
|> validate_required(@required_attrs)
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
|
|
|
end
|