Set an event UUID if default is nil

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-11-10 16:40:26 +01:00
parent aaf9c2c931
commit afff01d6d2
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -133,7 +133,7 @@ defmodule Mobilizon.Events.Event do
@doc false
@spec changeset(t | Ecto.Schema.t(), map) :: Changeset.t()
def changeset(%__MODULE__{} = event, attrs) do
attrs = Map.update(attrs, :uuid, Ecto.UUID.generate(), & &1)
attrs = Map.update(attrs, :uuid, Ecto.UUID.generate(), &(&1 || Ecto.UUID.generate()))
attrs = Map.update(attrs, :url, Routes.page_url(Endpoint, :event, attrs.uuid), & &1)
event