ensure moderators can see duplicate report tab

This commit is contained in:
byte[] 2019-12-09 20:36:58 -05:00
parent 2c1725f20a
commit ca3afb26fd
2 changed files with 6 additions and 2 deletions

View file

@ -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)

View file

@ -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