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.
|
* 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
|
## 2021-01-12
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|||||||
@@ -20,6 +20,14 @@ class ModerationReport < ApplicationRecord
|
|||||||
MODEL_TYPES
|
MODEL_TYPES
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.visible(user)
|
||||||
|
if user.is_moderator?
|
||||||
|
all
|
||||||
|
else
|
||||||
|
where(creator: user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def forum_topic_title
|
def forum_topic_title
|
||||||
"Reports requiring moderation"
|
"Reports requiring moderation"
|
||||||
end
|
end
|
||||||
@@ -74,10 +82,6 @@ class ModerationReport < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.visible(user)
|
|
||||||
user.is_moderator? ? all : none
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.search(params)
|
def self.search(params)
|
||||||
q = search_attributes(params, :id, :created_at, :updated_at, :reason, :creator, :model)
|
q = search_attributes(params, :id, :created_at, :updated_at, :reason, :creator, :model)
|
||||||
q = q.text_attribute_matches(:reason, params[:reason_matches])
|
q = q.text_attribute_matches(:reason, params[:reason_matches])
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
class ModerationReportPolicy < ApplicationPolicy
|
class ModerationReportPolicy < ApplicationPolicy
|
||||||
def index?
|
def index?
|
||||||
user.is_moderator?
|
!user.is_anonymous?
|
||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
user.is_moderator?
|
!user.is_anonymous?
|
||||||
end
|
end
|
||||||
|
|
||||||
def create?
|
def create?
|
||||||
|
|||||||
@@ -34,9 +34,21 @@ class ModerationReportsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "as a user" do
|
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
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user