From aa8da0103f555a7889963e281f6e9119691ed2f6 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 6 Sep 2020 14:24:32 -0400 Subject: [PATCH] hide merge buttons when either image is hidden --- .../templates/duplicate_report/_image_cell.html.slime | 2 +- lib/philomena_web/views/duplicate_report_view.ex | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime b/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime index 0a60cba4..1e262a35 100644 --- a/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime +++ b/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime @@ -16,7 +16,7 @@ p = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @image, conn: @conn - = if can?(@conn, :edit, @report) and same_rating_tags?(@report) do + = if can?(@conn, :edit, @report) and mergeable?(@report) do = if @source do a href=Routes.duplicate_report_accept_reverse_path(@conn, :create, @report) data-method="post" button.button diff --git a/lib/philomena_web/views/duplicate_report_view.ex b/lib/philomena_web/views/duplicate_report_view.ex index ed30407d..f1224dd0 100644 --- a/lib/philomena_web/views/duplicate_report_view.ex +++ b/lib/philomena_web/views/duplicate_report_view.ex @@ -102,6 +102,10 @@ defmodule PhilomenaWeb.DuplicateReportView do def both_are_alternate_versions?(%{image: image, duplicate_of_image: duplicate_of_image}), do: alternate_version?(image) and alternate_version?(duplicate_of_image) + def mergeable?(%{image: image, duplicate_of_image: duplicate_of_image} = report) do + same_rating_tags?(report) and not image.hidden_from_users and not duplicate_of_image.hidden_from_users + end + defp artist_tags(%{tags: tags}) do tags |> Enum.filter(&(&1.namespace == "artist"))