Add adresses

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-01-17 11:39:01 +01:00
parent bfcdc38076
commit 07382d6aca
19 changed files with 551 additions and 42 deletions

View File

@@ -36,13 +36,13 @@ defmodule Eventos.Events.Event do
alias Eventos.Events.Event.TitleSlug
alias Eventos.Accounts.Account
alias Eventos.Groups.Group
alias Eventos.Addresses.Address
schema "events" do
field :begins_on, Timex.Ecto.DateTimeWithTimezone
field :description, :string
field :ends_on, Timex.Ecto.DateTimeWithTimezone
field :title, :string
field :geom, Geo.Geometry
field :slug, TitleSlug.Type
field :state, :integer, default: 0
field :status, :integer, default: 0
@@ -58,6 +58,7 @@ defmodule Eventos.Events.Event do
has_many :event_request, Request
has_many :tracks, Track
has_many :sessions, Session
belongs_to :address, Address
timestamps()
end
@@ -65,8 +66,9 @@ defmodule Eventos.Events.Event do
@doc false
def changeset(%Event{} = event, attrs) do
event
|> cast(attrs, [:title, :description, :begins_on, :ends_on, :organizer_account_id, :organizer_group_id, :category_id, :state, :geom, :status, :public, :thumbnail, :large_image, :publish_at])
|> cast(attrs, [:title, :description, :begins_on, :ends_on, :organizer_account_id, :organizer_group_id, :category_id, :state, :status, :public, :thumbnail, :large_image, :publish_at])
|> cast_assoc(:tags)
|> cast_assoc(:address)
|> validate_required([:title, :description, :begins_on, :ends_on, :organizer_account_id, :category_id])
|> TitleSlug.maybe_generate_slug()
|> TitleSlug.unique_constraint()

View File

@@ -43,7 +43,7 @@ defmodule Eventos.Events do
"""
def get_event_full!(id) do
event = Repo.get!(Event, id)
Repo.preload(event, [:organizer_account, :organizer_group, :category, :sessions, :tracks, :tags, :participants])
Repo.preload(event, [:organizer_account, :organizer_group, :category, :sessions, :tracks, :tags, :participants, :address])
end
@doc """