-
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 16 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 | ||||
---|---|---|---|---|---|---|
@@ -1,9 +1,11 @@ | ||||||
class WranglingGuidelinesController < ApplicationController | ||||||
include WranglingHelper | ||||||
|
||||||
before_action :admin_only, except: [:index, :show] | ||||||
|
||||||
# GET /wrangling_guidelines | ||||||
def index | ||||||
@wrangling_guidelines = WranglingGuideline.order('position ASC') | ||||||
@wrangling_guidelines = WranglingGuideline.order("position ASC") | ||||||
end | ||||||
|
||||||
# GET /wrangling_guidelines/1 | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. All of these actions are admin only (see the
Suggested change
|
||||||
@wrangling_guideline = WranglingGuideline.new | ||||||
end | ||||||
|
||||||
# GET /wrangling_guidelines/1/edit | ||||||
def edit | ||||||
authorize :wrangling if logged_in_as_admin? | ||||||
@wrangling_guideline = WranglingGuideline.find(params[:id]) | ||||||
end | ||||||
|
||||||
# GET /wrangling_guidelines/manage | ||||||
def manage | ||||||
@wrangling_guidelines = WranglingGuideline.order('position ASC') | ||||||
authorize :wrangling if logged_in_as_admin? | ||||||
@wrangling_guidelines = WranglingGuideline.order("position ASC") | ||||||
end | ||||||
|
||||||
# POST /wrangling_guidelines | ||||||
def create | ||||||
authorize :wrangling if logged_in_as_admin? | ||||||
@wrangling_guideline = WranglingGuideline.new(wrangling_guideline_params) | ||||||
|
||||||
if @wrangling_guideline.save | ||||||
flash[:notice] = ts('Wrangling Guideline was successfully created.') | ||||||
flash[:notice] = t("wrangling_guidelines.create") | ||||||
redirect_to(@wrangling_guideline) | ||||||
else | ||||||
render action: 'new' | ||||||
render action: "new" | ||||||
end | ||||||
end | ||||||
|
||||||
# PUT /wrangling_guidelines/1 | ||||||
def update | ||||||
authorize :wrangling if logged_in_as_admin? | ||||||
@wrangling_guideline = WranglingGuideline.find(params[:id]) | ||||||
|
||||||
if @wrangling_guideline.update(wrangling_guideline_params) | ||||||
flash[:notice] = ts('Wrangling Guideline was successfully updated.') | ||||||
flash[:notice] = t("wrangling_guidelines.update") | ||||||
redirect_to(@wrangling_guideline) | ||||||
else | ||||||
render action: 'edit' | ||||||
render action: "edit" | ||||||
end | ||||||
end | ||||||
|
||||||
# reorder FAQs | ||||||
def update_positions | ||||||
authorize :wrangling if logged_in_as_admin? | ||||||
if params[:wrangling_guidelines] | ||||||
@wrangling_guidelines = WranglingGuideline.reorder_list(params[:wrangling_guidelines]) | ||||||
flash[:notice] = ts('Wrangling Guidelines order was successfully updated.') | ||||||
flash[:notice] = t("wrangling_guidelines.reorder") | ||||||
end | ||||||
redirect_to(wrangling_guidelines_path) | ||||||
end | ||||||
|
||||||
# DELETE /wrangling_guidelines/1 | ||||||
def destroy | ||||||
authorize :wrangling if logged_in_as_admin? | ||||||
@wrangling_guideline = WranglingGuideline.find(params[:id]) | ||||||
@wrangling_guideline.destroy | ||||||
flash[:notice] = ts('Wrangling Guideline was successfully deleted.') | ||||||
flash[:notice] = t("wrangling_guidelines.delete") | ||||||
redirect_to(wrangling_guidelines_path) | ||||||
end | ||||||
|
||||||
|
@@ -72,5 +81,4 @@ def destroy | |||||
def wrangling_guideline_params | ||||||
params.require(:wrangling_guideline).permit(:title, :content) | ||||||
end | ||||||
|
||||||
end |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion to match #4891:
Suggested change
|
||||||
@admin_post, | ||||||
data: { confirm: "Are you sure you want to delete this news post?" }, | ||||||
method: :delete %> | ||||||
|
@@ -29,8 +29,9 @@ | |||||
<li> | ||||||
<%= span_if_current ts("Known Issues", key: "header"), known_issues_path %> | ||||||
</li> | ||||||
<li> | ||||||
<%= span_if_current ts("Wrangling Guidelines", key: "header"), | ||||||
wrangling_guidelines_path %> | ||||||
</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 commentThe reason will be displayed to describe this comment to others. Learn more. This can be shortened by using a relative key:
Suggested change
|
||||||
</li> | ||||||
<% end %> | ||||||
</ul> |
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?