further fixes to the dnp template

This commit is contained in:
byte[] 2019-12-30 23:03:44 -05:00
parent 5ee81ea85e
commit 1c6387e847
2 changed files with 24 additions and 3 deletions

View file

@ -33,6 +33,7 @@ defmodule PhilomenaWeb.DnpEntryController do
defp load_entries(dnp_entries, conn, status) do defp load_entries(dnp_entries, conn, status) do
dnp_entries = Repo.paginate(dnp_entries, conn.assigns.scrivener) dnp_entries = Repo.paginate(dnp_entries, conn.assigns.scrivener)
linked_tags = linked_tags(conn)
bodies = bodies =
dnp_entries dnp_entries
@ -42,7 +43,7 @@ defmodule PhilomenaWeb.DnpEntryController do
dnp_entries = dnp_entries =
%{dnp_entries | entries: Enum.zip(bodies, dnp_entries.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 end
def show(conn, _params) do def show(conn, _params) do
@ -102,11 +103,12 @@ defmodule PhilomenaWeb.DnpEntryController do
end end
end end
defp linked_tags(conn) do defp linked_tags(%{assigns: %{current_user: user}}) when not is_nil(user) do
conn.assigns.current_user user
|> Repo.preload(:linked_tags) |> Repo.preload(:linked_tags)
|> Map.get(:linked_tags) |> Map.get(:linked_tags)
end end
defp linked_tags(_), do: []
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

View file

@ -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. 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 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 h3 The List
.block .block
- route = fn p -> Routes.dnp_entry_path(@conn, :index, p) end - route = fn p -> Routes.dnp_entry_path(@conn, :index, p) end