Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6634 Add board_assistants_team admin role #4749

Merged
merged 9 commits into from
Apr 4, 2024
2 changes: 1 addition & 1 deletion app/models/admin.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Admin < ApplicationRecord
VALID_ROLES = %w[superadmin board communications development_and_membership elections translation tag_wrangling docs support policy_and_abuse open_doors].freeze
VALID_ROLES = %w[superadmin board board_assistants_team communications development_and_membership docs elections translation tag_wrangling support policy_and_abuse open_doors].freeze

serialize :roles, Array

Expand Down
4 changes: 2 additions & 2 deletions app/policies/admin_banner_policy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AdminBannerPolicy < ApplicationPolicy
ACCESS_AND_EDIT_ROLES = %w[superadmin board communications development_and_membership support].freeze
CREATE_AND_DESTROY_ROLES = %w[superadmin board communications support].freeze
ACCESS_AND_EDIT_ROLES = %w[superadmin board board_assistants_team communications development_and_membership support].freeze
CREATE_AND_DESTROY_ROLES = %w[superadmin board board_assistants_team communications support].freeze

def index?
user_has_roles?(ACCESS_AND_EDIT_ROLES)
Expand Down
2 changes: 1 addition & 1 deletion app/policies/admin_post_policy.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AdminPostPolicy < ApplicationPolicy
POSTING_ROLES = %w[superadmin board communications support translation].freeze
POSTING_ROLES = %w[superadmin board board_assistants_team communications support translation].freeze

def can_post?
user_has_roles?(POSTING_ROLES)
Expand Down
12 changes: 9 additions & 3 deletions app/policies/comment_policy.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
class CommentPolicy < ApplicationPolicy
DESTROY_COMMENT_ROLES = %w[superadmin board policy_and_abuse support].freeze
DESTROY_ADMIN_POST_COMMENT_ROLES = %w[superadmin board communications elections policy_and_abuse support].freeze
DESTROY_ADMIN_POST_COMMENT_ROLES = %w[superadmin board board_assistants_team communications elections policy_and_abuse support].freeze
FREEZE_TAG_COMMENT_ROLES = %w[superadmin tag_wrangling].freeze
FREEZE_WORK_COMMENT_ROLES = %w[superadmin policy_and_abuse].freeze
HIDE_TAG_COMMENT_ROLES = %w[superadmin tag_wrangling].freeze
HIDE_WORK_COMMENT_ROLES = %w[superadmin policy_and_abuse].freeze
SPAM_ROLES = %w[superadmin board communications elections policy_and_abuse support].freeze
SPAM_ADMIN_POST_COMMENT_ROLES = %w[superadmin board board_assistants_team communications elections policy_and_abuse support].freeze
SPAM_COMMENT_ROLES = %w[superadmin board policy_and_abuse support].freeze

def can_destroy_comment?
case record.ultimate_parent
Expand Down Expand Up @@ -39,7 +40,12 @@ def can_hide_comment?
end

def can_mark_comment_spam?
user_has_roles?(SPAM_ROLES)
case record.ultimate_parent
when AdminPost
user_has_roles?(SPAM_ADMIN_POST_COMMENT_ROLES)
else
user_has_roles?(SPAM_COMMENT_ROLES)
end
end

alias destroy? can_destroy_comment?
Expand Down
1 change: 1 addition & 0 deletions config/locales/models/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ en:
attributes:
admin/role:
board: Board
board_assistants_team: Board Assistants Team
communications: Communications
development_and_membership: Development & Membership
docs: AO3 Docs
Expand Down
16 changes: 8 additions & 8 deletions spec/controllers/admin/banners_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications development_and_membership support]
authorized_roles: %w[superadmin board board_assistants_team communications development_and_membership support]
end

describe "GET #show" do
Expand All @@ -61,7 +61,7 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications development_and_membership support]
authorized_roles: %w[superadmin board board_assistants_team communications development_and_membership support]
end

describe "GET #new" do
Expand All @@ -72,7 +72,7 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications support]
authorized_roles: %w[superadmin board board_assistants_team communications support]
end

describe "POST #create" do
Expand All @@ -83,7 +83,7 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications support]
authorized_roles: %w[superadmin board board_assistants_team communications support]
end

describe "GET #edit" do
Expand All @@ -94,7 +94,7 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications development_and_membership support]
authorized_roles: %w[superadmin board board_assistants_team communications development_and_membership support]
end

describe "PUT #update" do
Expand All @@ -106,7 +106,7 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications development_and_membership support]
authorized_roles: %w[superadmin board board_assistants_team communications development_and_membership support]
end

describe "GET #confirm_delete" do
Expand All @@ -117,7 +117,7 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications support]
authorized_roles: %w[superadmin board board_assistants_team communications support]
end

describe "DELETE #destroy" do
Expand All @@ -129,6 +129,6 @@
end

it_behaves_like "only authorized admins are allowed",
authorized_roles: %w[superadmin board communications support]
authorized_roles: %w[superadmin board board_assistants_team communications support]
end
end
Loading
Loading