aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/line_footnotes_controller.rb
diff options
context:
space:
mode:
authorLuc Donnet2017-07-13 16:44:46 +0200
committerLuc Donnet2017-07-13 16:44:46 +0200
commit383ccd7d1337276c5d086e3dc077c7235fe0541d (patch)
treef44ebf3b4a76af9f04a8b48e874f20c42ed91bee /app/controllers/line_footnotes_controller.rb
parent20610cb69f5d6c27c7874c48bda39f9857720d1b (diff)
downloadchouette-core-383ccd7d1337276c5d086e3dc077c7235fe0541d.tar.bz2
Update policies to make a custom behaviour on footnotes Refs #4094 @1
Diffstat (limited to 'app/controllers/line_footnotes_controller.rb')
-rw-r--r--app/controllers/line_footnotes_controller.rb15
1 files changed, 11 insertions, 4 deletions
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