From 076e3a929412043733589cdb5ac8a5cdabcae839 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 31 Oct 2019 16:04:47 +0100 Subject: [PATCH 1/4] procedure: improve layout of the "webhook" field --- .../procedures/_informations.html.haml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/new_administrateur/procedures/_informations.html.haml b/app/views/new_administrateur/procedures/_informations.html.haml index c473c2726..3f0342b42 100644 --- a/app/views/new_administrateur/procedures/_informations.html.haml +++ b/app/views/new_administrateur/procedures/_informations.html.haml @@ -103,12 +103,11 @@ - if feature_enabled?(:administrateur_web_hook) = f.label :web_hook_url do Lien de rappel HTTP (webhook) + .notice + %p + Vous pouvez définir un lien de rappel HTTP (aussi appelé webhook) pour notifier un service tiers du changement de l'état d’un dossier de cette démarche sur demarches-simplifiees.fr. + = link_to("Consulter la documentation du webhook", WEBHOOK_DOC_URL, target: "_blank", rel: "noopener") = f.text_field :web_hook_url, class: 'form-control', placeholder: 'https://callback.exemple.fr/' - %p.help-block - %i.fa.fa-info-circle - Vous pouvez définir un lien de rappel HTTP (aussi appelé webhook) pour notifier un service tiers du changement de l'état d’un dossier de cette démarche sur demarches-simplifiees.fr. - = link_to("Consulter la documentation du webhook", WEBHOOK_DOC_URL, target: "_blank", rel: "noopener") - \. = f.label :auto_archive_on do Clôture automatique à 00h01 le : From 627d30191fa56f09994a1849a3a240b3984773c3 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 31 Oct 2019 16:30:39 +0100 Subject: [PATCH 2/4] manager: allow hidden procedures to be searched The Manager::DossiersController already allow hidden dossiers to be searched and displayed. Give the same behavior to Procedures. --- .../manager/procedures_controller.rb | 20 +++++++++++++++++++ app/views/manager/procedures/show.html.erb | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index b3241429f..846e103de 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -1,5 +1,21 @@ module Manager class ProceduresController < Manager::ApplicationController + # + # Administrate overrides + # + + # Override this if you have certain roles that require a subset + # this will be used to set the records shown on the `index` action. + def scoped_resource + if unfiltered_list? + # Don't display deleted dossiers in the unfiltered list… + Procedure + else + # … but allow them to be searched and displayed. + Procedure.unscope(:where) + end + end + def whitelist procedure.whitelist! flash[:notice] = "Démarche whitelistée." @@ -55,5 +71,9 @@ module Manager def type_de_champ_params params.require(:type_de_champ).permit(:piece_justificative_template) end + + def unfiltered_list? + action_name == "index" && !params[:search] + end end end diff --git a/app/views/manager/procedures/show.html.erb b/app/views/manager/procedures/show.html.erb index be61830b1..95216c8d4 100644 --- a/app/views/manager/procedures/show.html.erb +++ b/app/views/manager/procedures/show.html.erb @@ -43,7 +43,9 @@ as well as a link to its edit page. <%= link_to 'repasser en test', draft_manager_procedure_path(procedure), method: :post, class: 'button' %> <% end %> - <%= link_to 'supprimer la démarche', hide_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la suppression de la démarche ?" } %> + <% if !procedure.hidden? %> + <%= link_to 'supprimer la démarche', hide_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la suppression de la démarche ?" } %> + <% end %>
From 18e91e7ca3b872ae2f2aa0742326e374602f300a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 31 Oct 2019 11:21:22 +0100 Subject: [PATCH 3/4] Extend old export format till mid-November --- .../procedures/_download_dossiers.html.haml | 47 +++++++++---------- config/initializers/flipper.rb | 1 - 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/app/views/instructeurs/procedures/_download_dossiers.html.haml b/app/views/instructeurs/procedures/_download_dossiers.html.haml index 228c07e64..ef10c8a3b 100644 --- a/app/views/instructeurs/procedures/_download_dossiers.html.haml +++ b/app/views/instructeurs/procedures/_download_dossiers.html.haml @@ -2,36 +2,35 @@ %span.dropdown %button.button.dropdown-button Télécharger tous les dossiers - - old_format_limit_date = Date.parse("Oct 31 2019") + - old_format_limit_date = Date.parse("Nov 15 2019") - export_v1_enabled = old_format_limit_date > Time.zone.today - - export_v2_enabled = Flipper[:procedure_export_v2_enabled] || !export_v1_enabled .dropdown-content.fade-in-down{ style: !export_v1_enabled ? 'width: 330px' : '' } %ul.dropdown-items - - if export_v2_enabled - %li - - if procedure.xlsx_export_stale? - - if procedure.xlsx_export_queued? - L'export au format .xlsx est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - - else - = link_to "Exporter au format .xlsx", download_export_instructeur_procedure_path(procedure, export_format: :xlsx), remote: true + %li + - if procedure.xlsx_export_stale? + - if procedure.xlsx_export_queued? + L'export au format .xlsx est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - else - = link_to "Au format .xlsx", url_for(procedure.xlsx_export_file), target: "_blank", rel: "noopener" - %li - - if procedure.ods_export_stale? - - if procedure.ods_export_queued? - L'export au format .ods est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - - else - = link_to "Exporter au format .ods", download_export_instructeur_procedure_path(procedure, export_format: :ods), remote: true + = link_to "Exporter au format .xlsx", download_export_instructeur_procedure_path(procedure, export_format: :xlsx), remote: true + - else + = link_to "Au format .xlsx", url_for(procedure.xlsx_export_file), target: "_blank", rel: "noopener" + %li + - if procedure.ods_export_stale? + - if procedure.ods_export_queued? + L'export au format .ods est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - else - = link_to "Au format .ods", url_for(procedure.ods_export_file), target: "_blank", rel: "noopener" - %li - - if procedure.csv_export_stale? - - if procedure.csv_export_queued? - L'export au format .csv est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - - else - = link_to "Exporter au format .csv", download_export_instructeur_procedure_path(procedure, export_format: :csv), remote: true + = link_to "Exporter au format .ods", download_export_instructeur_procedure_path(procedure, export_format: :ods), remote: true + - else + = link_to "Au format .ods", url_for(procedure.ods_export_file), target: "_blank", rel: "noopener" + %li + - if procedure.csv_export_stale? + - if procedure.csv_export_queued? + L'export au format .csv est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - else - = link_to "Au format .csv", url_for(procedure.csv_export_file), target: "_blank", rel: "noopener" + = link_to "Exporter au format .csv", download_export_instructeur_procedure_path(procedure, export_format: :csv), remote: true + - else + = link_to "Au format .csv", url_for(procedure.csv_export_file), target: "_blank", rel: "noopener" + - if export_v1_enabled - old_format_message = "(ancien format, jusqu’au #{old_format_limit_date.strftime('%d/%m/%Y')})" %li diff --git a/config/initializers/flipper.rb b/config/initializers/flipper.rb index 0718c0e6a..e8172d0da 100644 --- a/config/initializers/flipper.rb +++ b/config/initializers/flipper.rb @@ -34,7 +34,6 @@ features = [ :mini_profiler, :operation_log_serialize_subject, :pre_maintenance_mode, - :procedure_export_v2_enabled, :xray ] From 839b0d7e6d3f294072fc82f4870856565efea736 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 31 Oct 2019 14:14:14 +0100 Subject: [PATCH 4/4] Add Entreprise raison sociale to dossier export fix #4422 --- app/models/dossier.rb | 20 ++++++--- .../procedure_export_v2_service_spec.rb | 45 ++++++++++++++++++- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 07d5e73fc..1b5c2a4f9 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -475,11 +475,21 @@ class Dossier < ApplicationRecord def spreadsheet_columns columns = [ ['ID', id.to_s], - ['Email', user.email], - ['Civilité', individual&.gender], - ['Nom', individual&.nom], - ['Prénom', individual&.prenom], - ['Date de naissance', individual&.birthdate], + ['Email', user.email] + ] + + if procedure.for_individual? + columns += [ + ['Civilité', individual&.gender], + ['Nom', individual&.nom], + ['Prénom', individual&.prenom], + ['Date de naissance', individual&.birthdate] + ] + else + columns << ['Entreprise raison sociale', etablissement&.entreprise_raison_sociale] + end + + columns += [ ['Archivé', :archived], ['État du dossier', I18n.t(state, scope: [:activerecord, :attributes, :dossier, :state])], ['Dernière mise à jour le', :updated_at], diff --git a/spec/services/procedure_export_v2_service_spec.rb b/spec/services/procedure_export_v2_service_spec.rb index 12a3cf945..5635c0380 100644 --- a/spec/services/procedure_export_v2_service_spec.rb +++ b/spec/services/procedure_export_v2_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe ProcedureExportV2Service do describe 'to_data' do - let(:procedure) { create(:procedure, :published, :with_all_champs) } + let(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs) } subject do Tempfile.create do |f| f << ProcedureExportV2Service.new(procedure, procedure.dossiers).to_xlsx @@ -104,12 +104,55 @@ describe ProcedureExportV2Service do end context 'with etablissement' do + let(:procedure) { create(:procedure, :published, :with_all_champs) } let!(:dossier) { create(:dossier, :en_instruction, :with_all_champs, :with_entreprise, procedure: procedure) } let(:dossier_etablissement) { etablissements_sheet.data[1] } let(:champ_etablissement) { etablissements_sheet.data[0] } + let(:nominal_headers) do + [ + "ID", + "Email", + "Entreprise raison sociale", + "Archivé", + "État du dossier", + "Dernière mise à jour le", + "Déposé le", + "Passé en instruction le", + "Traité le", + "Motivation de la décision", + "Instructeurs", + "textarea", + "date", + "datetime", + "number", + "decimal_number", + "integer_number", + "checkbox", + "civilite", + "email", + "phone", + "address", + "yes_no", + "simple_drop_down_list", + "multiple_drop_down_list", + "linked_drop_down_list", + "pays", + "regions", + "departements", + "engagement", + "dossier_link", + "piece_justificative", + "siret", + "carte", + "text" + ] + end + it 'should have headers' do + expect(dossiers_sheet.headers).to match(nominal_headers) + expect(etablissements_sheet.headers).to eq([ "Dossier ID", "Champ",