-
Notifications
You must be signed in to change notification settings - Fork 497
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-5520 Admin roles restrict ability to add or modify wrangling guidelines #4398
base: master
Are you sure you want to change the base?
Changes from 8 commits
82a248f
218ffe0
50685ce
e62258f
3977744
e43f067
678733b
ac13808
52016ec
5d614f7
504f4cc
c6da49b
92d3f42
a48fef7
1683ac4
67faec0
0858f9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class WranglingGuidelinePolicy < ApplicationPolicy | ||
MANAGE_WRANGLING_GUIDELINE = %w[superadmin tag_wrangling].freeze | ||
|
||
def new? | ||
user_has_roles?(MANAGE_WRANGLING_GUIDELINE) | ||
end | ||
|
||
alias edit? new? | ||
alias manage? new? | ||
alias create? new? | ||
alias update? new? | ||
alias update_positions? new? | ||
alias destroy? new? | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,9 @@ | |
<% end %> | ||
<li><%= link_to ts("Archive FAQ", key: "header"), archive_faqs_path %></li> | ||
<li><%= link_to ts("Known Issues", key: "header"), known_issues_path %></li> | ||
<li><%= link_to ts("Wrangling Guidelines", key: "header"), wrangling_guidelines_path %></li> | ||
<% if policy(WranglingGuideline).new? %> | ||
<li><%= link_to ts("Wrangling Guidelines", key: "header"), wrangling_guidelines_path %></li> | ||
<% end %> | ||
</ul> | ||
</li> | ||
<% if policy(AdminBlacklistedEmail).index? %> | ||
|
@@ -58,7 +60,9 @@ | |
</ul> | ||
</li> | ||
<% end %> | ||
<li><%= link_to ts("Tag Wrangling", key: "header"), tag_wranglings_path %></li> | ||
<% if policy(WranglingGuideline).new? %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're not actually restricting Tag Wrangling in this PR, so let's leave the Tag Wrangling link as-is. |
||
<li><%= link_to ts("Tag Wrangling", key: "header"), tag_wranglings_path %></li> | ||
<% end %> | ||
<li><%= link_to ts("Locales", key: "header"), locales_path %></li> | ||
|
||
<% if policy(AdminActivity).index? %> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
<!--main content--> | ||
<div class="admin" role="article"> | ||
<% if logged_in_as_admin? %> | ||
<% if policy(WranglingGuideline).new? %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're deciding whether to display the edit link, let's use |
||
<div class="header"> | ||
<h3 class="heading"> | ||
Updated: <%=h @wrangling_guideline.updated_at %> | <%= link_to ts('Edit'), edit_wrangling_guideline_path(@wrangling_guideline) %> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anywhere we're doing
@wrangling_guideline = WranglingGuideline.new
or@wrangling_guideline = WranglingGuideline.find
, we should be able to just stickauthorize
in front ofWranglingGuideline
to make things a bit neater.