Merge pull request #4467 from betagouv/dev

2019-10-31-02
This commit is contained in:
Paul Chavard 2019-10-31 17:32:33 +01:00 committed by GitHub
commit 84aba2c2ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 109 additions and 37 deletions

View file

@ -1,5 +1,21 @@
module Manager module Manager
class ProceduresController < Manager::ApplicationController 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 def whitelist
procedure.whitelist! procedure.whitelist!
flash[:notice] = "Démarche whitelistée." flash[:notice] = "Démarche whitelistée."
@ -55,5 +71,9 @@ module Manager
def type_de_champ_params def type_de_champ_params
params.require(:type_de_champ).permit(:piece_justificative_template) params.require(:type_de_champ).permit(:piece_justificative_template)
end end
def unfiltered_list?
action_name == "index" && !params[:search]
end
end end
end end

View file

@ -475,11 +475,21 @@ class Dossier < ApplicationRecord
def spreadsheet_columns def spreadsheet_columns
columns = [ columns = [
['ID', id.to_s], ['ID', id.to_s],
['Email', user.email], ['Email', user.email]
['Civilité', individual&.gender], ]
['Nom', individual&.nom],
['Prénom', individual&.prenom], if procedure.for_individual?
['Date de naissance', individual&.birthdate], 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], ['Archivé', :archived],
['État du dossier', I18n.t(state, scope: [:activerecord, :attributes, :dossier, :state])], ['État du dossier', I18n.t(state, scope: [:activerecord, :attributes, :dossier, :state])],
['Dernière mise à jour le', :updated_at], ['Dernière mise à jour le', :updated_at],

View file

@ -2,36 +2,35 @@
%span.dropdown %span.dropdown
%button.button.dropdown-button %button.button.dropdown-button
Télécharger tous les dossiers 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_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' : '' } .dropdown-content.fade-in-down{ style: !export_v1_enabled ? 'width: 330px' : '' }
%ul.dropdown-items %ul.dropdown-items
- if export_v2_enabled %li
%li - if procedure.xlsx_export_stale?
- if procedure.xlsx_export_stale? - if procedure.xlsx_export_queued?
- if procedure.xlsx_export_queued? L'export au format .xlsx est en cours de préparation, vous recevrez un email lorsqu'il sera disponible.
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
- else - else
= link_to "Au format .xlsx", url_for(procedure.xlsx_export_file), target: "_blank", rel: "noopener" = link_to "Exporter au format .xlsx", download_export_instructeur_procedure_path(procedure, export_format: :xlsx), remote: true
%li - else
- if procedure.ods_export_stale? = link_to "Au format .xlsx", url_for(procedure.xlsx_export_file), target: "_blank", rel: "noopener"
- if procedure.ods_export_queued? %li
L'export au format .ods est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - if procedure.ods_export_stale?
- else - if procedure.ods_export_queued?
= link_to "Exporter au format .ods", download_export_instructeur_procedure_path(procedure, export_format: :ods), remote: true L'export au format .ods est en cours de préparation, vous recevrez un email lorsqu'il sera disponible.
- else - else
= link_to "Au format .ods", url_for(procedure.ods_export_file), target: "_blank", rel: "noopener" = link_to "Exporter au format .ods", download_export_instructeur_procedure_path(procedure, export_format: :ods), remote: true
%li - else
- if procedure.csv_export_stale? = link_to "Au format .ods", url_for(procedure.ods_export_file), target: "_blank", rel: "noopener"
- if procedure.csv_export_queued? %li
L'export au format .csv est en cours de préparation, vous recevrez un email lorsqu'il sera disponible. - if procedure.csv_export_stale?
- else - if procedure.csv_export_queued?
= link_to "Exporter au format .csv", download_export_instructeur_procedure_path(procedure, export_format: :csv), remote: true L'export au format .csv est en cours de préparation, vous recevrez un email lorsqu'il sera disponible.
- else - 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 - if export_v1_enabled
- old_format_message = "(ancien format, jusquau #{old_format_limit_date.strftime('%d/%m/%Y')})" - old_format_message = "(ancien format, jusquau #{old_format_limit_date.strftime('%d/%m/%Y')})"
%li %li

View file

@ -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' %> <%= link_to 'repasser en test', draft_manager_procedure_path(procedure), method: :post, class: 'button' %>
<% end %> <% 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 %>
<div> <div>
</header> </header>

View file

@ -103,12 +103,11 @@
- if feature_enabled?(:administrateur_web_hook) - if feature_enabled?(:administrateur_web_hook)
= f.label :web_hook_url do = f.label :web_hook_url do
Lien de rappel HTTP (webhook) 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 dun 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/' = 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 dun 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 = f.label :auto_archive_on do
Clôture automatique à 00h01 le : Clôture automatique à 00h01 le :

View file

@ -34,7 +34,6 @@ features = [
:mini_profiler, :mini_profiler,
:operation_log_serialize_subject, :operation_log_serialize_subject,
:pre_maintenance_mode, :pre_maintenance_mode,
:procedure_export_v2_enabled,
:xray :xray
] ]

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe ProcedureExportV2Service do describe ProcedureExportV2Service do
describe 'to_data' 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 subject do
Tempfile.create do |f| Tempfile.create do |f|
f << ProcedureExportV2Service.new(procedure, procedure.dossiers).to_xlsx f << ProcedureExportV2Service.new(procedure, procedure.dossiers).to_xlsx
@ -104,12 +104,55 @@ describe ProcedureExportV2Service do
end end
context 'with etablissement' do 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) { create(:dossier, :en_instruction, :with_all_champs, :with_entreprise, procedure: procedure) }
let(:dossier_etablissement) { etablissements_sheet.data[1] } let(:dossier_etablissement) { etablissements_sheet.data[1] }
let(:champ_etablissement) { etablissements_sheet.data[0] } 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 it 'should have headers' do
expect(dossiers_sheet.headers).to match(nominal_headers)
expect(etablissements_sheet.headers).to eq([ expect(etablissements_sheet.headers).to eq([
"Dossier ID", "Dossier ID",
"Champ", "Champ",