2018-10-11 17:37:39 +02:00
|
|
|
defmodule Mobilizon.Addresses.Address do
|
2018-01-17 11:39:01 +01:00
|
|
|
@moduledoc "An address for an event or a group"
|
|
|
|
|
|
|
|
use Ecto.Schema
|
|
|
|
import Ecto.Changeset
|
2018-10-11 17:37:39 +02:00
|
|
|
alias Mobilizon.Addresses.Address
|
|
|
|
alias Mobilizon.Events.Event
|
2018-11-12 23:30:47 +01:00
|
|
|
# alias Mobilizon.Actors.Actor
|
2018-01-17 11:39:01 +01:00
|
|
|
|
|
|
|
schema "addresses" do
|
2019-03-22 15:51:23 +01:00
|
|
|
field(:country, :string)
|
|
|
|
field(:locality, :string)
|
|
|
|
field(:region, :string)
|
2018-07-27 10:45:35 +02:00
|
|
|
field(:description, :string)
|
|
|
|
field(:floor, :string)
|
2018-08-24 12:31:41 +02:00
|
|
|
field(:geom, Geo.PostGIS.Geometry)
|
2019-03-22 15:51:23 +01:00
|
|
|
field(:postal_code, :string)
|
|
|
|
field(:street, :string)
|
2018-11-12 23:30:47 +01:00
|
|
|
has_one(:event, Event, foreign_key: :physical_address_id)
|
|
|
|
# has_one(:group, Actor)
|
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,
|
2019-03-22 15:51:23 +01:00
|
|
|
:country,
|
|
|
|
:locality,
|
|
|
|
:region,
|
|
|
|
:postal_code,
|
|
|
|
:street
|
2018-07-27 10:45:35 +02:00
|
|
|
])
|
2018-01-17 11:39:01 +01:00
|
|
|
end
|
|
|
|
end
|