From ca3afb26fda1bde6a6cc6a7b4b931133cc3f86ec Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Mon, 9 Dec 2019 20:36:58 -0500 Subject: [PATCH] ensure moderators can see duplicate report tab --- lib/philomena/duplicate_reports.ex | 2 +- lib/philomena/users/ability.ex | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/philomena/duplicate_reports.ex b/lib/philomena/duplicate_reports.ex index 5f63ff43..7aa65069 100644 --- a/lib/philomena/duplicate_reports.ex +++ b/lib/philomena/duplicate_reports.ex @@ -161,7 +161,7 @@ defmodule Philomena.DuplicateReports do end def count_duplicate_reports(user) do - if Canada.Can.can?(user, :edit, DuplicateReport) do + if Canada.Can.can?(user, :index, DuplicateReport) do DuplicateReport |> where(state: "open") |> Repo.aggregate(:count, :id) diff --git a/lib/philomena/users/ability.ex b/lib/philomena/users/ability.ex index a387bfda..1cf88368 100644 --- a/lib/philomena/users/ability.ex +++ b/lib/philomena/users/ability.ex @@ -42,7 +42,10 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do # View IP addresses and fingerprints def can?(%User{role: "moderator"}, :show, :ip_address), do: true - # View reports + # Manage duplicate reports + def can?(%User{role: "moderator"}, :index, DuplicateReport), do: true + + # Manage reports def can?(%User{role: "moderator"}, :index, Report), do: true def can?(%User{role: "moderator"}, :show, %Report{}), do: true def can?(%User{role: "moderator"}, :edit, %Report{}), do: true @@ -64,6 +67,7 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do def can?(%User{role: "assistant", role_map: %{"Image" => "moderator"}}, :edit, %Image{}), do: true # Dupe assistant actions + def can?(%User{role: "assistant", role_map: %{"DuplicateReport" => "moderator"}}, :index, DuplicateReport), do: true def can?(%User{role: "assistant", role_map: %{"DuplicateReport" => "moderator"}}, :edit, %DuplicateReport{}), do: true def can?(%User{role: "assistant", role_map: %{"DuplicateReport" => "moderator"}}, :show, %Image{}), do: true def can?(%User{role: "assistant", role_map: %{"DuplicateReport" => "moderator"}}, :edit, %Image{}), do: true