allow admins to create dnp entries on arbitrary tags

This commit is contained in:
byte[] 2019-12-30 19:04:19 -05:00
parent 7503e48591
commit a5966ae287
3 changed files with 6 additions and 1 deletions

View file

@ -11,6 +11,8 @@
= if manages_tags?(@conn) do = if manages_tags?(@conn) do
= link "Edit details", to: Routes.tag_path(@conn, :edit, @tag), class: "detail-link" = link "Edit details", to: Routes.tag_path(@conn, :edit, @tag), class: "detail-link"
= link "Usage", to: Routes.tag_detail_path(@conn, :index, @tag), class: "detail-link" = link "Usage", to: Routes.tag_detail_path(@conn, :index, @tag), class: "detail-link"
= if manages_dnp?(@conn) do
= link "Create new DNP entry", to: Routes.dnp_entry_path(@conn, :new, tag_id: @tag.id), class: "detail-link"
br br

View file

@ -23,6 +23,6 @@ defmodule PhilomenaWeb.DnpEntryView do
def pretty_state(_dnp_entry), do: "Requested" def pretty_state(_dnp_entry), do: "Requested"
def show_steps?(changeset) do def show_steps?(changeset) do
not is_nil(changeset.action) and not changeset.data.state == :loaded changeset.action == nil and changeset.data.__meta__.state != :loaded
end end
end end

View file

@ -144,6 +144,9 @@ defmodule PhilomenaWeb.TagView do
defp manages_links?(conn), defp manages_links?(conn),
do: can?(conn, :index, Philomena.UserLinks.UserLink) do: can?(conn, :index, Philomena.UserLinks.UserLink)
defp manages_dnp?(conn),
do: can?(conn, :index, Philomena.DnpEntries.DnpEntry)
defp tag_url_root do defp tag_url_root do
Application.get_env(:philomena, :tag_url_root) Application.get_env(:philomena, :tag_url_root)
end end