aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/line_footnotes_controller.rb33
-rw-r--r--app/controllers/referential_lines_controller.rb4
2 files changed, 37 insertions, 0 deletions
diff --git a/app/controllers/line_footnotes_controller.rb b/app/controllers/line_footnotes_controller.rb
new file mode 100644
index 000000000..6e3c08653
--- /dev/null
+++ b/app/controllers/line_footnotes_controller.rb
@@ -0,0 +1,33 @@
+class LineFootnotesController < ChouetteController
+ before_action :set_line
+ before_action :check_policy, :only => [:edit, :update]
+
+ def show
+ end
+
+ def edit
+ end
+
+ def update
+ if @line.update(line_params)
+ redirect_to referential_line_path(@referential, @line) , notice: t('notice.footnotes.updated')
+ else
+ render :edit
+ end
+ end
+
+ private
+ def check_policy
+ authorize @line, :update_footnote?
+ end
+
+ def set_line
+ @referential = Referential.find params[:referential_id]
+ @line = @referential.lines.find params[:line_id]
+ end
+
+ def line_params
+ params.require(:line).permit(
+ { footnotes_attributes: [ :code, :label, :_destroy, :id ] } )
+ end
+end
diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb
index fb53e4959..c1f3e01a8 100644
--- a/app/controllers/referential_lines_controller.rb
+++ b/app/controllers/referential_lines_controller.rb
@@ -1,4 +1,5 @@
class ReferentialLinesController < ChouetteController
+ before_action :check_policy, :only => [:edit, :update, :destroy]
defaults :resource_class => Chouette::Line, :collection_name => 'lines', :instance_name => 'line'
respond_to :html
@@ -79,6 +80,9 @@ class ReferentialLinesController < ChouetteController
end
private
+ def check_policy
+ authorize resource
+ end
def line_params
params.require(:line).permit(