Skip to content

Commit

Permalink
address bilka2 comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesium-Ice committed Sep 13, 2024
1 parent 67faec0 commit 0858f9a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
18 changes: 8 additions & 10 deletions app/controllers/wrangling_guidelines_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class WranglingGuidelinesController < ApplicationController
include WranglingHelper

class WranglingGuidelinesController < ApplicationController
before_action :admin_only, except: [:index, :show]

# GET /wrangling_guidelines
Expand All @@ -15,25 +13,25 @@ def show

# GET /wrangling_guidelines/new
def new
authorize :wrangling if logged_in_as_admin?
authorize :wrangling
@wrangling_guideline = WranglingGuideline.new
end

# GET /wrangling_guidelines/1/edit
def edit
authorize :wrangling if logged_in_as_admin?
authorize :wrangling
@wrangling_guideline = WranglingGuideline.find(params[:id])
end

# GET /wrangling_guidelines/manage
def manage
authorize :wrangling if logged_in_as_admin?
authorize :wrangling
@wrangling_guidelines = WranglingGuideline.order("position ASC")
end

# POST /wrangling_guidelines
def create
authorize :wrangling if logged_in_as_admin?
authorize :wrangling
@wrangling_guideline = WranglingGuideline.new(wrangling_guideline_params)

if @wrangling_guideline.save
Expand All @@ -46,7 +44,7 @@ def create

# PUT /wrangling_guidelines/1
def update
authorize :wrangling if logged_in_as_admin?
authorize :wrangling
@wrangling_guideline = WranglingGuideline.find(params[:id])

if @wrangling_guideline.update(wrangling_guideline_params)
Expand All @@ -59,7 +57,7 @@ def update

# reorder FAQs
def update_positions
authorize :wrangling if logged_in_as_admin?
authorize :wrangling
if params[:wrangling_guidelines]
@wrangling_guidelines = WranglingGuideline.reorder_list(params[:wrangling_guidelines])
flash[:notice] = t("wrangling_guidelines.reorder")
Expand All @@ -69,7 +67,7 @@ def update_positions

# DELETE /wrangling_guidelines/1
def destroy
authorize :wrangling if logged_in_as_admin?
authorize :wrangling
@wrangling_guideline = WranglingGuideline.find(params[:id])
@wrangling_guideline.destroy
flash[:notice] = t("wrangling_guidelines.delete")
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/_admin_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</li>
<% if params[:controller] == "admin_posts" && params[:action] == "edit" %>
<li>
<%= link_to t("admin.admin_nav.delete"),
<%= link_to t(".news.delete_post"),
@admin_post,
data: { confirm: "Are you sure you want to delete this news post?" },
method: :delete %>
Expand All @@ -31,7 +31,7 @@
</li>
<% if policy(:wrangling).new? %>
<li>
<%= span_if_current t("admin.admin_nav.wrangling_guidelines"), wrangling_guidelines_path %>
<%= span_if_current t(".wrangling_guidelines"), wrangling_guidelines_path %>
</li>
<% end %>
</ul>
3 changes: 2 additions & 1 deletion config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ en:
requests: Manage Requests
page_heading: Invite New Users
admin_nav:
delete: Delete Post
news:
delete_post: Delete Post
wrangling_guidelines: Wrangling Guidelines
admin_options:
delete:
Expand Down

0 comments on commit 0858f9a

Please sign in to comment.