diff options
| author | Luc Donnet | 2017-07-13 17:13:12 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-07-13 17:13:12 +0200 |
| commit | ea3ad8d1f9db76e3d2dfc5f96c930af8db074690 (patch) | |
| tree | bde3f033418d512a80ef28703abb4c021c5a0f06 /app/controllers/line_footnotes_controller.rb | |
| parent | 3ef09ffa403dd253c19537bd3d477357d85bfa3d (diff) | |
| parent | 0a2f9ff965389133fb9656dfb5b222ccfc2b0531 (diff) | |
| download | chouette-core-ea3ad8d1f9db76e3d2dfc5f96c930af8db074690.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'app/controllers/line_footnotes_controller.rb')
| -rw-r--r-- | app/controllers/line_footnotes_controller.rb | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/app/controllers/line_footnotes_controller.rb b/app/controllers/line_footnotes_controller.rb index 6a9048392..581c921e8 100644 --- a/app/controllers/line_footnotes_controller.rb +++ b/app/controllers/line_footnotes_controller.rb @@ -1,15 +1,9 @@ -class LineFootnotesController < BreadcrumbController - defaults :resource_class => Chouette::Line - include PolicyChecker - respond_to :json, :only => :show +class LineFootnotesController < ChouetteController + defaults resource_class: Chouette::Line, collection_name: 'lines', instance_name: 'line' belongs_to :referential - def show - show! do - build_breadcrumb :show - end - @footnotes = @line.footnotes - end + 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 @@ -18,25 +12,31 @@ class LineFootnotesController < BreadcrumbController end def update - if @line.update(line_params) - redirect_to referential_line_footnotes_path(@referential, @line) , notice: t('notice.footnotes.updated') - else - render :edit + update! do |success, failure| + success.html { redirect_to referential_line_footnotes_path(@referential, @line) , notice: t('notice.footnotes.updated') } + failure.html { render :edit } end end protected - # overrides default - def check_policy + + protected + def authorize_resource authorize resource, "#{action_name}_footnote?".to_sym end - private + def authorize_resource_class + authorize resource_class, "#{action_name}_footnote?".to_sym + end + + alias_method :line, :resource + def resource - @referential = Referential.find params[:referential_id] - @line = @referential.lines.find params[:line_id] + @line ||= current_referential.lines.find params[:line_id] end + private + def line_params params.require(:line).permit( { footnotes_attributes: [ :code, :label, :_destroy, :id ] } ) |
