Fix for adding addresses

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-11-05 11:49:45 +01:00
parent 23470a010c
commit f91f8ab926
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -187,8 +187,8 @@ defmodule Mobilizon.Events.Event do
# In case the provided addresses is an existing one
@spec put_address(Changeset.t(), map) :: Changeset.t()
defp put_address(%Changeset{} = changeset, %{physical_address: %{id: id} = _physical_address}) do
case Addresses.get_address!(id) do
defp put_address(%Changeset{} = changeset, %{physical_address: %{id: id} = _physical_address}) when not is_nil(id) do
case Addresses.get_address(id) do
%Address{} = address ->
put_assoc(changeset, :physical_address, address)