modreports: allow users to see modreports they've submitted.
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
|
||||
* Removed the option to disable tag autocomplete.
|
||||
|
||||
* You can now see the list of comments and forum posts you've reported to
|
||||
the moderators at <https://danbooru.donmai.us/moderation_reports>.
|
||||
|
||||
## 2021-01-12
|
||||
|
||||
### Changes
|
||||
|
||||
@@ -20,6 +20,14 @@ class ModerationReport < ApplicationRecord
|
||||
MODEL_TYPES
|
||||
end
|
||||
|
||||
def self.visible(user)
|
||||
if user.is_moderator?
|
||||
all
|
||||
else
|
||||
where(creator: user)
|
||||
end
|
||||
end
|
||||
|
||||
def forum_topic_title
|
||||
"Reports requiring moderation"
|
||||
end
|
||||
@@ -74,10 +82,6 @@ class ModerationReport < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def self.visible(user)
|
||||
user.is_moderator? ? all : none
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = search_attributes(params, :id, :created_at, :updated_at, :reason, :creator, :model)
|
||||
q = q.text_attribute_matches(:reason, params[:reason_matches])
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class ModerationReportPolicy < ApplicationPolicy
|
||||
def index?
|
||||
user.is_moderator?
|
||||
!user.is_anonymous?
|
||||
end
|
||||
|
||||
def show?
|
||||
user.is_moderator?
|
||||
!user.is_anonymous?
|
||||
end
|
||||
|
||||
def create?
|
||||
|
||||
@@ -34,9 +34,21 @@ class ModerationReportsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
context "as a user" do
|
||||
should "render the access denied page" do
|
||||
should "show reports submitted by the current user" do
|
||||
get_auth moderation_reports_path, @user
|
||||
assert_response 403
|
||||
|
||||
assert_response :success
|
||||
assert_select "tbody tr", count: 2
|
||||
assert_select "tr#moderation-report-#{@comment_report.id}", count: 1
|
||||
assert_select "tr#moderation-report-#{@forum_report.id}", count: 1
|
||||
assert_select "tr#moderation-report-#{@dmail_report.id}", count: 0
|
||||
end
|
||||
|
||||
should "not show reports submitted by other users" do
|
||||
get_auth moderation_reports_path, create(:user)
|
||||
|
||||
assert_response :success
|
||||
assert_select "tbody tr", count: 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user