fix dupe report submission

This commit is contained in:
byte[] 2019-12-06 19:11:25 -05:00
parent c1b92967c6
commit 0d3555c3da

View file

@ -10,6 +10,7 @@ defmodule PhilomenaWeb.DuplicateReportController do
@valid_states ~W(open rejected accepted claimed) @valid_states ~W(open rejected accepted claimed)
plug PhilomenaWeb.FilterBannedUsersPlug when action in [:create] plug PhilomenaWeb.FilterBannedUsersPlug when action in [:create]
plug PhilomenaWeb.UserAttributionPlug when action in [:create]
plug :load_resource, model: DuplicateReport, only: [:show], preload: [:image, :duplicate_of_image] plug :load_resource, model: DuplicateReport, only: [:show], preload: [:image, :duplicate_of_image]
def index(conn, params) do def index(conn, params) do
@ -29,11 +30,11 @@ defmodule PhilomenaWeb.DuplicateReportController do
end end
def create(conn, %{"duplicate_report" => duplicate_report_params}) do def create(conn, %{"duplicate_report" => duplicate_report_params}) do
attribution = conn.assigns.attribution attributes = conn.assigns.attributes
source = Repo.get!(Image, duplicate_report_params["image_id"]) source = Repo.get!(Image, duplicate_report_params["image_id"])
target = Repo.get!(Image, duplicate_report_params["duplicate_of_image_id"]) target = Repo.get!(Image, duplicate_report_params["duplicate_of_image_id"])
case DuplicateReports.create_duplicate_report(source, target, attribution, duplicate_report_params) do case DuplicateReports.create_duplicate_report(source, target, attributes, duplicate_report_params) do
{:ok, duplicate_report} -> {:ok, duplicate_report} ->
conn conn
|> put_flash(:info, "Duplicate report created successfully.") |> put_flash(:info, "Duplicate report created successfully.")