2018-01-17 11:39:01 +01:00
|
|
|
defmodule Eventos.Addresses.Address do
|
|
|
|
@moduledoc "An address for an event or a group"
|
|
|
|
|
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
|
|
|
alias Eventos.Addresses.Address
|
|
|
|
alias Eventos.Events.Event
|
|
|
|
alias Eventos.Groups.Group
|
|
|
|
|
|
|
|
schema "addresses" do
|
2018-07-27 10:45:35 +02:00
|
|
|
field(:addressCountry, :string)
|
|
|
|
field(:addressLocality, :string)
|
|
|
|
field(:addressRegion, :string)
|
|
|
|
field(:description, :string)
|
|
|
|
field(:floor, :string)
|
2018-08-24 12:31:41 +02:00
|
|
|
field(:geom, Geo.PostGIS.Geometry)
|
2018-07-27 10:45:35 +02:00
|
|
|
field(:postalCode, :string)
|
|
|
|
field(:streetAddress, :string)
|
|
|
|
has_one(:event, Event)
|
|
|
|
has_one(:group, Group)
|
2018-01-17 11:39:01 +01:00
|
|
|
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
def changeset(%Address{} = address, attrs) do
|
|
|
|
address
|
2018-07-27 10:45:35 +02:00
|
|
|
|> cast(attrs, [
|
|
|
|
:description,
|
|
|
|
:floor,
|
|
|
|
:geom,
|
|
|
|
:addressCountry,
|
|
|
|
:addressLocality,
|
|
|
|
:addressRegion,
|
|
|
|
:postalCode,
|
|
|
|
:streetAddress
|
|
|
|
])
|
2018-01-17 11:39:01 +01:00
|
|
|
end
|
|
|
|
end
|