2019-12-08 18:45:37 +01:00
|
|
|
defmodule PhilomenaWeb.Admin.ReportView do
|
|
|
|
use PhilomenaWeb, :view
|
|
|
|
|
2019-12-08 19:22:38 +01:00
|
|
|
alias Philomena.Images.Image
|
|
|
|
alias Philomena.Comments.Comment
|
|
|
|
|
2019-12-19 20:32:12 +01:00
|
|
|
alias PhilomenaWeb.ReportView
|
|
|
|
alias PhilomenaWeb.ProfileView
|
|
|
|
|
2024-06-06 22:28:35 +02:00
|
|
|
defp link_to_reported_thing(reportable),
|
|
|
|
do: ReportView.link_to_reported_thing(reportable)
|
2019-12-19 20:32:12 +01:00
|
|
|
|
|
|
|
defp report_row_class(report),
|
|
|
|
do: ReportView.report_row_class(report)
|
|
|
|
|
|
|
|
defp pretty_state(report),
|
|
|
|
do: ReportView.pretty_state(report)
|
|
|
|
|
2024-06-06 22:28:35 +02:00
|
|
|
defp user_abbrv(user),
|
|
|
|
do: ProfileView.user_abbrv(user)
|
2019-12-19 20:32:12 +01:00
|
|
|
|
|
|
|
defp current?(current_user, user),
|
|
|
|
do: ProfileView.current?(current_user, user)
|
2019-12-08 18:45:37 +01:00
|
|
|
|
|
|
|
def truncate(<<string::binary-size(50), _rest::binary>>), do: string <> "..."
|
|
|
|
def truncate(string), do: string
|
|
|
|
|
2024-06-06 22:28:35 +02:00
|
|
|
def truncated_ip_link(ip) do
|
2019-12-08 18:45:37 +01:00
|
|
|
case to_string(ip) do
|
|
|
|
<<string::binary-size(25), _rest::binary>> = ip ->
|
2024-06-06 22:28:35 +02:00
|
|
|
link(string <> "...", to: ~p"/ip_profiles/#{ip}")
|
2019-12-08 18:45:37 +01:00
|
|
|
|
|
|
|
ip ->
|
2024-06-06 22:28:35 +02:00
|
|
|
link(ip, to: ~p"/ip_profiles/#{ip}")
|
2019-12-08 18:45:37 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def ordered_tags(tags) do
|
|
|
|
Enum.sort_by(tags, & &1.name)
|
|
|
|
end
|
2019-12-08 19:22:38 +01:00
|
|
|
|
|
|
|
def reported_image(conn, %Image{} = image) do
|
2020-01-11 05:20:19 +01:00
|
|
|
render(PhilomenaWeb.ImageView, "_image_container.html",
|
|
|
|
image: image,
|
|
|
|
size: :thumb_tiny,
|
|
|
|
conn: conn
|
|
|
|
)
|
2019-12-08 19:22:38 +01:00
|
|
|
end
|
2020-01-11 05:20:19 +01:00
|
|
|
|
2019-12-08 19:22:38 +01:00
|
|
|
def reported_image(conn, %Comment{image: image}) do
|
2020-01-11 05:20:19 +01:00
|
|
|
render(PhilomenaWeb.ImageView, "_image_container.html",
|
|
|
|
image: image,
|
|
|
|
size: :thumb_tiny,
|
|
|
|
conn: conn
|
|
|
|
)
|
2019-12-08 19:22:38 +01:00
|
|
|
end
|
2020-01-11 05:20:19 +01:00
|
|
|
|
2019-12-08 19:22:38 +01:00
|
|
|
def reported_image(_conn, _reportable), do: nil
|
2019-12-08 18:45:37 +01:00
|
|
|
end
|