aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2017-07-13 16:44:46 +0200
committerLuc Donnet2017-07-13 16:44:46 +0200
commit383ccd7d1337276c5d086e3dc077c7235fe0541d (patch)
treef44ebf3b4a76af9f04a8b48e874f20c42ed91bee
parent20610cb69f5d6c27c7874c48bda39f9857720d1b (diff)
downloadchouette-core-383ccd7d1337276c5d086e3dc077c7235fe0541d.tar.bz2
Update policies to make a custom behaviour on footnotes Refs #4094 @1
-rw-r--r--app/controllers/concerns/policy_checker.rb2
-rw-r--r--app/controllers/line_footnotes_controller.rb15
2 files changed, 12 insertions, 5 deletions
diff --git a/app/controllers/concerns/policy_checker.rb b/app/controllers/concerns/policy_checker.rb
index 9721dc63c..65a4428e2 100644
--- a/app/controllers/concerns/policy_checker.rb
+++ b/app/controllers/concerns/policy_checker.rb
@@ -2,7 +2,7 @@ module PolicyChecker
extend ActiveSupport::Concern
included do
- before_action :authorize_resource, only: [:destroy, :show, :update]
+ before_action :authorize_resource, only: [:destroy, :edit, :show, :update]
before_action :authorize_resource_class, only: [:create, :index, :new]
end
diff --git a/app/controllers/line_footnotes_controller.rb b/app/controllers/line_footnotes_controller.rb
index f24d624d4..581c921e8 100644
--- a/app/controllers/line_footnotes_controller.rb
+++ b/app/controllers/line_footnotes_controller.rb
@@ -2,6 +2,9 @@ class LineFootnotesController < ChouetteController
defaults resource_class: Chouette::Line, collection_name: 'lines', instance_name: 'line'
belongs_to :referential
+ before_action :authorize_resource, only: [:destroy_footnote, :edit_footnote, :show_footnote, :update_footnote]
+ before_action :authorize_resource_class, only: [:create_footnote, :index_footnote, :new_footnote]
+
def edit
edit! do
build_breadcrumb :edit
@@ -17,13 +20,17 @@ class LineFootnotesController < ChouetteController
protected
- alias_method :line, :resource
-
- # overrides default
- def check_policy
+ protected
+ def authorize_resource
authorize resource, "#{action_name}_footnote?".to_sym
end
+ def authorize_resource_class
+ authorize resource_class, "#{action_name}_footnote?".to_sym
+ end
+
+ alias_method :line, :resource
+
def resource
@line ||= current_referential.lines.find params[:line_id]
end