fixes #80: broken presence check on tag_id param

This commit is contained in:
byte[] 2020-04-30 00:38:47 -04:00
parent d2c9975870
commit 44b004f9ec

View file

@ -131,7 +131,7 @@ defmodule PhilomenaWeb.DnpEntryController do
end end
defp selectable_tags(conn) do defp selectable_tags(conn) do
case not is_nil(conn.params["tag_id"]) and case present?(conn.params["tag_id"]) and
Canada.Can.can?(conn.assigns.current_user, :index, DnpEntry) do Canada.Can.can?(conn.assigns.current_user, :index, DnpEntry) do
true -> [Repo.get!(Tag, conn.params["tag_id"])] true -> [Repo.get!(Tag, conn.params["tag_id"])]
false -> linked_tags(conn) false -> linked_tags(conn)
@ -146,6 +146,10 @@ defmodule PhilomenaWeb.DnpEntryController do
defp linked_tags(_), do: [] defp linked_tags(_), do: []
defp present?(nil), do: false
defp present?(""), do: false
defp present?(_), do: true
defp set_mod_notes(conn, _opts) do defp set_mod_notes(conn, _opts) do
case Canada.Can.can?(conn.assigns.current_user, :index, ModNote) do case Canada.Can.can?(conn.assigns.current_user, :index, ModNote) do
true -> true ->