From d533abedbcc74955c27c401dc4b313df82275f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phil=C3=A9mon?= <40801449+philemon95@users.noreply.github.com> Date: Thu, 11 Apr 2019 17:35:47 +0200 Subject: [PATCH 1/6] =?UTF-8?q?Ajout=20rappel=20enregistrement=20n=C3=A9ce?= =?UTF-8?q?ssaire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shared/dossiers/_edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml index 5dc2bba2c..54c4f41be 100644 --- a/app/views/shared/dossiers/_edit.html.haml +++ b/app/views/shared/dossiers/_edit.html.haml @@ -14,7 +14,7 @@ .mandatory-explanation Les champs avec un astérisque ( %span.mandatory> * - ) sont obligatoires. + ) sont obligatoires. Pour enregistrer les informations saisies, cliquez sur le bouton « enregistrer le brouillon » en bas à gauche du formulaire. - if notice_url(dossier.procedure).present? = link_to notice_url(dossier.procedure), target: '_blank', rel: 'noopener', class: 'button notice', title: "Pour vous aider à remplir votre dossier, vous pouvez consulter le guide de cette démarche." do From 562fe90d42340860ce8a67cf7e1cab535223f9ea Mon Sep 17 00:00:00 2001 From: Nicolas Bouilleaud Date: Wed, 10 Apr 2019 14:54:43 +0200 Subject: [PATCH 2/6] Fix signout arrow direction --- app/assets/images/icons/sign-out.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/images/icons/sign-out.svg b/app/assets/images/icons/sign-out.svg index 184162794..76706b80d 100644 --- a/app/assets/images/icons/sign-out.svg +++ b/app/assets/images/icons/sign-out.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 11f8e7a3f9d9b3c6c532de383558dd9f879bf39d Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 17 Apr 2019 16:33:24 +0200 Subject: [PATCH 3/6] Small refactor --- app/controllers/manager/procedures_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index d5bef5228..dd3aa1401 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -1,14 +1,12 @@ module Manager class ProceduresController < Manager::ApplicationController def whitelist - procedure = Procedure.find(params[:id]) procedure.whitelist! flash[:notice] = "Démarche whitelistée." redirect_to manager_procedure_path(procedure) end def draft - procedure = Procedure.find(params[:id]) if procedure.dossiers.empty? procedure.draft! flash[:notice] = "La démarche a bien été passée en brouillon." @@ -19,14 +17,12 @@ module Manager end def hide - procedure = Procedure.find(params[:id]) procedure.hide! flash[:notice] = "La démarche a bien été supprimée, en cas d'erreur contactez un développeur." redirect_to manager_procedures_path end def add_administrateur - procedure = Procedure.find(params[:id]) administrateur = Administrateur.find_by(email: params[:email]) if administrateur procedure.administrateurs << administrateur @@ -36,5 +32,11 @@ module Manager end redirect_to manager_procedure_path(procedure) end + + private + + def procedure + Procedure.find(params[:id]) + end end end From 1d051dc3ef744e7452d6247982aacacc0434f7f1 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 17 Apr 2019 16:36:57 +0200 Subject: [PATCH 4/6] Can change a piece_justificative_template on a type_de_champ --- .../manager/procedures_controller.rb | 17 +++++++++++++++++ .../_show.html.haml | 10 ++++++++++ config/routes.rb | 1 + 3 files changed, 28 insertions(+) diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index dd3aa1401..b3241429f 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -33,10 +33,27 @@ module Manager redirect_to manager_procedure_path(procedure) end + def change_piece_justificative_template + if type_de_champ.update(type_de_champ_params) + flash[:notice] = "Le modèle est mis à jour." + else + flash[:alert] = type_de_champ.errors.full_messages.join(', ') + end + redirect_to manager_procedure_path(procedure) + end + private def procedure Procedure.find(params[:id]) end + + def type_de_champ + TypeDeChamp.find(params[:type_de_champ][:id]) + end + + def type_de_champ_params + params.require(:type_de_champ).permit(:piece_justificative_template) + end end end diff --git a/app/views/fields/types_de_champ_collection_field/_show.html.haml b/app/views/fields/types_de_champ_collection_field/_show.html.haml index 86b298e54..f70d88c66 100644 --- a/app/views/fields/types_de_champ_collection_field/_show.html.haml +++ b/app/views/fields/types_de_champ_collection_field/_show.html.haml @@ -5,6 +5,7 @@ %td.cell-label Libelle %td.cell-label Type de champ %td.cell-label Rempli + %td.cell-label Modifier le modèle %tbody - field.data.order(:order_place).each do |f| %tr @@ -20,5 +21,14 @@ vide - else rempli + + %td.cell-data + - if f.type_champ == 'piece_justificative' + = form_for f, + url: change_piece_justificative_template_manager_procedure_path, + method: :post do |form| + = form.hidden_field :id + = form.file_field :piece_justificative_template + = form.submit 'modifier' - else Aucun diff --git a/config/routes.rb b/config/routes.rb index 20cd28d8a..33493af6c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,7 @@ Rails.application.routes.draw do post 'draft', on: :member post 'hide', on: :member post 'add_administrateur', on: :member + post 'change_piece_justificative_template', on: :member end resources :dossiers, only: [:index, :show] do From 1f955db2c71d176b44b6f535ff35e8218b27e612 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 9 Apr 2019 09:00:13 +0000 Subject: [PATCH 5/6] gestionnaire: ignore when the gestionnaire already follows the dossier Fix #3720 --- app/models/gestionnaire.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 9bfa8e211..28331cd7f 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -31,7 +31,18 @@ class Gestionnaire < ApplicationRecord return end - followed_dossiers << dossier + begin + followed_dossiers << dossier + rescue ActiveRecord::RecordNotUnique + # Altough we checked before the insertion that the gestionnaire wasn't + # already following this dossier, this was done at the Rails level: + # at the database level, the dossier was already followed, and a + # "invalid constraint" exception is raised. + # + # We can ignore this safely, as it means the goal is already reached: + # the gestionnaire follows the dossier. + return + end end def unfollow(dossier) From e65e21a72fe3034fe539464c6db2ed26c503cd51 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 17 Apr 2019 15:20:10 +0200 Subject: [PATCH 6/6] Email notification: use the right method for procedures --- app/models/gestionnaire.rb | 4 +++- spec/models/gestionnaire_spec.rb | 6 +++--- spec/services/notification_service_spec.rb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 28331cd7f..5a2d9b0ea 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -127,6 +127,8 @@ class Gestionnaire < ApplicationRecord procedure.dossiers.termine when :not_archived procedure.dossiers.not_archived + when :all + procedure.dossiers else procedure.dossiers.en_cours end @@ -226,7 +228,7 @@ class Gestionnaire < ApplicationRecord h = { nb_en_construction: procedure.dossiers.en_construction.count, - nb_notification: notifications_per_procedure(procedure).count + nb_notification: notifications_for_procedure(procedure, :all).count } if h[:nb_en_construction] > 0 || h[:nb_notification] > 0 diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index ee3cfbafa..04a56e02f 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -279,7 +279,7 @@ describe Gestionnaire, type: :model do end end - describe '#notification_for_procedure' do + describe '#notifications_for_procedure' do let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) } let(:gestionnaire) { dossier.follows.first.gestionnaire } let(:procedure) { dossier.procedure } @@ -438,8 +438,8 @@ describe Gestionnaire, type: :model do context 'when a notification exists' do before do - allow(gestionnaire).to receive(:notifications_per_procedure) - .with(procedure_to_assign) + allow(gestionnaire).to receive(:notifications_for_procedure) + .with(procedure_to_assign, :all) .and_return([1, 2, 3]) end diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 7c9a9e116..c690c2ba6 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -49,7 +49,7 @@ describe NotificationService do context 'when there is a notification on this procedure' do before do - allow_any_instance_of(Gestionnaire).to receive(:notifications_per_procedure) + allow_any_instance_of(Gestionnaire).to receive(:notifications_for_procedure) .and_return([12]) end