Add state and fix casting

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2018-01-15 11:50:26 +01:00
parent a1f60cf386
commit 9df9a795c7
2 changed files with 3 additions and 1 deletions

View File

@ -44,6 +44,7 @@ defmodule Eventos.Events.Event do
field :geom, Geo.Geometry field :geom, Geo.Geometry
field :slug, TitleSlug.Type field :slug, TitleSlug.Type
field :state, :integer, default: 0 field :state, :integer, default: 0
field :status, :integer, default: 0
field :public, :boolean, default: true field :public, :boolean, default: true
field :thumbnail, :string field :thumbnail, :string
field :large_image, :string field :large_image, :string
@ -61,7 +62,7 @@ defmodule Eventos.Events.Event do
@doc false @doc false
def changeset(%Event{} = event, attrs) do def changeset(%Event{} = event, attrs) do
event event
|> cast(attrs, [:title, :description, :begins_on, :ends_on, :organizer_id]) |> cast(attrs, [:title, :description, :begins_on, :ends_on, :organizer_id, :state, :geom, :status, :public, :thumbnail, :large_image, :publish_at])
|> validate_required([:title, :description, :begins_on, :ends_on, :organizer_id]) |> validate_required([:title, :description, :begins_on, :ends_on, :organizer_id])
|> TitleSlug.maybe_generate_slug() |> TitleSlug.maybe_generate_slug()
|> TitleSlug.unique_constraint() |> TitleSlug.unique_constraint()

View File

@ -11,6 +11,7 @@ defmodule Eventos.Repo.Migrations.CreateEvents do
add :geom, :geometry add :geom, :geometry
add :state, :integer, null: false add :state, :integer, null: false
add :public, :boolean, null: false add :public, :boolean, null: false
add :status, :integer, null: false
add :large_image, :string add :large_image, :string
add :thumbnail, :string add :thumbnail, :string
add :publish_at, :datetimetz add :publish_at, :datetimetz