-
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?
Conversation
…dd-or-modify-wrangling-guidelines
app/views/admin/_header.html.erb
Outdated
@@ -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 comment
The 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.
@@ -14,21 +14,25 @@ def show | |||
# GET /wrangling_guidelines/new | |||
def new | |||
@wrangling_guideline = WranglingGuideline.new | |||
authorize @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 stick authorize
in front of WranglingGuideline
to make things a bit neater.
@@ -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 comment
The 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 policy(WranglingGuideline).edit?
instead.
Is there some way I can run the rubocop check locally? |
Yes, see https://github.com/otwcode/otwarchive/wiki/Coding-Standards#user-content-Previewing_Reviewdog_comments. If you're using Docker, I would recommend running the commands similarly to the tests, with docker compose run: |
When I fix the error with rubocop by replacing instances of ts with t, the wrangling_guidelines_controller_spec.rb unit tests fails with errors like so:
Does this mean instead of having instances of t("insert string here") I need to move "insert string here" into en.yml? |
Yes, as you said you need to move the string into the yml file and use a key in the t() call. You can find more information on the i18n standards wiki page. You may find the i18n-tasks section useful for some commands to find if you missed any translations - it would also flag this issue. |
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.
I'm not sarken, but I had a look over the PR and it looks good. Thank you!
Sorry for the delay! We were discussing how we wanted to approach admin roles for wrangling areas, and we determined the best way to do it would be to put everything -- including Wrangling Guidelines -- under one Obviously, that would require significant changes to this pull request. Is that something you'd be interested in working on? If not, that's fine! You've already spent a lot of time on this and I bet you're sick of it -- someone else would be happy to take over (and give you credit for all the work you did, of course). There's no rush to actually update this, but if you could let us know within the next 14 days if you'd like to keep working on this or would prefer someone else adopt it, that would be great. Thank you! |
I’m good with working on it |
Hi @Cesium-Ice! I started working on another issue in this same epic, with the |
This |
…dd-or-modify-wrangling-guidelines
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.
Thanks for updating this, there are just some minor issues remaining.
app/views/admin/_admin_nav.html.erb
Outdated
@@ -9,7 +9,7 @@ | |||
</li> | |||
<% if params[:controller] == "admin_posts" && params[:action] == "edit" %> | |||
<li> | |||
<%= link_to t("admin.admin_nav.delete", default: "Delete Post"), | |||
<%= link_to t("admin.admin_nav.delete"), |
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.
Suggestion to match #4891:
<%= link_to t("admin.admin_nav.delete"), | |
<%= link_to t(".news.delete_post"), |
include WranglingHelper | ||
|
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.
Is anything from the helper used in this file?
@@ -13,57 +15,64 @@ def show | |||
|
|||
# GET /wrangling_guidelines/new | |||
def new | |||
authorize :wrangling if logged_in_as_admin? |
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.
All of these actions are admin only (see the before_action
), so the logged_in_as_admin?
check is redundant. Please remove it here and from the other authorize calls in this controller.
authorize :wrangling if logged_in_as_admin? | |
authorize :wrangling |
app/views/admin/_admin_nav.html.erb
Outdated
</li> | ||
<% if policy(:wrangling).new? %> | ||
<li> | ||
<%= span_if_current t("admin.admin_nav.wrangling_guidelines"), wrangling_guidelines_path %> |
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.
This can be shortened by using a relative key:
<%= span_if_current t("admin.admin_nav.wrangling_guidelines"), wrangling_guidelines_path %> | |
<%= span_if_current t(".wrangling_guidelines"), wrangling_guidelines_path %> |
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.
Thank you very much!
Pull Request Checklist
as the first thing in your pull request title (e.g.
AO3-1234 Fix thing
)until they are reviewed and merged before creating new pull requests.
Issue
https://otwarchive.atlassian.net/browse/AO3-5520
Purpose
What does this PR do?
Testing Instructions
How can the Archive's QA team verify that this is working as you intended?
If you have a Jira account with access, please update or comment on the issue
with any new or missing testing instructions instead.
References
Are there other relevant issues/pull requests/mailing list discussions?
Credit
What name and pronouns should we use to credit you in the Archive of Our Own's Release Notes?
Cesium-Ice, they/them
If you have a Jira account, please include the same name in the "Full name"
field on your Jira profile, so we can assign you the issues you're working on.
Please note that if you do not fill in this section, we will use your GitHub account name and
they/them pronouns.