From 3662b82039dbe5436557b9def62f04fe4a243c71 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 29 Aug 2018 22:11:38 +0200 Subject: [PATCH 01/25] =?UTF-8?q?accompagnateur=20=E2=86=92=20instructeur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{accompagnateur.scss => instructeur.scss} | 0 .../admin/gestionnaires_controller.rb | 8 +-- ...ntroller.rb => instructeurs_controller.rb} | 22 +++---- .../gestionnaires/activate_controller.rb | 2 +- .../new_gestionnaire/dossiers_controller.rb | 4 +- app/mailers/gestionnaire_mailer.rb | 4 +- app/serializers/dossier_serializer.rb | 4 +- .../dossier_table_export_serializer.rb | 4 +- app/views/admin/accompagnateurs/show.js.erb | 3 - app/views/admin/gestionnaires/_list.html.haml | 2 +- app/views/admin/gestionnaires/index.html.haml | 8 +-- .../_list_assign.html.haml | 6 +- .../_list_not_assign.html.haml | 8 +-- .../show.html.haml | 8 +-- app/views/admin/instructeurs/show.js.erb | 3 + app/views/admin/procedures/show.html.haml | 2 +- .../invite_gestionnaire.html.haml | 4 +- .../user_to_gestionnaire.text.haml | 4 +- .../gestionnaires/sessions/new.html.haml | 2 +- app/views/layouts/_new_header.haml | 2 +- .../_switch_devise_profile_module.html.haml | 2 +- ...min_instructeurscontroller_show.html.haml} | 2 +- ...dmin_procedurescontroller_navbar.html.haml | 6 +- ...admin_procedurescontroller_index.html.haml | 2 +- .../dossiers/_envoyer_dossier_block.html.haml | 6 +- .../dossiers/personnes_impliquees.html.haml | 2 +- .../shared/avis/_form.html.haml | 4 +- config/locales/dynamics/fr.yml | 8 +-- config/routes.rb | 8 +-- doc/apipie_examples.json | 2 +- .../admin/gestionnaires_controller_spec.rb | 4 +- ...pec.rb => instructeurs_controller_spec.rb} | 6 +- .../api/v1/dossiers_controller_spec.rb | 2 +- .../dossiers_controller_spec.rb | 4 +- .../features/admin/procedure_creation_spec.rb | 6 +- spec/mailers/avis_mailer_spec.rb | 2 +- .../dossier_table_export_serializer_spec.rb | 8 +-- .../accompagnateurs/show.html.haml_spec.rb | 61 ------------------- .../gestionnaires/index.html.haml_spec.rb | 4 +- .../admin/instructeurs/show.html.haml_spec.rb | 61 +++++++++++++++++++ .../_envoyer_dossier_block.html.haml_spec.rb | 2 +- 41 files changed, 151 insertions(+), 151 deletions(-) rename app/assets/stylesheets/new_design/{accompagnateur.scss => instructeur.scss} (100%) rename app/controllers/admin/{accompagnateurs_controller.rb => instructeurs_controller.rb} (53%) delete mode 100644 app/views/admin/accompagnateurs/show.js.erb rename app/views/admin/{accompagnateurs => instructeurs}/_list_assign.html.haml (58%) rename app/views/admin/{accompagnateurs => instructeurs}/_list_not_assign.html.haml (57%) rename app/views/admin/{accompagnateurs => instructeurs}/show.html.haml (76%) create mode 100644 app/views/admin/instructeurs/show.js.erb rename app/views/layouts/left_panels/{_left_panel_admin_accompagnateurscontroller_show.html.haml => _left_panel_admin_instructeurscontroller_show.html.haml} (51%) rename spec/controllers/admin/{accompagnateurs_controller_spec.rb => instructeurs_controller_spec.rb} (66%) delete mode 100644 spec/views/admin/accompagnateurs/show.html.haml_spec.rb create mode 100644 spec/views/admin/instructeurs/show.html.haml_spec.rb diff --git a/app/assets/stylesheets/new_design/accompagnateur.scss b/app/assets/stylesheets/new_design/instructeur.scss similarity index 100% rename from app/assets/stylesheets/new_design/accompagnateur.scss rename to app/assets/stylesheets/new_design/instructeur.scss diff --git a/app/controllers/admin/gestionnaires_controller.rb b/app/controllers/admin/gestionnaires_controller.rb index f77c49fc0..663edcd45 100644 --- a/app/controllers/admin/gestionnaires_controller.rb +++ b/app/controllers/admin/gestionnaires_controller.rb @@ -23,7 +23,7 @@ class Admin::GestionnairesController < AdminController end if procedure_id.present? - redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure_id) + redirect_to admin_procedure_instructeurs_path(procedure_id: procedure_id) else redirect_to admin_gestionnaires_path end @@ -54,7 +54,7 @@ class Admin::GestionnairesController < AdminController else User.create(email: email, password: password, confirmed_at: DateTime.now) end - flash.notice = 'Accompagnateur ajouté' + flash.notice = 'Instructeur ajouté' else flash.alert = @gestionnaire.errors.full_messages end @@ -62,10 +62,10 @@ class Admin::GestionnairesController < AdminController def assign_gestionnaire! if current_administrateur.gestionnaires.include? @gestionnaire - flash.alert = 'Accompagnateur déjà ajouté' + flash.alert = 'Instructeur déjà ajouté' else @gestionnaire.administrateurs.push current_administrateur - flash.notice = 'Accompagnateur ajouté' + flash.notice = 'Instructeur ajouté' # TODO Mailer no assign_to end end diff --git a/app/controllers/admin/accompagnateurs_controller.rb b/app/controllers/admin/instructeurs_controller.rb similarity index 53% rename from app/controllers/admin/accompagnateurs_controller.rb rename to app/controllers/admin/instructeurs_controller.rb index 366e662ef..a79dea1fd 100644 --- a/app/controllers/admin/accompagnateurs_controller.rb +++ b/app/controllers/admin/instructeurs_controller.rb @@ -1,4 +1,4 @@ -class Admin::AccompagnateursController < AdminController +class Admin::InstructeursController < AdminController include SmartListing::Helper::ControllerExtensions helper SmartListing::Helper @@ -10,42 +10,42 @@ class Admin::AccompagnateursController < AdminController def show assign_scope = @procedure.gestionnaires - @accompagnateurs_assign = smart_listing_create :accompagnateurs_assign, + @instructeurs_assign = smart_listing_create :instructeurs_assign, assign_scope, - partial: "admin/accompagnateurs/list_assign", + partial: "admin/instructeurs/list_assign", array: true not_assign_scope = current_administrateur.gestionnaires.where.not(id: assign_scope.ids) not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%") if params[:filter] - @accompagnateurs_not_assign = smart_listing_create :accompagnateurs_not_assign, + @instructeurs_not_assign = smart_listing_create :instructeurs_not_assign, not_assign_scope, - partial: "admin/accompagnateurs/list_not_assign", + partial: "admin/instructeurs/list_not_assign", array: true @gestionnaire ||= Gestionnaire.new end def update - gestionnaire = Gestionnaire.find(params[:accompagnateur_id]) + gestionnaire = Gestionnaire.find(params[:instructeur_id]) procedure = Procedure.find(params[:procedure_id]) to = params[:to] case to when ASSIGN if gestionnaire.assign_to_procedure(procedure) - flash.notice = "L'accompagnateur a bien été affecté" + flash.notice = "L'instructeur a bien été affecté" else - flash.alert = "L'accompagnateur a déjà été affecté" + flash.alert = "L'instructeur a déjà été affecté" end when NOT_ASSIGN if gestionnaire.remove_from_procedure(procedure) - flash.notice = "L'accompagnateur a bien été désaffecté" + flash.notice = "L'instructeur a bien été désaffecté" else - flash.alert = "L'accompagnateur a déjà été désaffecté" + flash.alert = "L'instructeur a déjà été désaffecté" end end - redirect_to admin_procedure_accompagnateurs_path, procedure_id: params[:procedure_id] + redirect_to admin_procedure_instructeurs_path, procedure_id: params[:procedure_id] end end diff --git a/app/controllers/gestionnaires/activate_controller.rb b/app/controllers/gestionnaires/activate_controller.rb index 61d957401..c2464ca58 100644 --- a/app/controllers/gestionnaires/activate_controller.rb +++ b/app/controllers/gestionnaires/activate_controller.rb @@ -5,7 +5,7 @@ class Gestionnaires::ActivateController < ApplicationController @gestionnaire = Gestionnaire.with_reset_password_token(params[:token]) if !@gestionnaire - flash.alert = "Le lien de validation du compte accompagnateur a expiré, #{view_context.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien." + flash.alert = "Le lien de validation du compte instructeur a expiré, #{view_context.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien." redirect_to root_path end end diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 3e6e6b24e..c7e11d740 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -31,13 +31,13 @@ module NewGestionnaire end def personnes_impliquees - @following_accompagnateurs_emails = dossier.followers_gestionnaires.pluck(:email) + @following_instructeurs_emails = dossier.followers_gestionnaires.pluck(:email) @avis_emails = dossier.avis.includes(:gestionnaire).map(&:email_to_display) @invites_emails = dossier.invites.map(&:email) @potential_recipients = procedure.gestionnaires.reject { |g| g == current_gestionnaire } end - def envoyer_a_accompagnateur + def envoyer_a_instructeur recipient = Gestionnaire.find(params[:recipient]) GestionnaireMailer.send_dossier(current_gestionnaire, dossier, recipient).deliver_later flash.notice = "Dossier envoyé" diff --git a/app/mailers/gestionnaire_mailer.rb b/app/mailers/gestionnaire_mailer.rb index 230e87fb5..87e822a03 100644 --- a/app/mailers/gestionnaire_mailer.rb +++ b/app/mailers/gestionnaire_mailer.rb @@ -4,7 +4,7 @@ class GestionnaireMailer < ApplicationMailer def invite_gestionnaire(gestionnaire, reset_password_token) @reset_password_token = reset_password_token @gestionnaire = gestionnaire - subject = "Activez votre compte accompagnateur" + subject = "Activez votre compte instructeur" mail(to: gestionnaire.email, subject: subject, @@ -13,7 +13,7 @@ class GestionnaireMailer < ApplicationMailer def user_to_gestionnaire(email) @email = email - subject = "Vous avez été nommé accompagnateur" + subject = "Vous avez été nommé instructeur" mail(to: @email, subject: subject) end diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index 6cf11e962..05575a90b 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -10,7 +10,7 @@ class DossierSerializer < ActiveModel::Serializer :received_at, :processed_at, :motivation, - :accompagnateurs, + :instructeurs, :invites has_one :individual @@ -71,7 +71,7 @@ class DossierSerializer < ActiveModel::Serializer object.en_instruction_at end - def accompagnateurs + def instructeurs object.followers_gestionnaires.pluck(:email) end diff --git a/app/serializers/dossier_table_export_serializer.rb b/app/serializers/dossier_table_export_serializer.rb index 325eaa160..6622f3401 100644 --- a/app/serializers/dossier_table_export_serializer.rb +++ b/app/serializers/dossier_table_export_serializer.rb @@ -10,7 +10,7 @@ class DossierTableExportSerializer < ActiveModel::Serializer :processed_at, :motivation - attribute :emails_accompagnateurs + attribute :emails_instructeurs attributes :individual_gender, :individual_prenom, @@ -62,7 +62,7 @@ class DossierTableExportSerializer < ActiveModel::Serializer object.individual&.gender end - def emails_accompagnateurs + def emails_instructeurs object.followers_gestionnaires.pluck(:email).join(' ') end end diff --git a/app/views/admin/accompagnateurs/show.js.erb b/app/views/admin/accompagnateurs/show.js.erb deleted file mode 100644 index 197a811b4..000000000 --- a/app/views/admin/accompagnateurs/show.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= smart_listing_update :accompagnateurs_not_assign %> - -<%= smart_listing_update :accompagnateurs_assign %> diff --git a/app/views/admin/gestionnaires/_list.html.haml b/app/views/admin/gestionnaires/_list.html.haml index f30dc9a57..ce6cb5f71 100644 --- a/app/views/admin/gestionnaires/_list.html.haml +++ b/app/views/admin/gestionnaires/_list.html.haml @@ -19,4 +19,4 @@ - else %h4.center - Aucun accompagnateur + Aucun instructeur diff --git a/app/views/admin/gestionnaires/index.html.haml b/app/views/admin/gestionnaires/index.html.haml index ea6ff62b4..081fa04ad 100644 --- a/app/views/admin/gestionnaires/index.html.haml +++ b/app/views/admin/gestionnaires/index.html.haml @@ -1,10 +1,10 @@ -%h1 Accompagnateurs disponibles +%h1 instructeurs disponibles %p - Cette page vous permet de gérer la liste des accompagnateurs disponibles pour être affectés à une procédure. + Cette page vous permet de gérer la liste des instructeurs disponibles pour être affectés à une procédure. %p{ style: 'font-style: italic' } - N.B. : cette page ne concerne que la liste des personnes disponibles. Si vous souhaitez affecter ou enlever un accompagnateur d'une procédure particulière, + N.B. : cette page ne concerne que la liste des personnes disponibles. Si vous souhaitez affecter ou enlever un instructeur d'une procédure particulière, utilisez plutôt la = link_to "page de la procédure", admin_procedures_path concernée. @@ -16,7 +16,7 @@ .col-xs-1   .col-xs-6 - %h3 Ajouter un accompagnateur + %h3 Ajouter un instructeur #procedure_new.section.section-label = form_for @gestionnaire, url: { controller: 'admin/gestionnaires', action: :create } do |f| .row diff --git a/app/views/admin/accompagnateurs/_list_assign.html.haml b/app/views/admin/instructeurs/_list_assign.html.haml similarity index 58% rename from app/views/admin/accompagnateurs/_list_assign.html.haml rename to app/views/admin/instructeurs/_list_assign.html.haml index 8afe8e25f..e384ce534 100644 --- a/app/views/admin/accompagnateurs/_list_assign.html.haml +++ b/app/views/admin/instructeurs/_list_assign.html.haml @@ -6,12 +6,12 @@ %th Enlever %th#email{ style: 'text-align: right;' } Email - - @accompagnateurs_assign.each do |accompagnateur| + - @instructeurs_assign.each do |instructeur| %tr %td.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center - = link_to "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: Admin::AccompagnateursController::NOT_ASSIGN)}", class: "btn btn-primary", 'data-method' => 'put' do + = link_to "#{admin_procedure_instructeurs_path(procedure_id: @procedure.id, instructeur_id: instructeur.id, to: Admin::InstructeursController::NOT_ASSIGN)}", class: "btn btn-primary", 'data-method' => 'put' do .fa.fa-arrow-left - %td{ style: 'padding-top: 11px; font-size: 15px; text-align: right;' }= accompagnateur.email + %td{ style: 'padding-top: 11px; font-size: 15px; text-align: right;' }= instructeur.email = smart_listing.paginate = smart_listing.pagination_per_page_links diff --git a/app/views/admin/accompagnateurs/_list_not_assign.html.haml b/app/views/admin/instructeurs/_list_not_assign.html.haml similarity index 57% rename from app/views/admin/accompagnateurs/_list_not_assign.html.haml rename to app/views/admin/instructeurs/_list_not_assign.html.haml index e9e156a07..1e14d5f1c 100644 --- a/app/views/admin/accompagnateurs/_list_not_assign.html.haml +++ b/app/views/admin/instructeurs/_list_not_assign.html.haml @@ -1,4 +1,4 @@ -= smart_listing_controls_for(:accompagnateurs_not_assign, { class: "form-inline text-right" }) do += smart_listing_controls_for(:instructeurs_not_assign, { class: "form-inline text-right" }) do .form-group.filter.input-append = text_field_tag :filter, '', class: "search form-control", placeholder: "Recherche...", autocomplete: :off @@ -12,11 +12,11 @@ %th#email Email %th Ajouter - - @accompagnateurs_not_assign.each do |accompagnateur| + - @instructeurs_not_assign.each do |instructeur| %tr - %td.col-xs-11{ style: 'padding-top: 11px; font-size: 15px;' }= accompagnateur.email + %td.col-xs-11{ style: 'padding-top: 11px; font-size: 15px;' }= instructeur.email %td.center - = link_to "#{admin_procedure_accompagnateurs_path(procedure_id: @procedure.id, accompagnateur_id: accompagnateur.id, to: Admin::AccompagnateursController::ASSIGN)}", class: "btn btn-success gestionnaire-affectation", 'data-method' => 'put' do + = link_to "#{admin_procedure_instructeurs_path(procedure_id: @procedure.id, instructeur_id: instructeur.id, to: Admin::InstructeursController::ASSIGN)}", class: "btn btn-success gestionnaire-affectation", 'data-method' => 'put' do .fa.fa-arrow-right diff --git a/app/views/admin/accompagnateurs/show.html.haml b/app/views/admin/instructeurs/show.html.haml similarity index 76% rename from app/views/admin/accompagnateurs/show.html.haml rename to app/views/admin/instructeurs/show.html.haml index 251f89880..3f0c6a2d3 100644 --- a/app/views/admin/accompagnateurs/show.html.haml +++ b/app/views/admin/instructeurs/show.html.haml @@ -1,13 +1,13 @@ .row.white-back - #accompagnateur_form + #instructeur_form .row .col-xs-6 %h3.text-info Disponibles - = smart_listing_render :accompagnateurs_not_assign + = smart_listing_render :instructeurs_not_assign %br %h3 - = t('dynamics.admin.procedure.onglet_accompagnateurs.add.title') + = t('dynamics.admin.procedure.onglet_instructeurs.add.title') #procedure_new.section.section-label = form_for @gestionnaire, url: { controller: 'admin/gestionnaires', action: :create } do |f| .row @@ -20,4 +20,4 @@ = f.submit 'Valider', class: 'btn btn-info', style: 'float: left;', id: 'add-gestionnaire-email' .col-xs-6 %h3.text-success Affectés - = smart_listing_render :accompagnateurs_assign + = smart_listing_render :instructeurs_assign diff --git a/app/views/admin/instructeurs/show.js.erb b/app/views/admin/instructeurs/show.js.erb new file mode 100644 index 000000000..8b9615843 --- /dev/null +++ b/app/views/admin/instructeurs/show.js.erb @@ -0,0 +1,3 @@ +<%= smart_listing_update :instructeurs_not_assign %> + +<%= smart_listing_update :instructeurs_assign %> diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index a77693c21..12c51c98b 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -8,7 +8,7 @@ - if @procedure.gestionnaires.empty? || @procedure.service.nil? - missing_elements = [] - if @procedure.gestionnaires.empty? - - missing_elements << 'des accompagnateurs' + - missing_elements << 'des instructeurs' - if @procedure.service.nil? - missing_elements << 'un service' - message = "Affectez #{missing_elements.join(' et ')} à votre procédure." diff --git a/app/views/gestionnaire_mailer/invite_gestionnaire.html.haml b/app/views/gestionnaire_mailer/invite_gestionnaire.html.haml index f8d4f77df..a7076b704 100644 --- a/app/views/gestionnaire_mailer/invite_gestionnaire.html.haml +++ b/app/views/gestionnaire_mailer/invite_gestionnaire.html.haml @@ -1,10 +1,10 @@ -- content_for(:title, 'Activation de votre compte accompagnateur') +- content_for(:title, 'Activation de votre compte instructeur') %p Bonjour, %p - Vous venez d'être nommé accompagnateur sur demarches-simplifiees.fr. + Vous venez d'être nommé instructeur sur demarches-simplifiees.fr. %p Votre compte a été créé pour l'adresse email #{@gestionnaire.email}. Pour l’activer, je vous invite à cliquer sur le lien suivant :  diff --git a/app/views/gestionnaire_mailer/user_to_gestionnaire.text.haml b/app/views/gestionnaire_mailer/user_to_gestionnaire.text.haml index f5e10ce94..6fc539af7 100644 --- a/app/views/gestionnaire_mailer/user_to_gestionnaire.text.haml +++ b/app/views/gestionnaire_mailer/user_to_gestionnaire.text.haml @@ -1,7 +1,7 @@ Bienvenue sur demarches-simplifiees.fr, \ -Vous venez d'être nommé accompagnateur sur demarches-simplifiees.fr. -Votre compte (#{@email}) vous donnera désormais aussi accès à l’espace accompagnateur. +Vous venez d'être nommé instructeur sur demarches-simplifiees.fr. +Votre compte (#{@email}) vous donnera désormais aussi accès à l’espace instructeur. \ Bonne journée, \ diff --git a/app/views/gestionnaires/sessions/new.html.haml b/app/views/gestionnaires/sessions/new.html.haml index 005803443..f7b275a8a 100644 --- a/app/views/gestionnaires/sessions/new.html.haml +++ b/app/views/gestionnaires/sessions/new.html.haml @@ -2,7 +2,7 @@ %br = image_tag(image_url(LOGO_NAME)) %br - %h2#gestionnaire_login Accompagnateur + %h2#gestionnaire_login Instructeur %br %br diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index d5b8890af..26e3a6eb7 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -78,7 +78,7 @@ %li = link_to gestionnaire_procedures_path, class: "menu-item menu-link" do = image_tag "icons/switch-profile.svg" - Passer en accompagnateur + Passer en instructeur - if administrateur_signed_in? && nav_bar_profile != :administrateur %li = link_to admin_procedures_path, class: "menu-item menu-link" do diff --git a/app/views/layouts/_switch_devise_profile_module.html.haml b/app/views/layouts/_switch_devise_profile_module.html.haml index beaaa67da..7cc41cc06 100644 --- a/app/views/layouts/_switch_devise_profile_module.html.haml +++ b/app/views/layouts/_switch_devise_profile_module.html.haml @@ -15,7 +15,7 @@ = link_to(gestionnaire_procedures_path) do %i.fa.fa-user   - Accompagnateur + instructeur - if administrateur_signed_in? %li diff --git a/app/views/layouts/left_panels/_left_panel_admin_accompagnateurscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_admin_instructeurscontroller_show.html.haml similarity index 51% rename from app/views/layouts/left_panels/_left_panel_admin_accompagnateurscontroller_show.html.haml rename to app/views/layouts/left_panels/_left_panel_admin_instructeurscontroller_show.html.haml index acfb49356..67d77cdcc 100644 --- a/app/views/layouts/left_panels/_left_panel_admin_accompagnateurscontroller_show.html.haml +++ b/app/views/layouts/left_panels/_left_panel_admin_instructeurscontroller_show.html.haml @@ -1 +1 @@ -= render partial: 'layouts/left_panels/left_panel_admin_procedurescontroller_navbar', locals: { active: 'Accompagnateurs' } += render partial: 'layouts/left_panels/left_panel_admin_procedurescontroller_navbar', locals: { active: 'Instructeurs' } diff --git a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml index 12f0f64bf..3c20ec785 100644 --- a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml +++ b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml @@ -18,9 +18,9 @@ .procedure-list-element Services - %a#onglet-accompagnateurs{ href: url_for(admin_procedure_accompagnateurs_path(@procedure)) } - .procedure-list-element{ class: ('active' if active == 'Accompagnateurs') } - = t('dynamics.admin.procedure.onglets.accompagnateurs') + %a#onglet-instructeurs{ href: url_for(admin_procedure_instructeurs_path(@procedure)) } + .procedure-list-element{ class: ('active' if active == 'instructeurs') } + = t('dynamics.admin.procedure.onglets.instructeurs') %a#onglet-description{ href: url_for(edit_admin_procedure_path(@procedure)) } .procedure-list-element{ class: ('active' if active == 'Description') } diff --git a/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml index 6202a734e..a8f948ee3 100644 --- a/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml +++ b/app/views/layouts/navbars/_navbar_admin_procedurescontroller_index.html.haml @@ -18,7 +18,7 @@ = link_to(admin_gestionnaires_path) do %i.fa.fa-user   - = t('dynamics.admin.menu.accompagnateurs') + = t('dynamics.admin.menu.instructeurs') %li.divider{ role: :separator } %li = link_to(admin_profile_path, id: :profile) do diff --git a/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml b/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml index bc5951438..b0b8079b7 100644 --- a/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml +++ b/app/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml @@ -1,10 +1,10 @@ -.tab-title= "Envoyer ce dossier à un autre accompagnateur" +.tab-title= "Envoyer ce dossier à un autre instructeur" - if potential_recipients.empty? %p.tab-paragraph - Vous êtes le seul accompagnateur assigné sur cette procédure + Vous êtes le seul instructeur assigné sur cette procédure - else - = form_for dossier, url: envoyer_a_accompagnateur_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form' } do |f| + = form_for dossier, url: envoyer_a_instructeur_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form' } do |f| .flex.justify-start.align-baseline = select_tag(:recipient, options_from_collection_for_select(potential_recipients, :id, :email)) = f.submit "Envoyer", class: "button large send gap-left" diff --git a/app/views/new_gestionnaire/dossiers/personnes_impliquees.html.haml b/app/views/new_gestionnaire/dossiers/personnes_impliquees.html.haml index 571279a48..74174e862 100644 --- a/app/views/new_gestionnaire/dossiers/personnes_impliquees.html.haml +++ b/app/views/new_gestionnaire/dossiers/personnes_impliquees.html.haml @@ -5,7 +5,7 @@ .personnes-impliquees.container = render partial: 'new_gestionnaire/dossiers/envoyer_dossier_block', locals: { dossier: @dossier, potential_recipients: @potential_recipients } - = render partial: 'new_gestionnaire/dossiers/personnes_impliquees_block', locals: { emails_collection: @following_accompagnateurs_emails, title: "Accompagnateurs qui suivent le dossier", blank: "Aucun accompagnateur ne suit ce dossier" } + = render partial: 'new_gestionnaire/dossiers/personnes_impliquees_block', locals: { emails_collection: @following_instructeurs_emails, title: "Instructeurs qui suivent le dossier", blank: "Aucun instructeur ne suit ce dossier" } = render partial: 'new_gestionnaire/dossiers/personnes_impliquees_block', locals: { emails_collection: @avis_emails, title: "Personnes à qui un avis a été demandé", blank: "Aucun avis n'a été demandé" } diff --git a/app/views/new_gestionnaire/shared/avis/_form.html.haml b/app/views/new_gestionnaire/shared/avis/_form.html.haml index 2a660ce51..c429b8103 100644 --- a/app/views/new_gestionnaire/shared/avis/_form.html.haml +++ b/app/views/new_gestionnaire/shared/avis/_form.html.haml @@ -10,7 +10,7 @@ %p.confidentiel.flex %span.icon.lock %span - Cet avis est confidentiel et n'est pas affiché aux autres experts consultés mais est visible par tous les accompagnateurs + Cet avis est confidentiel et n'est pas affiché aux autres experts consultés mais est visible par tous les instructeurs .send-wrapper = f.submit 'Demander un avis', class: 'button send' - else @@ -18,6 +18,6 @@ = f.label :confidentiel, 'Cet avis est' = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]], {}, onchange: "javascript:DS.toggleCondidentielExplanation(event);" .confidentiel-explanation - Il ne sera pas affiché aux autres experts consultés mais sera visible par les accompagnateurs + Il ne sera pas affiché aux autres experts consultés mais sera visible par les instructeurs .send-wrapper = f.submit 'Demander un avis', class: 'button send' diff --git a/config/locales/dynamics/fr.yml b/config/locales/dynamics/fr.yml index 782381f27..f568480b5 100644 --- a/config/locales/dynamics/fr.yml +++ b/config/locales/dynamics/fr.yml @@ -19,11 +19,11 @@ fr: nouvelle_procedure: 'Nouvelle procédure' menu: title: Mes procédures - accompagnateurs: Accompagnateurs + instructeurs: Instructeurs procedures: Procédures procedure: onglets: - accompagnateurs: Accompagnateurs - onglet_accompagnateurs: + instructeurs: Instructeurs + onglet_instructeurs: add: - title: 'Ajouter un accompagnateur' + title: 'Ajouter un instructeur' diff --git a/config/routes.rb b/config/routes.rb index b2d09f2c3..0b6e8a877 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -223,7 +223,7 @@ Rails.application.routes.draw do post 'transfer' => 'procedures#transfer', as: :transfer put 'clone' => 'procedures#clone', as: :clone - resource :accompagnateurs, only: [:show, :update] + resource :instructeurs, only: [:show, :update] resource :attestation_template, only: [:edit, :update, :create] @@ -234,8 +234,8 @@ Rails.application.routes.draw do patch 'attestation_template/preview' => 'attestation_templates#preview' end - namespace :accompagnateurs do - get 'show' # delete after fixed tests admin/accompagnateurs/show_spec without this line + namespace :instructeurs do + get 'show' # delete after fixed tests admin/instructeurs/show_spec without this line end resources :gestionnaires, only: [:index, :create, :destroy] @@ -319,7 +319,7 @@ Rails.application.routes.draw do post 'passer-en-instruction' => 'dossiers#passer_en_instruction' post 'repasser-en-construction' => 'dossiers#repasser_en_construction' post 'terminer' - post 'envoyer-a-accompagnateur' => 'dossiers#envoyer_a_accompagnateur' + post 'envoyer-a-instructeur' => 'dossiers#envoyer_a_instructeur' scope :carte do get 'position' end diff --git a/doc/apipie_examples.json b/doc/apipie_examples.json index 77d1d6c78..d3183ee70 100644 --- a/doc/apipie_examples.json +++ b/doc/apipie_examples.json @@ -51,7 +51,7 @@ "received_at": null, "processed_at": null, "motivation": null, - "accompagnateurs": [ + "instructeurs": [ "gestionnaire@apientreprise.fr" ], "invites": [ diff --git a/spec/controllers/admin/gestionnaires_controller_spec.rb b/spec/controllers/admin/gestionnaires_controller_spec.rb index 0e495f9e7..d44726b93 100644 --- a/spec/controllers/admin/gestionnaires_controller_spec.rb +++ b/spec/controllers/admin/gestionnaires_controller_spec.rb @@ -46,7 +46,7 @@ describe Admin::GestionnairesController, type: :controller do let(:procedure_id) { procedure.id } it { expect(response.status).to eq(302) } - it { expect(response).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure_id) } + it { expect(response).to redirect_to admin_procedure_instructeurs_path(procedure_id: procedure_id) } end describe 'Gestionnaire attributs in database' do @@ -148,7 +148,7 @@ describe Admin::GestionnairesController, type: :controller do end context 'Email notification' do - it 'Notification email is sent when accompagnateur is create' do + it 'Notification email is sent when instructeur is create' do expect_any_instance_of(Gestionnaire).to receive(:invite!) subject end diff --git a/spec/controllers/admin/accompagnateurs_controller_spec.rb b/spec/controllers/admin/instructeurs_controller_spec.rb similarity index 66% rename from spec/controllers/admin/accompagnateurs_controller_spec.rb rename to spec/controllers/admin/instructeurs_controller_spec.rb index f8891a2ad..ba7014a03 100644 --- a/spec/controllers/admin/accompagnateurs_controller_spec.rb +++ b/spec/controllers/admin/instructeurs_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Admin::AccompagnateursController, type: :controller do +describe Admin::InstructeursController, type: :controller do let(:admin) { create(:administrateur) } let(:procedure) { create :procedure, administrateur: admin } let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] } @@ -15,9 +15,9 @@ describe Admin::AccompagnateursController, type: :controller do end describe 'PUT #update' do - subject { put :update, params: { accompagnateur_id: gestionnaire.id, procedure_id: procedure.id, to: 'assign' } } + subject { put :update, params: { instructeur_id: gestionnaire.id, procedure_id: procedure.id, to: 'assign' } } - it { expect(subject).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure.id) } + it { expect(subject).to redirect_to admin_procedure_instructeurs_path(procedure_id: procedure.id) } context 'when assignement is valid' do before do diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 9aeb4704b..549ee4f95 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -137,7 +137,7 @@ describe API::V1::DossiersController do let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, motivation: "Motivation") } } let(:dossier_id) { dossier.id } let(:body) { JSON.parse(retour.body, symbolize_names: true) } - let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :accompagnateurs, :invites] } + let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :instructeurs, :invites] } subject { body[:dossier] } it 'return REST code 200', :show_in_doc do diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index c2ce8b187..87a5eb02a 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -31,7 +31,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end end - describe '#envoyer_a_accompagnateur' do + describe '#envoyer_a_instructeur' do let(:recipient) { create(:gestionnaire) } let(:gestionnaires) { [gestionnaire, recipient] } let(:mail) { double("mail") } @@ -45,7 +45,7 @@ describe NewGestionnaire::DossiersController, type: :controller do .and_return(mail) post( - :envoyer_a_accompagnateur, + :envoyer_a_instructeur, params: { recipient: recipient, procedure_id: procedure.id, diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb index 856ec0f1e..03987fbb5 100644 --- a/spec/features/admin/procedure_creation_spec.rb +++ b/spec/features/admin/procedure_creation_spec.rb @@ -83,7 +83,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do end end - scenario 'After adding champ and file, check impossibility to publish procedure, add accompagnateur and make publication' do + scenario 'After adding champ and file, check impossibility to publish procedure, add instructeur and make publication' do fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libelle de champ' click_on 'add_type_de_champ' click_on 'onglet-pieces' @@ -97,8 +97,8 @@ feature 'As an administrateur I wanna create a new procedure', js: true do expect(page).to have_selector('#disabled-publish-procedure') expect(page.find_by_id('disabled-publish-procedure')[:disabled]).to eq('true') - click_on 'onglet-accompagnateurs' - expect(page).to have_current_path(admin_procedure_accompagnateurs_path(Procedure.first)) + click_on 'onglet-instructeurs' + expect(page).to have_current_path(admin_procedure_instructeurs_path(Procedure.first)) fill_in 'gestionnaire_email', with: 'gestionnaire@apientreprise.fr' click_on 'add-gestionnaire-email' page.first('.gestionnaire-affectation').click diff --git a/spec/mailers/avis_mailer_spec.rb b/spec/mailers/avis_mailer_spec.rb index 4d4af26dd..58a70f0f1 100644 --- a/spec/mailers/avis_mailer_spec.rb +++ b/spec/mailers/avis_mailer_spec.rb @@ -13,7 +13,7 @@ RSpec.describe AvisMailer, type: :mailer do context 'when the recipient is not already registered' do before do - avis.email = 'accompagnateur@email.com' + avis.email = 'instructeur@email.com' avis.gestionnaire = nil end diff --git a/spec/serializers/dossier_table_export_serializer_spec.rb b/spec/serializers/dossier_table_export_serializer_spec.rb index 39b8b564b..a1a9ea2e2 100644 --- a/spec/serializers/dossier_table_export_serializer_spec.rb +++ b/spec/serializers/dossier_table_export_serializer_spec.rb @@ -37,18 +37,18 @@ describe DossierTableExportSerializer do end end - describe '#emails_accompagnateurs' do + describe '#emails_instructeurs' do let(:gestionnaire){ create(:gestionnaire) } let(:gestionnaire2) { create :gestionnaire } let(:dossier) { create(:dossier) } - subject { DossierTableExportSerializer.new(dossier).emails_accompagnateurs } + subject { DossierTableExportSerializer.new(dossier).emails_instructeurs } - context 'when there is no accompagnateurs' do + context 'when there is no instructeurs' do it { is_expected.to eq('') } end - context 'when there one accompagnateur' do + context 'when there one instructeur' do before { gestionnaire.followed_dossiers << dossier } it { is_expected.to eq(gestionnaire.email) } diff --git a/spec/views/admin/accompagnateurs/show.html.haml_spec.rb b/spec/views/admin/accompagnateurs/show.html.haml_spec.rb deleted file mode 100644 index 231b6f05a..000000000 --- a/spec/views/admin/accompagnateurs/show.html.haml_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe 'admin/accompagnateurs/show.html.haml', type: :view do - let(:admin) { create(:administrateur) } - let(:procedure) { create :procedure, administrateur: admin } - - let(:assign_gestionnaires) { procedure.gestionnaires } - let(:not_assign_gestionnaires) { admin.gestionnaires.where.not(id: assign_gestionnaires.ids) } - - before do - assign(:procedure, procedure) - assign(:gestionnaire, Gestionnaire.new) - - assign(:accompagnateurs_assign, (smart_listing_create :accompagnateurs_assign, - assign_gestionnaires, - partial: "admin/accompagnateurs/list_assign", - array: true)) - - assign(:accompagnateurs_not_assign, (smart_listing_create :accompagnateurs_not_assign, - not_assign_gestionnaires, - partial: "admin/accompagnateurs/list_not_assign", - array: true)) - end - - context 'when admin have none accompagnateur ' do - before do - render - end - - it { expect(rendered).to have_content('Aucun de disponible') } - - context 'when administrateur have none accompagnateur assign' do - it { expect(rendered).to have_content('Aucun d\'affecté') } - end - end - - context 'when administrateur have two accompagnateur' do - let!(:accompagnateur_1) { create :gestionnaire, email: 'plop@plop.com', administrateurs: [admin] } - let!(:accompagnateur_2) { create :gestionnaire, email: 'plip@plop.com', administrateurs: [admin] } - - before do - not_assign_gestionnaires.reload - assign_gestionnaires.reload - - assign(:accompagnateurs_assign, (smart_listing_create :accompagnateurs_assign, - assign_gestionnaires, - partial: "admin/accompagnateurs/list_assign", - array: true)) - - assign(:accompagnateurs_not_assign, (smart_listing_create :accompagnateurs_not_assign, - not_assign_gestionnaires, - partial: "admin/accompagnateurs/list_not_assign", - array: true)) - - render - end - - it { expect(rendered).to have_content(accompagnateur_1.email) } - it { expect(rendered).to have_content(accompagnateur_2.email) } - end -end diff --git a/spec/views/admin/gestionnaires/index.html.haml_spec.rb b/spec/views/admin/gestionnaires/index.html.haml_spec.rb index be3014619..fc07723af 100644 --- a/spec/views/admin/gestionnaires/index.html.haml_spec.rb +++ b/spec/views/admin/gestionnaires/index.html.haml_spec.rb @@ -16,10 +16,10 @@ describe 'admin/gestionnaires/index.html.haml', type: :view do before do render end - it { expect(rendered).to have_content('Aucun accompagnateur') } + it { expect(rendered).to have_content('Aucun instructeur') } end - context 'Ajout d\'un accompagnateur' do + context 'Ajout d\'un instructeur' do before do create(:gestionnaire, administrateurs: [admin]) admin.reload diff --git a/spec/views/admin/instructeurs/show.html.haml_spec.rb b/spec/views/admin/instructeurs/show.html.haml_spec.rb new file mode 100644 index 000000000..4cfb43168 --- /dev/null +++ b/spec/views/admin/instructeurs/show.html.haml_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe 'admin/instructeurs/show.html.haml', type: :view do + let(:admin) { create(:administrateur) } + let(:procedure) { create :procedure, administrateur: admin } + + let(:assign_gestionnaires) { procedure.gestionnaires } + let(:not_assign_gestionnaires) { admin.gestionnaires.where.not(id: assign_gestionnaires.ids) } + + before do + assign(:procedure, procedure) + assign(:gestionnaire, Gestionnaire.new) + + assign(:instructeurs_assign, (smart_listing_create :instructeurs_assign, + assign_gestionnaires, + partial: "admin/instructeurs/list_assign", + array: true)) + + assign(:instructeurs_not_assign, (smart_listing_create :instructeurs_not_assign, + not_assign_gestionnaires, + partial: "admin/instructeurs/list_not_assign", + array: true)) + end + + context 'when admin have none instructeur ' do + before do + render + end + + it { expect(rendered).to have_content('Aucun de disponible') } + + context 'when administrateur have none instructeur assign' do + it { expect(rendered).to have_content('Aucun d\'affecté') } + end + end + + context 'when administrateur have two instructeur' do + let!(:instructeur_1) { create :gestionnaire, email: 'plop@plop.com', administrateurs: [admin] } + let!(:instructeur_2) { create :gestionnaire, email: 'plip@plop.com', administrateurs: [admin] } + + before do + not_assign_gestionnaires.reload + assign_gestionnaires.reload + + assign(:instructeurs_assign, (smart_listing_create :instructeurs_assign, + assign_gestionnaires, + partial: "admin/instructeurs/list_assign", + array: true)) + + assign(:instructeurs_not_assign, (smart_listing_create :instructeurs_not_assign, + not_assign_gestionnaires, + partial: "admin/instructeurs/list_not_assign", + array: true)) + + render + end + + it { expect(rendered).to have_content(instructeur_1.email) } + it { expect(rendered).to have_content(instructeur_2.email) } + end +end diff --git a/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb index 8f8222e91..85454102b 100644 --- a/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/_envoyer_dossier_block.html.haml_spec.rb @@ -22,6 +22,6 @@ describe 'new_gestionnaire/dossiers/envoyer_dossier_block.html.haml', type: :vie it { is_expected.not_to have_css("select") } it { is_expected.not_to have_css(".button.send") } - it { is_expected.to have_content("Vous êtes le seul accompagnateur assigné sur cette procédure") } + it { is_expected.to have_content("Vous êtes le seul instructeur assigné sur cette procédure") } end end From c67f8dcaaa1b7c2ead9476003b13e9327e0d0f4d Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 18 Jul 2018 15:45:23 +0200 Subject: [PATCH 02/25] Add after_party --- Gemfile | 2 ++ Gemfile.lock | 2 ++ README.md | 4 ++++ config/deploy.rb | 11 +++++++++++ config/initializers/after_party.rb | 3 +++ db/migrate/20180718133126_create_task_records.rb | 7 +++++++ db/schema.rb | 4 ++++ 7 files changed, 33 insertions(+) create mode 100644 config/initializers/after_party.rb create mode 100644 db/migrate/20180718133126_create_task_records.rb diff --git a/Gemfile b/Gemfile index a2dcf01fe..7e4d12c8e 100644 --- a/Gemfile +++ b/Gemfile @@ -112,6 +112,8 @@ gem 'aasm' gem 'webpacker', '>= 4.0.x' +gem 'after_party' + # Cron jobs gem 'delayed_job_active_record' gem "daemons" diff --git a/Gemfile.lock b/Gemfile.lock index 2d43f9b81..326a72d48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,7 @@ GEM sass-rails (~> 5.0) selectize-rails (~> 0.6) aes_key_wrap (1.0.1) + after_party (1.10.0) apipie-rails (0.5.10) rails (>= 4.1) arel (9.0.0) @@ -806,6 +807,7 @@ DEPENDENCIES active_link_to active_model_serializers administrate + after_party apipie-rails bootstrap-sass (~> 3.3.5) bootstrap-wysihtml5-rails (~> 0.3.3.8) diff --git a/README.md b/README.md index 8c6d07ccc..1630cf873 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ Pour exécuter les tests de l'application, plusieurs possibilités : bin/rake spec SPEC=file_path/file_name_spec.rb bin/rspec file_path/file_name_spec.rb +## Ajout de taches à exécuter au déploiement + + rails generate after_party:task task_name + ## Debug Une fois `overmind` lancé, et un breakpoint `byebug` inséré dans le code, il faut se connecter au process `server` dans un nouveau terminal afin d'intéragir avec byebug : diff --git a/config/deploy.rb b/config/deploy.rb index 08489b8d8..e7e6bdf23 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -110,6 +110,16 @@ namespace :yarn do end end +namespace :rails do + desc "Run deploy tasks." + task :after_party do + queue %{ + echo "-----> Running deploy tasks" + #{echo_cmd %[bin/rake after_party:run]} + } + end +end + desc "Deploys the current version to the server." task :deploy => :environment do queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims' @@ -122,6 +132,7 @@ task :deploy => :environment do invoke :'bundle:install' invoke :'yarn:install' invoke :'rails:db_migrate' + invoke :'rails:after_party' invoke :'rails:assets_precompile:force' to :launch do diff --git a/config/initializers/after_party.rb b/config/initializers/after_party.rb new file mode 100644 index 000000000..66c8b1071 --- /dev/null +++ b/config/initializers/after_party.rb @@ -0,0 +1,3 @@ +AfterParty.setup do |config| + require "after_party/active_record.rb" +end diff --git a/db/migrate/20180718133126_create_task_records.rb b/db/migrate/20180718133126_create_task_records.rb new file mode 100644 index 000000000..ce6d2441b --- /dev/null +++ b/db/migrate/20180718133126_create_task_records.rb @@ -0,0 +1,7 @@ +class CreateTaskRecords < ActiveRecord::Migration[5.2] + def change + create_table :task_records, id: false do |t| + t.string :version, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d6c557ed8..cfa20d4aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -548,6 +548,10 @@ ActiveRecord::Schema.define(version: 2018_08_27_111451) do t.index ["administrateur_id"], name: "index_services_on_administrateur_id" end + create_table "task_records", id: false, force: :cascade do |t| + t.string "version", null: false + end + create_table "types_de_champ", id: :serial, force: :cascade do |t| t.string "libelle" t.string "type_champ" From 3f0e61d2924a8a5d6e91f5dec985efbefd3c330e Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 11:34:16 +0200 Subject: [PATCH 03/25] Remove from .gitignore a line that should be in a global .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index f01467f0c..ac9f9c928 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ public/uploads public/downloads doc/*.svg uploads/* -.DS_Store .byebug_history .env Procfile.dev From 15d1b01a90e6f312dfe2e257ed34d5926849c0c1 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 22:34:01 +0200 Subject: [PATCH 04/25] Code simplification --- app/controllers/stats_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 51c011012..7b7dacdc6 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -198,7 +198,7 @@ class StatsController < ApplicationController count_per_administrateur = procedures.group(:administrateur_id).count.values { 'Une procédure' => count_per_administrateur.select { |count| count == 1 }.count, - 'Entre deux et cinq procédures' => count_per_administrateur.select { |count| 2 <= count && count <= 5 }.count, + 'Entre deux et cinq procédures' => count_per_administrateur.select { |count| count.in?(2..5) }.count, 'Plus de cinq procédures' => count_per_administrateur.select { |count| 5 < count }.count } end From de48dab0310fd07a7c6015f29e820cefb1d7752f Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 11:52:15 +0200 Subject: [PATCH 05/25] Alignment --- app/controllers/root_controller.rb | 6 +++--- app/helpers/type_de_champ_helper.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 4c8a50539..54499e156 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -42,9 +42,9 @@ class RootController < ApplicationController end type_champ_values = { - TypeDeChamp.type_champs.fetch(:date) => '2016-07-26', - TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35', - TypeDeChamp.type_champs.fetch(:textarea) => 'Une description de mon projet' + TypeDeChamp.type_champs.fetch(:date) => '2016-07-26', + TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35', + TypeDeChamp.type_champs.fetch(:textarea) => 'Une description de mon projet' } type_champ_values.each do |(type_champ, value)| diff --git a/app/helpers/type_de_champ_helper.rb b/app/helpers/type_de_champ_helper.rb index 4d2ad46d9..f569382dd 100644 --- a/app/helpers/type_de_champ_helper.rb +++ b/app/helpers/type_de_champ_helper.rb @@ -1,7 +1,7 @@ module TypeDeChampHelper TOGGLES = { - TypeDeChamp.type_champs.fetch(:piece_justificative) => :champ_pj?, - TypeDeChamp.type_champs.fetch(:siret) => :champ_siret?, + TypeDeChamp.type_champs.fetch(:piece_justificative) => :champ_pj?, + TypeDeChamp.type_champs.fetch(:siret) => :champ_siret?, TypeDeChamp.type_champs.fetch(:linked_drop_down_list) => :champ_linked_dropdown? } From bf9f3b40df023d085554bf933083e20e4c822b91 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 11:56:51 +0200 Subject: [PATCH 06/25] Remove useless `.to_s` --- app/controllers/root_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 54499e156..f7e802545 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -49,7 +49,7 @@ class RootController < ApplicationController type_champ_values.each do |(type_champ, value)| all_champs - .select { |champ| champ.type_champ == type_champ.to_s } + .select { |champ| champ.type_champ == type_champ } .each { |champ| champ.value = value } end From 47962ef795db7e63f8fa80ec2d6a4e3c9dd4a431 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 14:12:48 +0200 Subject: [PATCH 07/25] Simplify route_authorization --- app/controllers/users/carte_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 2 +- app/controllers/users/recapitulatif_controller.rb | 8 +++++++- app/services/user_routes_authorization_service.rb | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index 258299254..032883703 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -59,7 +59,7 @@ class Users::CarteController < UsersController def self.route_authorization { - states: [:brouillon, :en_construction], + states: [Dossier.states.fetch(:brouillon), Dossier.states.fetch(:en_construction)], api_carto: true } end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index e62ef80b0..28d85cf8f 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -149,7 +149,7 @@ class Users::DossiersController < UsersController def self.route_authorization { - states: [:brouillon] + states: [Dossier.states.fetch(:brouillon)] } end diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index b8b7fb03a..d0657b72e 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -18,7 +18,13 @@ class Users::RecapitulatifController < UsersController def self.route_authorization { - states: [:en_construction, :en_instruction, :sans_suite, :accepte, :refuse] + states: [ + Dossier.states.fetch(:en_construction), + Dossier.states.fetch(:en_instruction), + Dossier.states.fetch(:sans_suite), + Dossier.states.fetch(:accepte), + Dossier.states.fetch(:refuse) + ] } end diff --git a/app/services/user_routes_authorization_service.rb b/app/services/user_routes_authorization_service.rb index a60c5b415..9fc85c97b 100644 --- a/app/services/user_routes_authorization_service.rb +++ b/app/services/user_routes_authorization_service.rb @@ -2,7 +2,7 @@ class UserRoutesAuthorizationService def self.authorized_route?(controller, dossier) auth = controller.route_authorization - auth[:states].include?(dossier.state.to_sym) && + auth[:states].include?(dossier.state) && (auth[:api_carto].nil? ? true : auth[:api_carto] == dossier.procedure.use_api_carto) end end From e60aa0c37b4ee1f93fa89daf0b7739dc32c6cfc9 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 28 Aug 2018 14:50:44 +0200 Subject: [PATCH 08/25] Use scopes when possible --- app/controllers/stats_controller.rb | 2 +- app/views/root/administration.html.haml | 2 +- app/views/root/landing.html.haml | 2 +- spec/controllers/stats_controller_spec.rb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 7b7dacdc6..c37ec9bad 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -7,7 +7,7 @@ class StatsController < ApplicationController def index procedures = Procedure.publiees_ou_archivees - dossiers = Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) + dossiers = Dossier.state_not_brouillon @procedures_numbers = procedures_numbers(procedures) @dossiers_numbers = dossiers_numbers(dossiers) diff --git a/app/views/root/administration.html.haml b/app/views/root/administration.html.haml index 63e28002f..bae00f101 100644 --- a/app/views/root/administration.html.haml +++ b/app/views/root/administration.html.haml @@ -124,7 +124,7 @@ partenaires %li.number .number-value - = number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr) + = number_with_delimiter(Dossier.state_not_brouillon.count, :locale => :fr) .number-label< dossiers %br<> diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index 35e367765..c912c1bfa 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -50,7 +50,7 @@ partenaires %li.number .number-value - = number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr) + = number_with_delimiter(Dossier.state_not_brouillon.count, :locale => :fr) .number-label< dossiers %br<> diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 93e8c8f50..f4ff56dcb 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -170,7 +170,7 @@ describe StatsController, type: :controller do } end - let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) } + let (:association) { Dossier.state_not_brouillon } subject { StatsController.new.send(:dossier_instruction_mean_time, association) } @@ -222,7 +222,7 @@ describe StatsController, type: :controller do } end - let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) } + let (:association) { Dossier.state_not_brouillon } subject { StatsController.new.send(:dossier_filling_mean_time, association) } From 89af9c2b36c89cd666216a12196f0e2dd3ac9ad7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 29 Aug 2018 15:08:26 +0200 Subject: [PATCH 09/25] Remove extra blank lines --- app/assets/stylesheets/new_design/stats.scss | 1 - app/views/new_gestionnaire/avis/show.html.haml | 1 - app/views/shared/champs/siret/_delete_etablissement.html.haml | 1 - 3 files changed, 3 deletions(-) diff --git a/app/assets/stylesheets/new_design/stats.scss b/app/assets/stylesheets/new_design/stats.scss index adea45065..c77d6ba36 100644 --- a/app/assets/stylesheets/new_design/stats.scss +++ b/app/assets/stylesheets/new_design/stats.scss @@ -144,4 +144,3 @@ $big-number-card-padding: 2 * $segmented-control-item-border-radius; text-align: center; color: $blue; } - diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml index 6a0e2e9d8..d008c0536 100644 --- a/app/views/new_gestionnaire/avis/show.html.haml +++ b/app/views/new_gestionnaire/avis/show.html.haml @@ -3,4 +3,3 @@ = render partial: 'header', locals: { avis: @avis, dossier: @dossier } = render partial: 'shared/dossiers/show', locals: { dossier: @dossier, demande_seen_at: nil } - diff --git a/app/views/shared/champs/siret/_delete_etablissement.html.haml b/app/views/shared/champs/siret/_delete_etablissement.html.haml index 1c4a888fb..1d443c0d2 100644 --- a/app/views/shared/champs/siret/_delete_etablissement.html.haml +++ b/app/views/shared/champs/siret/_delete_etablissement.html.haml @@ -3,4 +3,3 @@ - champ_attributes = etablissement.champ.private? ? 'champs_private_attributes' : 'champs_attributes' = fields_for "dossier[#{champ_attributes}][#{position}][etablissement_attributes]", etablissement do |form| = form.hidden_field :_destroy - From 04c6a653da654374bb3ebb19f55a10e55d83c103 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 29 Aug 2018 16:27:57 +0200 Subject: [PATCH 10/25] =?UTF-8?q?Unify=20the=20CSS=20filenames=E2=80=99=20?= =?UTF-8?q?case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../new_design/{procedure-logo.scss => procedure_logo.scss} | 0 .../stylesheets/new_design/{rich-text.scss => rich_text.scss} | 0 .../new_design/{services-index.scss => services_index.scss} | 0 .../new_design/{table-service.scss => table_service.scss} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename app/assets/stylesheets/new_design/{procedure-logo.scss => procedure_logo.scss} (100%) rename app/assets/stylesheets/new_design/{rich-text.scss => rich_text.scss} (100%) rename app/assets/stylesheets/new_design/{services-index.scss => services_index.scss} (100%) rename app/assets/stylesheets/new_design/{table-service.scss => table_service.scss} (100%) diff --git a/app/assets/stylesheets/new_design/procedure-logo.scss b/app/assets/stylesheets/new_design/procedure_logo.scss similarity index 100% rename from app/assets/stylesheets/new_design/procedure-logo.scss rename to app/assets/stylesheets/new_design/procedure_logo.scss diff --git a/app/assets/stylesheets/new_design/rich-text.scss b/app/assets/stylesheets/new_design/rich_text.scss similarity index 100% rename from app/assets/stylesheets/new_design/rich-text.scss rename to app/assets/stylesheets/new_design/rich_text.scss diff --git a/app/assets/stylesheets/new_design/services-index.scss b/app/assets/stylesheets/new_design/services_index.scss similarity index 100% rename from app/assets/stylesheets/new_design/services-index.scss rename to app/assets/stylesheets/new_design/services_index.scss diff --git a/app/assets/stylesheets/new_design/table-service.scss b/app/assets/stylesheets/new_design/table_service.scss similarity index 100% rename from app/assets/stylesheets/new_design/table-service.scss rename to app/assets/stylesheets/new_design/table_service.scss From 0e2b7ec6e1a653b58e508bb52bff895ffa023d77 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 12:51:28 +0100 Subject: [PATCH 11/25] try to fix after_party on deploy --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index e7e6bdf23..30b987ac6 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -115,7 +115,7 @@ namespace :rails do task :after_party do queue %{ echo "-----> Running deploy tasks" - #{echo_cmd %[bin/rake after_party:run]} + #{echo_cmd %[bundle exec rake after_party:run]} } end end From 37c45f0d29e3bcc1a881f0cbb8d2eca5998fe0a1 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 30 Aug 2018 11:51:35 +0200 Subject: [PATCH 12/25] [#2486] Always order champs to help activerecord cache the champs collection --- .../new_user/dossiers_controller.rb | 2 +- app/facades/dossier_facades.rb | 4 ++-- app/models/dossier.rb | 18 +++++------------- .../dossiers/annotations_privees.html.haml | 4 ++-- .../new_gestionnaire/dossiers/print.html.haml | 4 ++-- app/views/shared/dossiers/_show.html.haml | 2 +- spec/models/dossier_spec.rb | 12 ++++++------ 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index 3ffa4fa57..138ee6848 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -189,7 +189,7 @@ module NewUser end def dossier_with_champs - Dossier.with_ordered_champs.find(params[:id]) + Dossier.with_champs.find(params[:id]) end def ensure_ownership! diff --git a/app/facades/dossier_facades.rb b/app/facades/dossier_facades.rb index 635f8da82..5fbe5ae7f 100644 --- a/app/facades/dossier_facades.rb +++ b/app/facades/dossier_facades.rb @@ -10,7 +10,7 @@ class DossierFacades end def champs - @dossier.ordered_champs + @dossier.champs end def etablissement @@ -42,7 +42,7 @@ class DossierFacades end def champs_private - @dossier.ordered_champs_private + @dossier.champs_private end def individual diff --git a/app/models/dossier.rb b/app/models/dossier.rb index a894a1adb..f6205681a 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -18,8 +18,8 @@ class Dossier < ApplicationRecord has_one :attestation has_many :pieces_justificatives, dependent: :destroy - has_many :champs, -> { public_only }, dependent: :destroy - has_many :champs_private, -> { private_only }, class_name: 'Champ', dependent: :destroy + has_many :champs, -> { public_only.ordered }, dependent: :destroy + has_many :champs_private, -> { private_only.ordered }, class_name: 'Champ', dependent: :destroy has_many :quartier_prioritaires, dependent: :destroy has_many :cadastres, dependent: :destroy has_many :commentaires, dependent: :destroy @@ -59,7 +59,7 @@ class Dossier < ApplicationRecord scope :en_cours, -> { not_archived.state_en_construction_ou_instruction } scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) } scope :followed_by, -> (gestionnaire) { joins(:follows).where(follows: { gestionnaire: gestionnaire }) } - scope :with_ordered_champs, -> { includes(champs: :type_de_champ).order('types_de_champ.order_place') } + scope :with_champs, -> { includes(champs: :type_de_champ) } accepts_nested_attributes_for :individual @@ -120,14 +120,6 @@ class Dossier < ApplicationRecord end end - def ordered_champs - champs.ordered - end - - def ordered_champs_private - champs_private.ordered - end - def ordered_pieces_justificatives champs.joins(', types_de_piece_justificative').where("pieces_justificatives.type_de_piece_justificative_id = types_de_piece_justificative.id AND types_de_piece_justificative.procedure_id = #{procedure.id}").order('order_place ASC') end @@ -340,8 +332,8 @@ class Dossier < ApplicationRecord def sorted_values serialized_dossier = DossierTableExportSerializer.new(self) values = serialized_dossier.attributes.values - values += ordered_champs.map(&:for_export) - values += ordered_champs_private.map(&:for_export) + values += champs.map(&:for_export) + values += champs_private.map(&:for_export) values += export_etablissement_data.values values end diff --git a/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml b/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml index 58b2d42e8..93a976244 100644 --- a/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml +++ b/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml @@ -3,10 +3,10 @@ = render partial: "header", locals: { dossier: @dossier } #dossier-annotations-privees.container - - if @dossier.ordered_champs_private.present? + - if @dossier.champs_private.present? %section = form_for @dossier, url: annotations_gestionnaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| - = f.fields_for :champs_private, f.object.ordered_champs_private do |champ_form| + = f.fields_for :champs_private, f.object.champs_private do |champ_form| - champ = champ_form.object = render partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: champ, form: champ_form, seen_at: @annotations_privees_seen_at } diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml index ac7af1845..ebb055da4 100644 --- a/app/views/new_gestionnaire/dossiers/print.html.haml +++ b/app/views/new_gestionnaire/dossiers/print.html.haml @@ -13,7 +13,7 @@ %h2 Formulaire -- champs = @dossier.ordered_champs.decorate +- champs = @dossier.champs.decorate - if champs.any? = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil } @@ -49,7 +49,7 @@ %h2 Annotations privées -- if @dossier.ordered_champs_private.present? +- if @dossier.champs_private.present? %table - @dossier.champs_private.each do |champ| %tr diff --git a/app/views/shared/dossiers/_show.html.haml b/app/views/shared/dossiers/_show.html.haml index 4405f57b3..e5595e499 100644 --- a/app/views/shared/dossiers/_show.html.haml +++ b/app/views/shared/dossiers/_show.html.haml @@ -10,7 +10,7 @@ = render partial: "shared/dossiers/identite_individual", locals: { individual: dossier.individual } .tab-title Formulaire - - champs = dossier.ordered_champs.includes(:type_de_champ).decorate + - champs = dossier.champs.includes(:type_de_champ).decorate - if champs.any? .card = render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at } diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index c3d1b283c..baf3162e9 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -12,7 +12,7 @@ describe Dossier do it { expect(Dossier.without_followers.to_a).to eq([dossier2]) } end - describe 'with_ordered_champs' do + describe 'with_champs' do let(:procedure) { create(:procedure) } let(:dossier) { Dossier.create(user: create(:user), procedure: procedure) } @@ -23,7 +23,7 @@ describe Dossier do end it do - expect(Dossier.with_ordered_champs.find(dossier.id).champs.map(&:libelle)).to match(%w(l1 l2 l3)) + expect(Dossier.with_champs.find(dossier.id).champs.map(&:libelle)).to match(%w(l1 l2 l3)) end end @@ -343,7 +343,7 @@ describe Dossier do end end - describe '#ordered_champs' do + describe '#champs' do let(:procedure) { create(:procedure) } let(:dossier) { Dossier.create(user: create(:user), procedure: procedure) } @@ -353,10 +353,10 @@ describe Dossier do create(:type_de_champ, libelle: 'l2', order_place: 2, procedure: procedure) end - it { expect(dossier.ordered_champs.pluck(:libelle)).to match(%w(l1 l2 l3)) } + it { expect(dossier.champs.pluck(:libelle)).to match(%w(l1 l2 l3)) } end - describe '#ordered_champs_private' do + describe '#champs_private' do let(:procedure) { create :procedure } let(:dossier) { Dossier.create(user: create(:user), procedure: procedure) } @@ -366,7 +366,7 @@ describe Dossier do create :type_de_champ, :private, libelle: 'l2', order_place: 2, procedure: procedure end - it { expect(dossier.ordered_champs_private.pluck(:libelle)).to match(%w(l1 l2 l3)) } + it { expect(dossier.champs_private.pluck(:libelle)).to match(%w(l1 l2 l3)) } end describe '#total_follow' do From 9403d4c04254fda246ddc68aba11ed06c367292f Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 30 Aug 2018 12:25:21 +0200 Subject: [PATCH 13/25] [#2486] followers_gestionnaires should not be a method To help activerecord caching --- app/models/dossier.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index f6205681a..301c11d50 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -27,6 +27,7 @@ class Dossier < ApplicationRecord has_many :invites_user, class_name: 'InviteUser', dependent: :destroy has_many :invites_gestionnaires, class_name: 'InviteGestionnaire', dependent: :destroy has_many :follows + has_many :followers_gestionnaires, through: :follows, source: :gestionnaire has_many :avis, dependent: :destroy belongs_to :procedure @@ -151,10 +152,6 @@ class Dossier < ApplicationRecord end end - def followers_gestionnaires - follows.includes(:gestionnaire).map(&:gestionnaire) - end - def reset! etablissement.destroy From 7326065590f5ba5524c486fc69815f89438fdad6 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Thu, 30 Aug 2018 12:26:09 +0200 Subject: [PATCH 14/25] [fix #2486] Include all needed attributes on downloadable_sorted to avoid N+1 select --- app/models/dossier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 301c11d50..e96aa26a1 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -56,7 +56,7 @@ class Dossier < ApplicationRecord scope :en_construction, -> { not_archived.state_en_construction } scope :en_instruction, -> { not_archived.state_en_instruction } scope :termine, -> { not_archived.state_termine } - scope :downloadable_sorted, -> { state_not_brouillon.includes(:etablissement, :champs, :champs_private).order(en_construction_at: 'asc') } + scope :downloadable_sorted, -> { state_not_brouillon.includes(:etablissement, :champs, :champs_private, :user, :individual, :followers_gestionnaires).order(en_construction_at: 'asc') } scope :en_cours, -> { not_archived.state_en_construction_ou_instruction } scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) } scope :followed_by, -> (gestionnaire) { joins(:follows).where(follows: { gestionnaire: gestionnaire }) } From c015365057855d32ca797bbdaa86f14a6ab81322 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 30 Aug 2018 14:23:34 +0200 Subject: [PATCH 15/25] Fix case typos --- app/views/admin/gestionnaires/index.html.haml | 2 +- app/views/layouts/_switch_devise_profile_module.html.haml | 2 +- .../_left_panel_admin_procedurescontroller_navbar.html.haml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/admin/gestionnaires/index.html.haml b/app/views/admin/gestionnaires/index.html.haml index 081fa04ad..ff350b55e 100644 --- a/app/views/admin/gestionnaires/index.html.haml +++ b/app/views/admin/gestionnaires/index.html.haml @@ -1,4 +1,4 @@ -%h1 instructeurs disponibles +%h1 Instructeurs disponibles %p Cette page vous permet de gérer la liste des instructeurs disponibles pour être affectés à une procédure. diff --git a/app/views/layouts/_switch_devise_profile_module.html.haml b/app/views/layouts/_switch_devise_profile_module.html.haml index 7cc41cc06..2b13779b5 100644 --- a/app/views/layouts/_switch_devise_profile_module.html.haml +++ b/app/views/layouts/_switch_devise_profile_module.html.haml @@ -15,7 +15,7 @@ = link_to(gestionnaire_procedures_path) do %i.fa.fa-user   - instructeur + Instructeur - if administrateur_signed_in? %li diff --git a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml index 3c20ec785..70bdcf11e 100644 --- a/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml +++ b/app/views/layouts/left_panels/_left_panel_admin_procedurescontroller_navbar.html.haml @@ -19,8 +19,8 @@ Services %a#onglet-instructeurs{ href: url_for(admin_procedure_instructeurs_path(@procedure)) } - .procedure-list-element{ class: ('active' if active == 'instructeurs') } - = t('dynamics.admin.procedure.onglets.instructeurs') + .procedure-list-element{ class: ('active' if active == 'Instructeurs') } + Instructeurs %a#onglet-description{ href: url_for(edit_admin_procedure_path(@procedure)) } .procedure-list-element{ class: ('active' if active == 'Description') } From 6a33c308120aee098d9e26127a0c1f270c48e153 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 30 Aug 2018 14:42:09 +0200 Subject: [PATCH 16/25] =?UTF-8?q?Rename=20the=20last=20=E2=80=9CGestionnai?= =?UTF-8?q?re=E2=80=9D=20occurence=20in=20the=20UI=20to=20=E2=80=9CInstruc?= =?UTF-8?q?teur=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/manager/gestionnaires_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/manager/gestionnaires_controller.rb b/app/controllers/manager/gestionnaires_controller.rb index 408e788de..1caaf9156 100644 --- a/app/controllers/manager/gestionnaires_controller.rb +++ b/app/controllers/manager/gestionnaires_controller.rb @@ -3,7 +3,7 @@ module Manager def reinvite gestionnaire = Gestionnaire.find(params[:id]) gestionnaire.invite! - flash[:notice] = "Gestionnaire réinvité." + flash[:notice] = "Instructeur réinvité." redirect_to manager_gestionnaire_path(gestionnaire) end end From 7ac4dc355fb13c1cfc1029e888eec7d7d89fcd59 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 12:10:56 +0100 Subject: [PATCH 17/25] Add default dossier_id to contact form on dossier pages --- app/helpers/application_helper.rb | 6 +++++- app/views/layouts/_footer.html.haml | 5 ++++- app/views/new_user/dossiers/_footer.html.haml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 070455ded..aadc34ce2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -56,7 +56,11 @@ module ApplicationHelper def contact_link(title, options = {}) if Flipflop.support_form? - params = { tags: options[:tags], type: options[:type] }.compact + params = { + tags: options[:tags], + type: options[:type], + dossier_id: options[:dossier_id] + }.compact link_to title, contact_url(params), options else mail_to CONTACT_EMAIL, title, diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index 1d9a90032..7140724b5 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -9,4 +9,7 @@ \- = link_to 'CGU / Mentions légales', CGU_URL \- - = contact_link 'Contact' + - if @facade.present? && @facade.respond_to?(:dossier) + = contact_link 'Contact', dossier_id: @facade.dossier&.id + - else + = contact_link 'Contact' diff --git a/app/views/new_user/dossiers/_footer.html.haml b/app/views/new_user/dossiers/_footer.html.haml index 45d6fafda..a012e66ea 100644 --- a/app/views/new_user/dossiers/_footer.html.haml +++ b/app/views/new_user/dossiers/_footer.html.haml @@ -36,4 +36,4 @@ – = link_to "Mentions légales", MENTIONS_LEGALES_URL, :class => "footer-link", :target => "_blank", rel: "noopener noreferrer" – - = contact_link "Contact technique", class: "footer-link" + = contact_link "Contact technique", class: "footer-link", dossier_id: dossier.id From 441e123e8a909cc029bb36e8006941eea0d3405c Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 12:47:13 +0100 Subject: [PATCH 18/25] Do not lose form content on errors --- app/controllers/support_controller.rb | 2 -- app/views/support/index.html.haml | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb index fdb634758..9a04d1563 100644 --- a/app/controllers/support_controller.rb +++ b/app/controllers/support_controller.rb @@ -26,8 +26,6 @@ class SupportController < ApplicationController def setup_context @dossier_id = dossier&.id - @type = params[:type] - @tags = params[:tags] @options = Helpscout::FormAdapter::OPTIONS end diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml index 5b1a5a307..09b019893 100644 --- a/app/views/support/index.html.haml +++ b/app/views/support/index.html.haml @@ -14,13 +14,13 @@ = label_tag :email do Email %span.mandatory * - = text_field_tag :email, '', required: true + = text_field_tag :email, params[:email], required: true .contact-champ = label_tag :type do Votre problème %span.mandatory * - = select_tag :type, options_for_select(@options, @type) + = select_tag :type, options_for_select(@options, params[:type]) .contact-champ = label_tag :dossier_id, 'Numéro du dossier concerné' @@ -30,19 +30,19 @@ = label_tag :subject do Sujet %span.mandatory * - = text_field_tag :subject, '', required: true + = text_field_tag :subject, params[:subject], required: true .contact-champ = label_tag :text do Message %span.mandatory * - = text_area_tag :text, '', rows: 6, required: true + = text_area_tag :text, params[:text], rows: 6, required: true .contact-champ = label_tag :text, 'Pièce jointe' = file_field_tag :file - = hidden_field_tag :tags, @tags + = hidden_field_tag :tags, params[:tags] .send-wrapper = button_tag 'Envoyer le message', type: :submit, class: 'button send primary' From b60805a54c8275c4268fe1810d12f60e164695f6 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 12:47:45 +0100 Subject: [PATCH 19/25] Use mailto in error message --- app/assets/stylesheets/new_design/new_alert.scss | 5 +++++ app/controllers/support_controller.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/new_alert.scss b/app/assets/stylesheets/new_design/new_alert.scss index 909048b2e..0e5d04c60 100644 --- a/app/assets/stylesheets/new_design/new_alert.scss +++ b/app/assets/stylesheets/new_design/new_alert.scss @@ -8,6 +8,11 @@ .alert-danger { background-color: $medium-red; color: #FFFFFF; + + a { + color: #FFFFFF; + text-decoration: underline; + } } .alert-success { diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb index 9a04d1563..13424e02e 100644 --- a/app/controllers/support_controller.rb +++ b/app/controllers/support_controller.rb @@ -16,7 +16,7 @@ class SupportController < ApplicationController redirect_to root_path else setup_context - flash.now.alert = "Une erreur est survenue. Vous pouvez nous contactez à #{CONTACT_EMAIL}." + flash.now.alert = "Une erreur est survenue. Vous pouvez nous contactez à #{view_context.mail_to(CONTACT_EMAIL)}." render :index end From ea5248dde1ad2d2940fe79c60ade3d5a6c3fa6bb Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 12:48:03 +0100 Subject: [PATCH 20/25] Flatten tags list, cast to array and remove blank elements --- app/controllers/support_controller.rb | 4 ++++ app/views/support/index.html.haml | 2 +- spec/controllers/support_controller_spec.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb index 13424e02e..99089edd0 100644 --- a/app/controllers/support_controller.rb +++ b/app/controllers/support_controller.rb @@ -26,6 +26,7 @@ class SupportController < ApplicationController def setup_context @dossier_id = dossier&.id + @tags = tags @options = Helpscout::FormAdapter::OPTIONS end @@ -51,6 +52,9 @@ class SupportController < ApplicationController def tags [params[:tags], params[:type]].flatten.compact + .map { |tag| tag.split(',') } + .flatten + .reject(&:blank?).uniq end def browser_name diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml index 09b019893..ac566f292 100644 --- a/app/views/support/index.html.haml +++ b/app/views/support/index.html.haml @@ -42,7 +42,7 @@ = label_tag :text, 'Pièce jointe' = file_field_tag :file - = hidden_field_tag :tags, params[:tags] + = hidden_field_tag :tags, @tags&.join(',') .send-wrapper = button_tag 'Envoyer le message', type: :submit, class: 'button send primary' diff --git a/spec/controllers/support_controller_spec.rb b/spec/controllers/support_controller_spec.rb index 93ea27bc8..e47d1f002 100644 --- a/spec/controllers/support_controller_spec.rb +++ b/spec/controllers/support_controller_spec.rb @@ -38,6 +38,17 @@ describe SupportController, type: :controller do expect(response.body).to include(tag) end end + + describe "with multiple tags" do + let(:tags) { ['yolo', 'toto'] } + + it 'should fill tags' do + get :index, params: { tags: tags } + + expect(response.status).to eq(200) + expect(response.body).to include(tags.join(',')) + end + end end context 'signed out' do From 854bc62caa733ed63cbe8582d3b4668bf6d41d76 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 13:25:10 +0100 Subject: [PATCH 21/25] Fix class name --- app/views/root/landing.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index c912c1bfa..6fa52eb8f 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -72,7 +72,7 @@ %div = contact_link "Contactez-nous", tags: 'landing', - class: "cta-panel-button white", + class: "cta-panel-button-white", target: "_blank", rel: "noopener noreferrer" From 0c582197dad3e2bd0d1c7a2cc4edb9ba34fca775 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 13:43:03 +0100 Subject: [PATCH 22/25] Do not send messages to brouillon dossier --- app/controllers/support_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb index 99089edd0..1309927f4 100644 --- a/app/controllers/support_controller.rb +++ b/app/controllers/support_controller.rb @@ -64,7 +64,7 @@ class SupportController < ApplicationController end def direct_message? - user_signed_in? && params[:type] == Helpscout::FormAdapter::TYPE_INSTRUCTION && dossier.present? + user_signed_in? && params[:type] == Helpscout::FormAdapter::TYPE_INSTRUCTION && dossier.present? && !dossier.brouillon? end def dossier From 8e88f2c27f4ed949b91ff98259307e2164662824 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 14:08:26 +0100 Subject: [PATCH 23/25] Cleanup support controller tests --- spec/controllers/support_controller_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/controllers/support_controller_spec.rb b/spec/controllers/support_controller_spec.rb index e47d1f002..e6335081b 100644 --- a/spec/controllers/support_controller_spec.rb +++ b/spec/controllers/support_controller_spec.rb @@ -9,6 +9,13 @@ describe SupportController, type: :controller do end let(:user) { create(:user) } + it 'should not have email field' do + get :index + + expect(response.status).to eq(200) + expect(response.body).not_to have_content("Email *") + end + describe "with dossier" do let(:user) { dossier.user } let(:dossier) { create(:dossier) } @@ -19,16 +26,9 @@ describe SupportController, type: :controller do expect(response.status).to eq(200) expect(response.body).to include("#{dossier.id}") end - - it 'should not have email field' do - get :index - - expect(response.status).to eq(200) - expect(response.body).not_to have_content("Email *") - end end - describe "with dossier" do + describe "with tag" do let(:tag) { 'yolo' } it 'should fill tags' do From 5d5a356adea3e82d6e7f5e5aff22a20314ce8c4a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 14:10:18 +0100 Subject: [PATCH 24/25] Cleanup contact_link helper --- app/helpers/application_helper.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index aadc34ce2..76d73157f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -55,12 +55,11 @@ module ApplicationHelper end def contact_link(title, options = {}) + tags, type, dossier_id = options.values_at(:tags, :type, :dossier_id) + options.except!(:tags, :type, :dossier_id) + if Flipflop.support_form? - params = { - tags: options[:tags], - type: options[:type], - dossier_id: options[:dossier_id] - }.compact + params = { tags: tags, type: type, dossier_id: dossier_id }.compact link_to title, contact_url(params), options else mail_to CONTACT_EMAIL, title, From 4866f9724a329809afc941912220ce7094927436 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 30 Aug 2018 15:12:40 +0100 Subject: [PATCH 25/25] Add support controller send_form tests --- spec/controllers/support_controller_spec.rb | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/spec/controllers/support_controller_spec.rb b/spec/controllers/support_controller_spec.rb index e6335081b..f35a3e51c 100644 --- a/spec/controllers/support_controller_spec.rb +++ b/spec/controllers/support_controller_spec.rb @@ -49,6 +49,60 @@ describe SupportController, type: :controller do expect(response.body).to include(tags.join(',')) end end + + describe "send form" do + it 'should create conversation' do + expect(subject).not_to receive(:create_commentaire) + allow(subject).to receive(:create_conversation).and_return(true) + + post :create, params: { + subject: 'bonjour', + text: 'un message' + } + + expect(flash[:notice]).to match('Votre message a été envoyé.') + expect(response).to redirect_to root_path + end + + context "with dossier" do + let(:user) { dossier.user } + let(:dossier) { create(:dossier) } + + it 'should create conversation' do + expect(subject).not_to receive(:create_commentaire) + allow(subject).to receive(:create_conversation).and_return(true) + + post :create, params: { + dossier_id: dossier.id, + type: Helpscout::FormAdapter::TYPE_INSTRUCTION, + subject: 'bonjour', + text: 'un message' + } + + expect(flash[:notice]).to match('Votre message a été envoyé.') + expect(response).to redirect_to root_path + end + + context "en_construction" do + let(:dossier) { create(:dossier, :en_construction) } + + it 'should create commentaire' do + allow(subject).to receive(:create_commentaire).and_return(true) + expect(subject).not_to receive(:create_conversation) + + post :create, params: { + dossier_id: dossier.id, + type: Helpscout::FormAdapter::TYPE_INSTRUCTION, + subject: 'bonjour', + text: 'un message' + } + + expect(flash[:notice]).to match('Votre message a été envoyé sur la messagerie de votre dossier.') + expect(response).to redirect_to users_dossier_recapitulatif_path(dossier) + end + end + end + end end context 'signed out' do