diff --git a/lib/philomena_web/controllers/dnp_entry_controller.ex b/lib/philomena_web/controllers/dnp_entry_controller.ex index 37140ab5..3e1564ff 100644 --- a/lib/philomena_web/controllers/dnp_entry_controller.ex +++ b/lib/philomena_web/controllers/dnp_entry_controller.ex @@ -33,6 +33,7 @@ defmodule PhilomenaWeb.DnpEntryController do defp load_entries(dnp_entries, conn, status) do dnp_entries = Repo.paginate(dnp_entries, conn.assigns.scrivener) + linked_tags = linked_tags(conn) bodies = dnp_entries @@ -42,7 +43,7 @@ defmodule PhilomenaWeb.DnpEntryController do dnp_entries = %{dnp_entries | entries: Enum.zip(bodies, dnp_entries.entries)} - render(conn, "index.html", title: "Do-Not-Post List", layout_class: "layout--medium", dnp_entries: dnp_entries, status_column: status) + render(conn, "index.html", title: "Do-Not-Post List", layout_class: "layout--medium", dnp_entries: dnp_entries, status_column: status, linked_tags: linked_tags) end def show(conn, _params) do @@ -102,11 +103,12 @@ defmodule PhilomenaWeb.DnpEntryController do end end - defp linked_tags(conn) do - conn.assigns.current_user + defp linked_tags(%{assigns: %{current_user: user}}) when not is_nil(user) do + user |> Repo.preload(:linked_tags) |> Map.get(:linked_tags) end + defp linked_tags(_), do: [] defp set_mod_notes(conn, _opts) do case Canada.Can.can?(conn.assigns.current_user, :index, ModNote) do diff --git a/lib/philomena_web/templates/dnp_entry/index.html.slime b/lib/philomena_web/templates/dnp_entry/index.html.slime index 115ed2cf..0edda2f4 100644 --- a/lib/philomena_web/templates/dnp_entry/index.html.slime +++ b/lib/philomena_web/templates/dnp_entry/index.html.slime @@ -10,6 +10,25 @@ h3 Information p We ask that you please respect the wishes of artists in regards to their artworks, and check the list before uploading. Note that just because an artist is not listed may not mean that their artwork is ok to post, especially if they have a note at their "source" that they do not wish for their artwork to be reposted. br +.block + .block__header + span.block__header__title Manage My Listings + .block__content + = cond do + - not is_nil(@current_user) and Enum.any?(@linked_tags) -> + = link "Create an entry", to: Routes.dnp_entry_path(@conn, :new) + br + = link "My Listings", to: Routes.dnp_entry_path(@conn, :index, mine: "1") + + - not is_nil(@current_user) -> + ' You must have a verified user link to create and manage DNP entries. + = link "Request a user link", to: Routes.profile_user_link_path(@conn, :new, @current_user) + | . + + - true -> + ' You must be logged in and have a verified user link to create and manage DNP entries. + + h3 The List .block - route = fn p -> Routes.dnp_entry_path(@conn, :index, p) end