2019-12-04 05:14:56 +01:00
|
|
|
defmodule PhilomenaWeb.Image.ReportingController do
|
|
|
|
use PhilomenaWeb, :controller
|
|
|
|
|
|
|
|
alias Philomena.Images.Image
|
|
|
|
alias Philomena.DuplicateReports.DuplicateReport
|
|
|
|
alias Philomena.DuplicateReports
|
|
|
|
alias Philomena.Repo
|
|
|
|
import Ecto.Query
|
|
|
|
|
2020-01-11 05:20:19 +01:00
|
|
|
plug :load_and_authorize_resource,
|
|
|
|
model: Image,
|
|
|
|
id_name: "image_id",
|
|
|
|
persisted: true,
|
2020-12-03 20:23:32 +01:00
|
|
|
preload: [tags: :aliases]
|
2019-12-04 05:14:56 +01:00
|
|
|
|
|
|
|
def show(conn, _params) do
|
|
|
|
image = conn.assigns.image
|
|
|
|
|
|
|
|
dupe_reports =
|
|
|
|
DuplicateReport
|
2020-12-03 20:23:32 +01:00
|
|
|
|> preload([:user, :modifier, image: [:user, tags: :aliases], duplicate_of_image: [:user, tags: :aliases]])
|
2019-12-04 05:14:56 +01:00
|
|
|
|> where([d], d.image_id == ^image.id or d.duplicate_of_image_id == ^image.id)
|
|
|
|
|> Repo.all()
|
|
|
|
|
|
|
|
changeset =
|
|
|
|
%DuplicateReport{}
|
|
|
|
|> DuplicateReports.change_duplicate_report()
|
|
|
|
|
2020-01-11 05:20:19 +01:00
|
|
|
render(conn, "show.html",
|
|
|
|
layout: false,
|
|
|
|
image: image,
|
|
|
|
dupe_reports: dupe_reports,
|
|
|
|
changeset: changeset
|
|
|
|
)
|
2019-12-04 05:14:56 +01:00
|
|
|
end
|
2020-01-11 05:20:19 +01:00
|
|
|
end
|