From 08f364ccdc36c1937eab36b1eb1dbf6cf75c6c54 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 19 Feb 2018 11:35:45 +0100 Subject: [PATCH] Add constants --- app/controllers/admin/accompagnateurs_controller.rb | 7 +++++-- app/views/admin/accompagnateurs/_list_assign.html.haml | 2 +- app/views/admin/accompagnateurs/_list_not_assign.html.haml | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/accompagnateurs_controller.rb b/app/controllers/admin/accompagnateurs_controller.rb index 86adfbe91..7222fc0ca 100644 --- a/app/controllers/admin/accompagnateurs_controller.rb +++ b/app/controllers/admin/accompagnateurs_controller.rb @@ -4,6 +4,9 @@ class Admin::AccompagnateursController < AdminController before_action :retrieve_procedure + ASSIGN = 'assign' + NOT_ASSIGN = 'not_assign' + def show assign_scope = @procedure.gestionnaires @@ -47,10 +50,10 @@ class Admin::AccompagnateursController < AdminController to = params[:to] case to - when 'assign' + when ASSIGN gestionnaire.assign_to_procedure(procedure) flash.notice = "L'accompagnateur a bien été affecté" - when 'not_assign' + when NOT_ASSIGN gestionnaire.remove_from_procedure(procedure) flash.notice = "L'accompagnateur a bien été désaffecté" end diff --git a/app/views/admin/accompagnateurs/_list_assign.html.haml b/app/views/admin/accompagnateurs/_list_assign.html.haml index 5160a8292..4e9171ccf 100644 --- a/app/views/admin/accompagnateurs/_list_assign.html.haml +++ b/app/views/admin/accompagnateurs/_list_assign.html.haml @@ -9,7 +9,7 @@ - @accompagnateurs_assign.each do |accompagnateur| %tr %td.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center - %a.btn.btn-primary{ href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: 'not_assign')}", 'data-method' => 'put' } + %a.btn.btn-primary{ href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: Admin::AccompagnateursController::NOT_ASSIGN)}", 'data-method' => 'put' } .fa.fa-arrow-left %td{ style: 'padding-top: 11px; font-size: 15px; text-align: right;' }= accompagnateur.email diff --git a/app/views/admin/accompagnateurs/_list_not_assign.html.haml b/app/views/admin/accompagnateurs/_list_not_assign.html.haml index 9cecdbee1..bba53bfd1 100644 --- a/app/views/admin/accompagnateurs/_list_not_assign.html.haml +++ b/app/views/admin/accompagnateurs/_list_not_assign.html.haml @@ -16,7 +16,7 @@ %tr %td.col-xs-11{ style: 'padding-top: 11px; font-size: 15px;' }= accompagnateur.email %td.center - %a.btn.btn-success.gestionnaire-affectation{ href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: 'assign')}", 'data-method' => 'put' } + %a.btn.btn-success.gestionnaire-affectation{ href: "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: Admin::AccompagnateursController::ASSIGN)}", 'data-method' => 'put' } .fa.fa-arrow-right