2019-12-04 05:14:56 +01:00
|
|
|
defmodule PhilomenaWeb.ReportView do
|
|
|
|
use PhilomenaWeb, :view
|
|
|
|
|
|
|
|
alias Philomena.Images.Image
|
|
|
|
alias Philomena.Comments.Comment
|
|
|
|
alias Philomena.Commissions.Commission
|
|
|
|
alias Philomena.Conversations.Conversation
|
2019-12-05 05:12:49 +01:00
|
|
|
alias Philomena.Galleries.Gallery
|
2019-12-04 05:14:56 +01:00
|
|
|
alias Philomena.Posts.Post
|
|
|
|
alias Philomena.Users.User
|
|
|
|
|
|
|
|
import Ecto.Changeset
|
|
|
|
|
|
|
|
def report_categories do
|
|
|
|
[
|
|
|
|
"Rule #0: Namecalling, trolling, discrimination": "Rule #0",
|
|
|
|
"Rule #1: DNP, content theft, pay content, trace/bad edit": "Rule #1",
|
|
|
|
"Rule #2: Bad tagging/sourcing": "Rule #2",
|
|
|
|
"Rule #3: Image not MLP-related/obligatory pony": "Rule #3",
|
|
|
|
"Rule #4: Whining about filterable content": "Rule #4",
|
|
|
|
"Rule #5: Underage+human/anthro-looking porn": "Rule #5",
|
|
|
|
"Rule #6: Spam, off-topic, or general site abuse": "Rule #6",
|
|
|
|
"Rule #7: Above topic rating (NOT swear words)": "Rule #7",
|
|
|
|
"Rule #8: Privacy violation": "Rule #8",
|
|
|
|
"Rule #9: Commissions": "Rule #9",
|
|
|
|
"Rule #n: Spirit of the rules": "Rule #n",
|
|
|
|
"Other (please explain)": "Other",
|
|
|
|
"Takedown request": "Takedown request"
|
2020-01-11 05:20:19 +01:00
|
|
|
]
|
2019-12-04 05:14:56 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def image?(changeset), do: get_field(changeset, :reportable_type) == "Image"
|
|
|
|
def conversation?(changeset), do: get_field(changeset, :reportable_type) == "Conversation"
|
|
|
|
|
|
|
|
def report_row_class(%{state: "closed"}), do: "success"
|
|
|
|
def report_row_class(%{state: "in_progress"}), do: "warning"
|
|
|
|
def report_row_class(_report), do: "danger"
|
|
|
|
|
|
|
|
def pretty_state(%{state: "closed"}), do: "Closed"
|
|
|
|
def pretty_state(%{state: "in_progress"}), do: "In progress"
|
|
|
|
def pretty_state(%{state: "claimed"}), do: "Claimed"
|
|
|
|
def pretty_state(_report), do: "Open"
|
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(%Image{} = r),
|
2024-04-29 02:55:27 +02:00
|
|
|
do: link("Image >>#{r.id}", to: ~p"/images/#{r}")
|
2019-12-04 05:14:56 +01:00
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(%Comment{} = r),
|
2020-01-11 05:20:19 +01:00
|
|
|
do:
|
|
|
|
link("Comment on image >>#{r.image.id}",
|
2024-04-29 02:55:27 +02:00
|
|
|
to: ~p"/images/#{r.image}" <> "#comment_#{r.id}"
|
2020-01-11 05:20:19 +01:00
|
|
|
)
|
2019-12-04 05:14:56 +01:00
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(%Conversation{} = r),
|
2020-01-11 05:20:19 +01:00
|
|
|
do:
|
|
|
|
link("Conversation between #{r.from.name} and #{r.to.name}",
|
2024-04-29 02:55:27 +02:00
|
|
|
to: ~p"/conversations/#{r}"
|
2020-01-11 05:20:19 +01:00
|
|
|
)
|
2019-12-04 05:14:56 +01:00
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(%Commission{} = r),
|
2020-01-11 05:20:19 +01:00
|
|
|
do:
|
|
|
|
link("#{r.user.name}'s commission page",
|
2024-04-29 02:55:27 +02:00
|
|
|
to: ~p"/profiles/#{r.user}/commission"
|
2020-01-11 05:20:19 +01:00
|
|
|
)
|
2019-12-04 05:14:56 +01:00
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(%Gallery{} = r),
|
2024-04-29 02:55:27 +02:00
|
|
|
do: link("Gallery '#{r.title}' by #{r.creator.name}", to: ~p"/galleries/#{r}")
|
2019-12-05 05:12:49 +01:00
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(%Post{} = r),
|
2020-01-11 05:20:19 +01:00
|
|
|
do:
|
|
|
|
link("Post in #{r.topic.title}",
|
|
|
|
to:
|
2024-04-29 02:55:27 +02:00
|
|
|
~p"/forums/#{r.topic.forum}/topics/#{r.topic}?#{[post_id: r.id]}" <>
|
2020-01-11 05:20:19 +01:00
|
|
|
"#post_#{r.id}"
|
|
|
|
)
|
2019-12-04 05:14:56 +01:00
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(%User{} = r),
|
2024-04-29 02:55:27 +02:00
|
|
|
do: link("User '#{r.name}'", to: ~p"/profiles/#{r}")
|
2019-12-04 05:14:56 +01:00
|
|
|
|
2024-04-29 03:08:00 +02:00
|
|
|
def link_to_reported_thing(_reportable) do
|
2019-12-04 05:14:56 +01:00
|
|
|
"Reported item permanently destroyed."
|
|
|
|
end
|
|
|
|
end
|