philomena/lib/philomena_web/views/admin/mod_note_view.ex

25 lines
771 B
Elixir
Raw Permalink Normal View History

2019-12-15 23:52:51 +01:00
defmodule PhilomenaWeb.Admin.ModNoteView do
use PhilomenaWeb, :view
alias Philomena.Users.User
alias Philomena.Reports.Report
alias Philomena.DnpEntries.DnpEntry
def link_to_noted_thing(%DnpEntry{tag: tag} = dnp_entry),
do: link("DNP entry for #{tag.name}", to: ~p"/dnp/#{dnp_entry}")
2019-12-15 23:52:51 +01:00
def link_to_noted_thing(%Report{user: nil} = report),
do: link("Report #{report.id}", to: ~p"/admin/reports/#{report}")
2019-12-15 23:52:51 +01:00
def link_to_noted_thing(%Report{user: user} = report),
2020-01-11 05:20:19 +01:00
do:
link("Report #{report.id} by #{user.name}",
to: ~p"/admin/reports/#{report}"
2020-01-11 05:20:19 +01:00
)
2019-12-15 23:52:51 +01:00
def link_to_noted_thing(%User{} = user),
do: link("User #{user.name}", to: ~p"/profiles/#{user}")
2019-12-15 23:52:51 +01:00
def link_to_noted_thing(_notable), do: "Item permanently deleted"
2019-12-15 23:52:51 +01:00
end