fixes #106: prevent renaming the default filter

This commit is contained in:
byte[] 2020-04-29 23:35:05 -04:00
parent d82bb4f33f
commit 1e794b11d8

View file

@ -59,7 +59,7 @@ defmodule Philomena.Filters.Filter do
end
def update_changeset(filter, attrs) do
changeset(filter, attrs)
changeset(filter, strip_name_if_default(filter, attrs))
end
def deletion_changeset(filter) do
@ -86,4 +86,9 @@ defmodule Philomena.Filters.Filter do
changeset
end
end
defp strip_name_if_default(%{system: true, name: "Default"}, attrs),
do: Map.delete(attrs, "name")
defp strip_name_if_default(_filter, attrs), do: attrs
end