link_to_reported_thing, link_to_noted_thing

This commit is contained in:
Liam 2024-04-28 21:08:00 -04:00
parent e69f1bf3fa
commit c506ef884e
8 changed files with 20 additions and 20 deletions

View file

@ -10,7 +10,7 @@ table.table
= for {body, note} <- @mod_notes do = for {body, note} <- @mod_notes do
tr tr
td td
= link_to_noted_thing(@conn, note.notable) = link_to_noted_thing(note.notable)
td td
= body = body

View file

@ -12,7 +12,7 @@ table.table
tr tr
td td
=> reported_image @conn, report.reportable => reported_image @conn, report.reportable
= link_to_reported_thing @conn, report.reportable = link_to_reported_thing report.reportable
td td
span title=report.reason span title=report.reason
= truncate(report.reason) = truncate(report.reason)

View file

@ -1,6 +1,6 @@
h1 Showing Report h1 Showing Report
p p
= link_to_reported_thing @conn, @report.reportable = link_to_reported_thing @report.reportable
article.block.communication article.block.communication
.block__content.flex.flex--no-wrap .block__content.flex.flex--no-wrap

View file

@ -18,6 +18,6 @@ h1 Your Reports
tr tr
td class=report_row_class(r) td class=report_row_class(r)
= pretty_state(r) = pretty_state(r)
td = link_to_reported_thing(@conn, r.reportable) td = link_to_reported_thing(r.reportable)
td = r.reason td = r.reason
td = pretty_time(r.created_at) td = pretty_time(r.created_at)

View file

@ -1,7 +1,7 @@
h2 Submit a report h2 Submit a report
p p
strong strong
= link_to_reported_thing(@conn, @reportable) = link_to_reported_thing(@reportable)
.image-other .image-other
.dnp-warning .dnp-warning

View file

@ -5,20 +5,20 @@ defmodule PhilomenaWeb.Admin.ModNoteView do
alias Philomena.Reports.Report alias Philomena.Reports.Report
alias Philomena.DnpEntries.DnpEntry alias Philomena.DnpEntries.DnpEntry
def link_to_noted_thing(conn, %DnpEntry{tag: tag} = dnp_entry), def link_to_noted_thing(%DnpEntry{tag: tag} = dnp_entry),
do: link("DNP entry for #{tag.name}", to: ~p"/dnp/#{dnp_entry}") do: link("DNP entry for #{tag.name}", to: ~p"/dnp/#{dnp_entry}")
def link_to_noted_thing(conn, %Report{user: nil} = report), def link_to_noted_thing(%Report{user: nil} = report),
do: link("Report #{report.id}", to: ~p"/admin/reports/#{report}") do: link("Report #{report.id}", to: ~p"/admin/reports/#{report}")
def link_to_noted_thing(conn, %Report{user: user} = report), def link_to_noted_thing(%Report{user: user} = report),
do: do:
link("Report #{report.id} by #{user.name}", link("Report #{report.id} by #{user.name}",
to: ~p"/admin/reports/#{report}" to: ~p"/admin/reports/#{report}"
) )
def link_to_noted_thing(conn, %User{} = user), def link_to_noted_thing(%User{} = user),
do: link("User #{user.name}", to: ~p"/profiles/#{user}") do: link("User #{user.name}", to: ~p"/profiles/#{user}")
def link_to_noted_thing(_conn, _notable), do: "Item permanently deleted" def link_to_noted_thing(_notable), do: "Item permanently deleted"
end end

View file

@ -7,8 +7,8 @@ defmodule PhilomenaWeb.Admin.ReportView do
alias PhilomenaWeb.ReportView alias PhilomenaWeb.ReportView
alias PhilomenaWeb.ProfileView alias PhilomenaWeb.ProfileView
defp link_to_reported_thing(conn, reportable), defp link_to_reported_thing(reportable),
do: ReportView.link_to_reported_thing(conn, reportable) do: ReportView.link_to_reported_thing(reportable)
defp report_row_class(report), defp report_row_class(report),
do: ReportView.report_row_class(report) do: ReportView.report_row_class(report)

View file

@ -41,31 +41,31 @@ defmodule PhilomenaWeb.ReportView do
def pretty_state(%{state: "claimed"}), do: "Claimed" def pretty_state(%{state: "claimed"}), do: "Claimed"
def pretty_state(_report), do: "Open" def pretty_state(_report), do: "Open"
def link_to_reported_thing(conn, %Image{} = r), def link_to_reported_thing(%Image{} = r),
do: link("Image >>#{r.id}", to: ~p"/images/#{r}") do: link("Image >>#{r.id}", to: ~p"/images/#{r}")
def link_to_reported_thing(conn, %Comment{} = r), def link_to_reported_thing(%Comment{} = r),
do: do:
link("Comment on image >>#{r.image.id}", link("Comment on image >>#{r.image.id}",
to: ~p"/images/#{r.image}" <> "#comment_#{r.id}" to: ~p"/images/#{r.image}" <> "#comment_#{r.id}"
) )
def link_to_reported_thing(conn, %Conversation{} = r), def link_to_reported_thing(%Conversation{} = r),
do: do:
link("Conversation between #{r.from.name} and #{r.to.name}", link("Conversation between #{r.from.name} and #{r.to.name}",
to: ~p"/conversations/#{r}" to: ~p"/conversations/#{r}"
) )
def link_to_reported_thing(conn, %Commission{} = r), def link_to_reported_thing(%Commission{} = r),
do: do:
link("#{r.user.name}'s commission page", link("#{r.user.name}'s commission page",
to: ~p"/profiles/#{r.user}/commission" to: ~p"/profiles/#{r.user}/commission"
) )
def link_to_reported_thing(conn, %Gallery{} = r), def link_to_reported_thing(%Gallery{} = r),
do: link("Gallery '#{r.title}' by #{r.creator.name}", to: ~p"/galleries/#{r}") do: link("Gallery '#{r.title}' by #{r.creator.name}", to: ~p"/galleries/#{r}")
def link_to_reported_thing(conn, %Post{} = r), def link_to_reported_thing(%Post{} = r),
do: do:
link("Post in #{r.topic.title}", link("Post in #{r.topic.title}",
to: to:
@ -73,10 +73,10 @@ defmodule PhilomenaWeb.ReportView do
"#post_#{r.id}" "#post_#{r.id}"
) )
def link_to_reported_thing(conn, %User{} = r), def link_to_reported_thing(%User{} = r),
do: link("User '#{r.name}'", to: ~p"/profiles/#{r}") do: link("User '#{r.name}'", to: ~p"/profiles/#{r}")
def link_to_reported_thing(_conn, _reportable) do def link_to_reported_thing(_reportable) do
"Reported item permanently destroyed." "Reported item permanently destroyed."
end end
end end