2019-12-05 05:12:49 +01:00
|
|
|
defmodule PhilomenaWeb.Gallery.ReportController do
|
|
|
|
use PhilomenaWeb, :controller
|
|
|
|
|
|
|
|
alias PhilomenaWeb.ReportController
|
|
|
|
alias PhilomenaWeb.ReportView
|
|
|
|
alias Philomena.Galleries.Gallery
|
|
|
|
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-05 05:12:49 +01:00
|
|
|
plug PhilomenaWeb.CanaryMapPlug, new: :show, create: :show
|
2020-01-11 05:20:19 +01:00
|
|
|
|
|
|
|
plug :load_and_authorize_resource,
|
|
|
|
model: Gallery,
|
|
|
|
id_name: "gallery_id",
|
|
|
|
persisted: true,
|
|
|
|
preload: [:creator]
|
2019-12-05 05:12:49 +01:00
|
|
|
|
|
|
|
def new(conn, _params) do
|
|
|
|
gallery = conn.assigns.gallery
|
|
|
|
action = Routes.gallery_report_path(conn, :create, gallery)
|
2020-01-11 05:20:19 +01:00
|
|
|
|
2019-12-05 05:12:49 +01:00
|
|
|
changeset =
|
|
|
|
%Report{reportable_type: "Gallery", reportable_id: gallery.id}
|
|
|
|
|> Reports.change_report()
|
|
|
|
|
|
|
|
conn
|
|
|
|
|> put_view(ReportView)
|
2020-01-11 05:20:19 +01:00
|
|
|
|> render("new.html",
|
|
|
|
title: "Reporting Gallery",
|
|
|
|
reportable: gallery,
|
|
|
|
changeset: changeset,
|
|
|
|
action: action
|
|
|
|
)
|
2019-12-05 05:12:49 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def create(conn, params) do
|
|
|
|
gallery = conn.assigns.gallery
|
|
|
|
action = Routes.gallery_report_path(conn, :create, gallery)
|
|
|
|
|
|
|
|
ReportController.create(conn, action, gallery, "Gallery", params)
|
|
|
|
end
|
2019-12-16 20:24:38 +01:00
|
|
|
end
|