2019-12-04 05:14:56 +01:00
|
|
|
defmodule PhilomenaWeb.Image.ReportController do
|
|
|
|
use PhilomenaWeb, :controller
|
|
|
|
|
|
|
|
alias PhilomenaWeb.ReportController
|
|
|
|
alias PhilomenaWeb.ReportView
|
|
|
|
alias Philomena.Images.Image
|
|
|
|
alias Philomena.Reports.Report
|
|
|
|
alias Philomena.Reports
|
|
|
|
|
|
|
|
plug PhilomenaWeb.FilterBannedUsersPlug
|
|
|
|
plug PhilomenaWeb.UserAttributionPlug
|
2020-09-12 19:43:16 +02:00
|
|
|
plug PhilomenaWeb.CaptchaPlug
|
|
|
|
plug PhilomenaWeb.CheckCaptchaPlug when action in [:create]
|
2019-12-04 05:14:56 +01:00
|
|
|
plug PhilomenaWeb.CanaryMapPlug, new: :show, create: :show
|
2020-01-11 05:20:19 +01:00
|
|
|
|
|
|
|
plug :load_and_authorize_resource,
|
|
|
|
model: Image,
|
|
|
|
id_name: "image_id",
|
|
|
|
persisted: true,
|
2023-05-29 13:06:41 +02:00
|
|
|
preload: [:sources, tags: :aliases]
|
2019-12-04 05:14:56 +01:00
|
|
|
|
|
|
|
def new(conn, _params) do
|
|
|
|
image = conn.assigns.image
|
2024-04-29 02:55:27 +02:00
|
|
|
action = ~p"/images/#{image}/reports"
|
2020-01-11 05:20:19 +01:00
|
|
|
|
2019-12-04 05:14:56 +01:00
|
|
|
changeset =
|
|
|
|
%Report{reportable_type: "Image", reportable_id: image.id}
|
|
|
|
|> Reports.change_report()
|
|
|
|
|
|
|
|
conn
|
|
|
|
|> put_view(ReportView)
|
2020-01-11 05:20:19 +01:00
|
|
|
|> render("new.html",
|
|
|
|
title: "Reporting Image",
|
|
|
|
reportable: image,
|
|
|
|
changeset: changeset,
|
|
|
|
action: action
|
|
|
|
)
|
2019-12-04 05:14:56 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def create(conn, params) do
|
|
|
|
image = conn.assigns.image
|
2024-04-29 02:55:27 +02:00
|
|
|
action = ~p"/images/#{image}/reports"
|
2019-12-04 05:14:56 +01:00
|
|
|
|
2024-07-21 04:40:57 +02:00
|
|
|
ReportController.create(conn, action, "Image", image, params)
|
2019-12-04 05:14:56 +01:00
|
|
|
end
|
2019-12-16 20:24:38 +01:00
|
|
|
end
|