From 2b1e0f14f66c944ccfeced5d7a0b8478b2bfbe4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Jun 2021 23:43:20 +0000 Subject: [PATCH 1/7] Bump bindata from 2.4.8 to 2.4.10 Bumps [bindata](https://github.com/dmendel/bindata) from 2.4.8 to 2.4.10. - [Release notes](https://github.com/dmendel/bindata/releases) - [Changelog](https://github.com/dmendel/bindata/blob/master/ChangeLog.rdoc) - [Commits](https://github.com/dmendel/bindata/compare/v2.4.8...v2.4.10) --- updated-dependencies: - dependency-name: bindata dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index fed4a457a..4261f934c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -123,7 +123,7 @@ GEM babel-source (>= 4.0, < 6) execjs (~> 2.0) bcrypt (3.1.16) - bindata (2.4.8) + bindata (2.4.10) bindex (0.8.1) bootsnap (1.7.2) msgpack (~> 1.0) From 8b2c2c6466763ca61b75a6e396295a85a8207c5f Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 23 Jun 2021 15:54:12 +0200 Subject: [PATCH 2/7] Handle carte layers changes --- app/models/champs/carte_champ.rb | 21 +-------- app/models/procedure_revision.rb | 11 +++++ app/models/type_de_champ.rb | 25 ++++++---- .../types_de_champ/carte_type_de_champ.rb | 12 +++++ .../procedures/_revision_changes.html.haml | 12 ++++- .../groupe_instructeurs/fr.yml | 11 +++++ spec/models/procedure_revision_spec.rb | 47 +++++++++++++++++++ 7 files changed, 109 insertions(+), 30 deletions(-) diff --git a/app/models/champs/carte_champ.rb b/app/models/champs/carte_champ.rb index c857d6cb0..ccec62cc0 100644 --- a/app/models/champs/carte_champ.rb +++ b/app/models/champs/carte_champ.rb @@ -36,29 +36,12 @@ class Champs::CarteChamp < Champ end end - def layer_enabled?(layer) - type_de_champ.options && type_de_champ.options[layer] && type_de_champ.options[layer] != '0' - end - def cadastres? - layer_enabled?(:cadastres) + type_de_champ.layer_enabled?(:cadastres) end def optional_layers - [ - :unesco, - :arretes_protection, - :conservatoire_littoral, - :reserves_chasse_faune_sauvage, - :reserves_biologiques, - :reserves_naturelles, - :natura_2000, - :zones_humides, - :znieff, - :cadastres - ].filter_map do |layer| - layer_enabled?(layer) ? layer : nil - end + type_de_champ.carte_optional_layers end def render_options diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index 939450b5e..4ef55e2b7 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -207,6 +207,17 @@ class ProcedureRevision < ApplicationRecord to: to_type_de_champ.drop_down_list_options } end + elsif to_type_de_champ.carte? + if from_type_de_champ.carte_optional_layers != to_type_de_champ.carte_optional_layers + changes << { + op: :update, + attribute: :carte_layers, + label: from_type_de_champ.libelle, + private: from_type_de_champ.private?, + from: from_type_de_champ.carte_optional_layers, + to: to_type_de_champ.carte_optional_layers + } + end elsif to_type_de_champ.piece_justificative? if from_type_de_champ.piece_justificative_template_checksum != to_type_de_champ.piece_justificative_template_checksum changes << { diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 35f168586..8874766fc 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -206,6 +206,10 @@ class TypeDeChamp < ApplicationRecord type_champ == TypeDeChamp.type_champs.fetch(:titre_identite) end + def carte? + type_champ == TypeDeChamp.type_champs.fetch(:carte) + end + def public? !private? end @@ -260,6 +264,16 @@ class TypeDeChamp < ApplicationRecord (drop_down_list_options - drop_down_list_disabled_options).reject(&:empty?) end + def layer_enabled?(layer) + options && options[layer] && options[layer] != '0' + end + + def carte_optional_layers + TypesDeChamp::CarteTypeDeChamp::LAYERS.filter_map do |layer| + layer_enabled?(layer) ? layer : nil + end.sort + end + def to_typed_id GraphQL::Schema::UniqueWithinType.encode('Champ', stable_id) end @@ -269,16 +283,7 @@ class TypeDeChamp < ApplicationRecord end def editable_options - options.slice(:cadastres, - :unesco, - :arretes_protection, - :conservatoire_littoral, - :reserves_chasse_faune_sauvage, - :reserves_biologiques, - :reserves_naturelles, - :natura_2000, - :zones_humides, - :znieff) + options.slice(*TypesDeChamp::CarteTypeDeChamp::LAYERS) end FEATURE_FLAGS = {} diff --git a/app/models/types_de_champ/carte_type_de_champ.rb b/app/models/types_de_champ/carte_type_de_champ.rb index 193db82d2..ee4c2f461 100644 --- a/app/models/types_de_champ/carte_type_de_champ.rb +++ b/app/models/types_de_champ/carte_type_de_champ.rb @@ -1,2 +1,14 @@ class TypesDeChamp::CarteTypeDeChamp < TypesDeChamp::TypeDeChampBase + LAYERS = [ + :unesco, + :arretes_protection, + :conservatoire_littoral, + :reserves_chasse_faune_sauvage, + :reserves_biologiques, + :reserves_naturelles, + :natura_2000, + :zones_humides, + :znieff, + :cadastres + ] end diff --git a/app/views/new_administrateur/procedures/_revision_changes.html.haml b/app/views/new_administrateur/procedures/_revision_changes.html.haml index aa430ede6..130558643 100644 --- a/app/views/new_administrateur/procedures/_revision_changes.html.haml +++ b/app/views/new_administrateur/procedures/_revision_changes.html.haml @@ -24,12 +24,22 @@ - added = change[:to].sort - change[:from].sort - removed = change[:from].sort - change[:to].sort %li.mb-1 - = "Les options de sélection du champ « #{change[:label]} » ont changé." + = "Les options de sélection du champ « #{change[:label]} » ont changé :" %ul - if added.present? %li= "Valeurs ajoutés : #{added.map{ |term| "« #{term.strip} »" }.join(", ")}." - if removed.present? %li= "Valeurs supprimés : #{removed.map{ |term| "« #{term.strip} »" }.join(", ")}." + - when :carte_layers + - added = change[:to].sort - change[:from].sort + - removed = change[:from].sort - change[:to].sort + %li.mb-1 + = "Les référentiels cartographiques du champ « #{change[:label]} » ont changé :" + %ul + - if added.present? + %li= "Référentiels ajoutés : #{added.map{ |term| "« #{t(term, scope: [:new_administrateur, :carte_layers])} »" }.join(", ")}." + - if removed.present? + %li= "Référentiels supprimés : #{removed.map{ |term| "« #{t(term, scope: [:new_administrateur, :carte_layers])} »" }.join(", ")}." - move_changes = changes.filter { |change| change[:op] == :move }.size - if move_changes != 0 %li.mb-1= t(:has_move_changes, count: move_changes, scope: [:new_administrateur, :revision_changes]) diff --git a/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml b/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml index 6f1b05090..35a2bf047 100644 --- a/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml +++ b/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml @@ -37,3 +37,14 @@ fr: has_move_changes: one: Un champ a changé de position other: "%{count} champs ont changé de position" + carte_layers: + unesco: UNESCO + arretes_protection: Arrêtés de protection + conservatoire_littoral: Conservatoire du Littoral + reserves_chasse_faune_sauvage: Réserves nationales de chasse et de faune sauvage + reserves_biologiques: Réserves biologiques + reserves_naturelles: Réserves naturelles + natura_2000: Natura 2000 + zones_humides: Zones humides d’importance internationale + znieff: ZNIEFF + cadastres: Cadastre diff --git a/spec/models/procedure_revision_spec.rb b/spec/models/procedure_revision_spec.rb index 0d14d7837..c7280fb95 100644 --- a/spec/models/procedure_revision_spec.rb +++ b/spec/models/procedure_revision_spec.rb @@ -312,6 +312,53 @@ describe ProcedureRevision do to: ["one", "two"] } ]) + + new_revision.find_or_clone_type_de_champ(new_revision.types_de_champ.last.types_de_champ.first.stable_id).update(type_champ: :carte) + new_revision.find_or_clone_type_de_champ(new_revision.types_de_champ.last.types_de_champ.first.stable_id).update(options: { cadastres: true, znieff: true }) + expect(procedure.active_revision.compare(new_revision.reload)).to eq([ + { + op: :remove, + label: type_de_champ_first.libelle, + private: false + }, + { + op: :add, + label: "Un champ text", + private: false + }, + { + op: :update, + attribute: :description, + label: type_de_champ_second.libelle, + private: false, + from: type_de_champ_second.description, + to: "une description" + }, + { + op: :update, + attribute: :mandatory, + label: type_de_champ_second.libelle, + private: false, + from: false, + to: true + }, + { + op: :update, + attribute: :type_champ, + label: "sub type de champ", + private: false, + from: "text", + to: "carte" + }, + { + op: :update, + attribute: :carte_layers, + label: "sub type de champ", + private: false, + from: [], + to: [:cadastres, :znieff] + } + ]) end end end From 0ca5e1abe277d2f8360a86f0b7060e3fd1a52b38 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 23 Jun 2021 15:57:11 +0200 Subject: [PATCH 3/7] Preview should reflect revision changes --- .../new_administrateur/procedures_controller.rb | 2 +- app/controllers/users/commencer_controller.rb | 2 +- app/models/procedure.rb | 11 ----------- app/models/procedure_revision.rb | 9 +++++++++ spec/models/procedure_spec.rb | 2 +- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/controllers/new_administrateur/procedures_controller.rb b/app/controllers/new_administrateur/procedures_controller.rb index c0c697143..d5a99c579 100644 --- a/app/controllers/new_administrateur/procedures_controller.rb +++ b/app/controllers/new_administrateur/procedures_controller.rb @@ -44,7 +44,7 @@ module NewAdministrateur end def apercu - @dossier = procedure_without_control.new_dossier + @dossier = procedure_without_control.draft_revision.new_dossier @tab = apercu_tab end diff --git a/app/controllers/users/commencer_controller.rb b/app/controllers/users/commencer_controller.rb index fe00ec99a..cd22a0664 100644 --- a/app/controllers/users/commencer_controller.rb +++ b/app/controllers/users/commencer_controller.rb @@ -81,7 +81,7 @@ module Users end def generate_empty_pdf(procedure) - @dossier = procedure.new_dossier + @dossier = procedure.active_revision.new_dossier s = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf]) send_data(s, :filename => "#{procedure.libelle}.pdf") end diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 25674e078..cc3227046 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -406,17 +406,6 @@ class Procedure < ApplicationRecord Flipper.enabled?(feature, self) end - # Warning: dossier after_save build_default_champs must be removed - # to save a dossier created from this method - def new_dossier - Dossier.new( - revision: active_revision, - champs: active_revision.build_champs, - champs_private: active_revision.build_champs_private, - groupe_instructeur: defaut_groupe_instructeur - ) - end - def path_customized? !path.match?(/[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}/) end diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index 4ef55e2b7..13c60c8d4 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -112,6 +112,15 @@ class ProcedureRevision < ApplicationRecord changes end + def new_dossier + Dossier.new( + revision: self, + champs: build_champs, + champs_private: build_champs_private, + groupe_instructeur: procedure.defaut_groupe_instructeur + ) + end + private def compare_types_de_champ(from_tdc, to_tdc) diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 9850686d4..b6b8f7cf6 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -927,7 +927,7 @@ describe Procedure do ]) end - let(:dossier) { procedure.new_dossier } + let(:dossier) { procedure.active_revision.new_dossier } it { expect(dossier.procedure).to eq(procedure) } From 241eff76a31d673f301e244d56fbf164811f95f1 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 23 Jun 2021 17:06:39 +0200 Subject: [PATCH 4/7] Enable publish new revision only if some changes are found --- app/models/procedure.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index cc3227046..85d51c211 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -361,7 +361,7 @@ class Procedure < ApplicationRecord end def draft_changed? - publiee? && published_revision.changed?(draft_revision) + publiee? && published_revision.changed?(draft_revision) && revision_changes.present? end def revision_changes From 15ff04642896a72021c9fb9f139c7a7fcc2bd52e Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 23 Jun 2021 18:56:04 +0200 Subject: [PATCH 5/7] Improuve revision changes messages --- app/assets/stylesheets/procedure_show.scss | 12 +++++ app/models/procedure.rb | 8 ---- .../procedures/_publication_form.html.haml | 2 +- .../procedures/_revision_changes.html.haml | 39 ++++++++-------- .../procedures/show.html.haml | 21 +++------ .../groupe_instructeurs/fr.yml | 21 --------- .../revision_changes/fr.yml | 45 +++++++++++++++++++ 7 files changed, 84 insertions(+), 64 deletions(-) create mode 100644 config/locales/views/new_administrateur/revision_changes/fr.yml diff --git a/app/assets/stylesheets/procedure_show.scss b/app/assets/stylesheets/procedure_show.scss index 62d31ba71..0349a06be 100644 --- a/app/assets/stylesheets/procedure_show.scss +++ b/app/assets/stylesheets/procedure_show.scss @@ -109,3 +109,15 @@ } } } + +ul.revision-changes { + list-style: none; + + ul { + list-style: none; + + li { + padding-top: 0.25 * $default-padding; + } + } +} diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 85d51c211..589f2d741 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -368,14 +368,6 @@ class Procedure < ApplicationRecord published_revision.compare(draft_revision) end - def revision_types_de_champ_private_changes - revision_changes.filter { |change| change[:private] } - end - - def revision_types_de_champ_changes - revision_changes.filter { |change| !change[:private] } - end - def accepts_new_dossiers? publiee? || brouillon? end diff --git a/app/views/new_administrateur/procedures/_publication_form.html.haml b/app/views/new_administrateur/procedures/_publication_form.html.haml index 881996d81..d7f0c8f45 100644 --- a/app/views/new_administrateur/procedures/_publication_form.html.haml +++ b/app/views/new_administrateur/procedures/_publication_form.html.haml @@ -2,7 +2,7 @@ %h2.card-title Publiez votre démarche = form_tag admin_procedure_publish_path(procedure_id: procedure.id), method: :put, class: 'form' do - if procedure.draft_changed? - %p.mb-4 Publiez une nouvelle version de votre démarche. Les changements suivants seront appliqués : + %p.mb-4 Publiez une nouvelle version de votre démarche. Les modifications suivantes seront appliquées : = render partial: 'revision_changes', locals: { changes: procedure.revision_changes } - else %p.mb-4 Publiez votre démarche, et partagez la à vos usagers. Aucune modification ne sera possible. diff --git a/app/views/new_administrateur/procedures/_revision_changes.html.haml b/app/views/new_administrateur/procedures/_revision_changes.html.haml index 130558643..010b9800d 100644 --- a/app/views/new_administrateur/procedures/_revision_changes.html.haml +++ b/app/views/new_administrateur/procedures/_revision_changes.html.haml @@ -1,45 +1,48 @@ -%ul +%ul.revision-changes - changes.each do |change| + - postfix = change[:private] ? '_private' : '' - case change[:op] - when :add - %li.mb-1= "Le champ « #{change[:label]} » a été ajouté." + %li.mb-1= t("add#{postfix}", label: change[:label], scope: [:new_administrateur, :revision_changes]) - when :remove - %li.mb-1= "Le champ « #{change[:label]} » a été supprimé." + %li.mb-1= t("remove#{postfix}", label: change[:label], scope: [:new_administrateur, :revision_changes]) - when :update - case change[:attribute] - when :libelle - %li.mb-1= "Le libellé du champ « #{change[:label]} » a changé en « #{change[:to]} »." + %li.mb-1= t("update_libelle#{postfix}", label: change[:label], to: change[:to], scope: [:new_administrateur, :revision_changes]) - when :type_champ - %li.mb-1= "Le type du champ « #{change[:label]} » a changé. Il est maintenant de type « #{t("activerecord.attributes.type_de_champ.type_champs.#{change[:to]}")} »." + %li.mb-1= t("update_type_champ#{postfix}", label: change[:label], to: t("activerecord.attributes.type_de_champ.type_champs.#{change[:to]}"), scope: [:new_administrateur, :revision_changes]) - when :description - %li.mb-1= "La description du champ « #{change[:label]} » a changé. La nouvelle description est « #{change[:to]} »." + %li.mb-1= t("update_description#{postfix}", label: change[:label], to: change[:to], scope: [:new_administrateur, :revision_changes]) - when :mandatory - if change[:from] == false - %li.mb-1= "Le champ « #{change[:label]} » est maintenant obligatoire." + %li.mb-1= t(:enabled, label: change[:label], scope: [:new_administrateur, :revision_changes, "update_mandatory#{postfix}"]) - else - %li.mb-1= "Le champ « #{change[:label]} » n'est plus obligatoire." + %li.mb-1= t(:disabled, label: change[:label], scope: [:new_administrateur, :revision_changes, "update_mandatory#{postfix}"]) - when :piece_justificative_template - %li.mb-1= "Le champ « #{change[:label]} » a changé de modèle de pièce justificative." + %li.mb-1= t("update_piece_justificative_template#{postfix}", label: change[:label], scope: [:new_administrateur, :revision_changes]) - when :drop_down_options - added = change[:to].sort - change[:from].sort - removed = change[:from].sort - change[:to].sort %li.mb-1 - = "Les options de sélection du champ « #{change[:label]} » ont changé :" + = t("update_drop_down_options#{postfix}", label: change[:label], scope: [:new_administrateur, :revision_changes]) %ul - if added.present? - %li= "Valeurs ajoutés : #{added.map{ |term| "« #{term.strip} »" }.join(", ")}." + %li= t(:add_option, items: added.map{ |term| "« #{term.strip} »" }.join(", "), scope: [:new_administrateur, :revision_changes]) - if removed.present? - %li= "Valeurs supprimés : #{removed.map{ |term| "« #{term.strip} »" }.join(", ")}." + %li= t(:remove_option, items: removed.map{ |term| "« #{term.strip} »" }.join(", "), scope: [:new_administrateur, :revision_changes]) - when :carte_layers - added = change[:to].sort - change[:from].sort - removed = change[:from].sort - change[:to].sort %li.mb-1 - = "Les référentiels cartographiques du champ « #{change[:label]} » ont changé :" + = t("update_carte_layers#{postfix}", label: change[:label], scope: [:new_administrateur, :revision_changes]) %ul - if added.present? - %li= "Référentiels ajoutés : #{added.map{ |term| "« #{t(term, scope: [:new_administrateur, :carte_layers])} »" }.join(", ")}." + %li= t(:add_option, items: added.map{ |term| "« #{t(term, scope: [:new_administrateur, :carte_layers])} »" }.join(", "), scope: [:new_administrateur, :revision_changes]) - if removed.present? - %li= "Référentiels supprimés : #{removed.map{ |term| "« #{t(term, scope: [:new_administrateur, :carte_layers])} »" }.join(", ")}." - - move_changes = changes.filter { |change| change[:op] == :move }.size - - if move_changes != 0 - %li.mb-1= t(:has_move_changes, count: move_changes, scope: [:new_administrateur, :revision_changes]) + %li= t(:remove_option, items: removed.map{ |term| "« #{t(term, scope: [:new_administrateur, :carte_layers])} »" }.join(", "), scope: [:new_administrateur, :revision_changes]) + - move_changes, move_private_changes = changes.filter { |change| change[:op] == :move }.partition { |change| !change[:private] } + - if move_changes.size != 0 + %li.mb-1= t(:move, count: move_changes.size, scope: [:new_administrateur, :revision_changes]) + - if move_private_changes.size != 0 + %li.mb-1= t(:move_private, count: move_private_changes.size, scope: [:new_administrateur, :revision_changes]) diff --git a/app/views/new_administrateur/procedures/show.html.haml b/app/views/new_administrateur/procedures/show.html.haml index 4a86a7953..9182af12f 100644 --- a/app/views/new_administrateur/procedures/show.html.haml +++ b/app/views/new_administrateur/procedures/show.html.haml @@ -33,22 +33,11 @@ = link_to 'Publier les modifications', admin_procedure_publication_path(@procedure), class: 'button primary', id: 'publish-procedure-link', data: { disable_with: "Publication..." } - if @procedure.draft_changed? - - types_de_champ_changes = @procedure.revision_types_de_champ_changes - - types_de_champ_private_changes = @procedure.revision_types_de_champ_private_changes - - - if types_de_champ_changes.present? - .container - .card.featured - .card-title - = t(:has_changes, count: types_de_champ_changes.size, scope: [:new_administrateur, :revision_changes]) - = render partial: 'revision_changes', locals: { changes: types_de_champ_changes } - - - if types_de_champ_private_changes.present? - .container - .card.featured - .card-title - = t(:has_private_changes, count: types_de_champ_private_changes.size, scope: [:new_administrateur, :revision_changes]) - = render partial: 'revision_changes', locals: { changes: types_de_champ_private_changes } + .container + .card.featured + .card-title + = t(:has_changes, scope: [:new_administrateur, :revision_changes]) + = render partial: 'revision_changes', locals: { changes: @procedure.revision_changes } .container %h2.procedure-admin-explanation Indispensable avant publication diff --git a/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml b/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml index 35a2bf047..2243a9caf 100644 --- a/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml +++ b/config/locales/views/new_administrateur/groupe_instructeurs/fr.yml @@ -27,24 +27,3 @@ fr: existing_groupe: one: "%{count} groupe existe" other: "%{count} groupes existent" - revision_changes: - has_changes: - one: Un champ a été changé - other: "%{count} champs ont été changés" - has_private_changes: - one: Une annotation privée a été changée - other: "%{count} deux annotations privées ont été changées" - has_move_changes: - one: Un champ a changé de position - other: "%{count} champs ont changé de position" - carte_layers: - unesco: UNESCO - arretes_protection: Arrêtés de protection - conservatoire_littoral: Conservatoire du Littoral - reserves_chasse_faune_sauvage: Réserves nationales de chasse et de faune sauvage - reserves_biologiques: Réserves biologiques - reserves_naturelles: Réserves naturelles - natura_2000: Natura 2000 - zones_humides: Zones humides d’importance internationale - znieff: ZNIEFF - cadastres: Cadastre diff --git a/config/locales/views/new_administrateur/revision_changes/fr.yml b/config/locales/views/new_administrateur/revision_changes/fr.yml new file mode 100644 index 000000000..009740ad1 --- /dev/null +++ b/config/locales/views/new_administrateur/revision_changes/fr.yml @@ -0,0 +1,45 @@ +fr: + new_administrateur: + revision_changes: + has_changes: Modifications en cours (appliqué à la prochaine publication) + add: Le champ « %{label} » a été ajouté + remove: Le champ « %{label} » a été supprimé + move: + one: La position d’un champ a été modifiée + other: Les positions de %{count} champs ont été modifiées + update_libelle: Le libellé du champ « %{label} » a été modifié. Le nouveau libellé est « %{to} » + update_description: La description du champ « %{label} » a été modifiée. La nouvelle description est « %{to} » + update_type_champ: Le type du champ « %{label} » a été modifié. Il est maintenant de type « %{to} » + update_mandatory: + enable: Le champ « %{label} » est maintenant obligatoire + disable: Le champ « %{label} » n’est plus obligatoire + update_piece_justificative_template: Le modèle de pièce justificative du champ « %{label} » a été modifié + update_drop_down_options: Les options de sélection du champ « %{label} » ont été modifiées + update_carte_layers: Les référentiels cartographiques du champ « %{label} » ont été modifiés + add_private: L’annotation privée « %{label} » a été ajoutée + remove_private: L’annotation privée « %{label} » a été supprimée + move_private: + one: La position d’une annotation privée a été modifiée + other: Les positions de %{count} annotations privées ont été modifiées + update_libelle_private: Le libellé de l’annotation privée « %{label} » a été modifié. Le nouveau libellé est « %{to} » + update_description_private: La description de l’annotation privée « %{label} » a été modifiée. La nouvelle description est « %{to} » + update_type_champ_private: Le type de l’annotation privée « %{label} » a été modifié. Elle est maintenant de type « %{to} » + update_mandatory_private: + enable: L’annotation privée « %{label} » est maintenant obligatoire + disable: L’annotation privée « %{label} » n’est plus obligatoire + update_piece_justificative_template_private: Le modèle de pièce justificative de l’annotation privée « %{label} » a été modifié + update_drop_down_options_private: Les options de sélection de l’annotation privée « %{label} » ont été modifiées + update_carte_layers_private: Les référentiels cartographiques de l’annotation privée « %{label} » ont été modifiés + add_option: "ajoutés : %{items}" + remove_option: "supprimés : %{items}" + carte_layers: + unesco: UNESCO + arretes_protection: Arrêtés de protection + conservatoire_littoral: Conservatoire du Littoral + reserves_chasse_faune_sauvage: Réserves nationales de chasse et de faune sauvage + reserves_biologiques: Réserves biologiques + reserves_naturelles: Réserves naturelles + natura_2000: Natura 2000 + zones_humides: Zones humides d’importance internationale + znieff: ZNIEFF + cadastres: Cadastre From a4482233b8efd8ca04b276a7cc9ae2e4f04c86f2 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 26 May 2021 13:50:02 +0200 Subject: [PATCH 6/7] [GraphQL] expose deleted dossiers --- app/graphql/schema.graphql | 96 +++++++++++++++++++ app/graphql/types/deleted_dossier_type.rb | 16 ++++ app/graphql/types/demarche_type.rb | 15 +++ app/models/deleted_dossier.rb | 1 + .../api/v2/graphql_controller_spec.rb | 38 ++++++++ 5 files changed, 166 insertions(+) create mode 100644 app/graphql/types/deleted_dossier_type.rb diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 827e3ac83..6e140c7c7 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -340,6 +340,67 @@ type DecimalNumberChamp implements Champ { value: Float } +""" +Un dossier supprimé +""" +type DeletedDossier { + """ + Date de suppression. + """ + dateSupression: ISO8601DateTime! + id: ID! + + """ + Le numéro du dossier qui a été supprimé. + """ + number: Int! + + """ + La raison de la suppression du dossier. + """ + reason: String! + + """ + L’état du dossier supprimé. + """ + state: DossierState! +} + +""" +The connection type for DeletedDossier. +""" +type DeletedDossierConnection { + """ + A list of edges. + """ + edges: [DeletedDossierEdge] + + """ + A list of nodes. + """ + nodes: [DeletedDossier] + + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! +} + +""" +An edge in a connection. +""" +type DeletedDossierEdge { + """ + A cursor for use in pagination. + """ + cursor: String! + + """ + The item at the end of the edge. + """ + node: DeletedDossier +} + interface Demandeur { id: ID! } @@ -381,6 +442,41 @@ type Demarche { """ declarative: DossierDeclarativeState + """ + Liste de tous les dossiers supprimés d’une démarche. + """ + deletedDossiers( + """ + Returns the elements in the list that come after the specified cursor. + """ + after: String + + """ + Returns the elements in the list that come before the specified cursor. + """ + before: String + + """ + Dossiers supprimés depuis la date. + """ + deletedSince: ISO8601DateTime + + """ + Returns the first _n_ elements from the list. + """ + first: Int + + """ + Returns the last _n_ elements from the list. + """ + last: Int + + """ + L’ordre des dossiers supprimés. + """ + order: Order = ASC + ): DeletedDossierConnection! + """ Description de la démarche. """ diff --git a/app/graphql/types/deleted_dossier_type.rb b/app/graphql/types/deleted_dossier_type.rb new file mode 100644 index 000000000..5d4ccd8b8 --- /dev/null +++ b/app/graphql/types/deleted_dossier_type.rb @@ -0,0 +1,16 @@ +module Types + class DeletedDossierType < Types::BaseObject + description "Un dossier supprimé" + + global_id_field :id + field :number, Int, "Le numéro du dossier qui a été supprimé.", null: false, method: :dossier_id + field :state, Types::DossierType::DossierState, "L’état du dossier supprimé.", null: false + field :reason, String, "La raison de la suppression du dossier.", null: false + + field :date_supression, GraphQL::Types::ISO8601DateTime, "Date de suppression.", null: false, method: :deleted_at + + def self.authorized?(object, context) + context.authorized_demarche?(object.procedure) + end + end +end diff --git a/app/graphql/types/demarche_type.rb b/app/graphql/types/demarche_type.rb index 42aae2d43..3202fed20 100644 --- a/app/graphql/types/demarche_type.rb +++ b/app/graphql/types/demarche_type.rb @@ -43,6 +43,11 @@ module Types argument :min_revision, ID, required: false, description: "Seulement les dossiers pour les révisons après la révision donnée." end + field :deleted_dossiers, Types::DeletedDossierType.connection_type, "Liste de tous les dossiers supprimés d’une démarche.", null: false do + argument :order, Types::Order, default_value: :asc, required: false, description: "L’ordre des dossiers supprimés." + argument :deleted_since, GraphQL::Types::ISO8601DateTime, required: false, description: "Dossiers supprimés depuis la date." + end + field :champ_descriptors, [Types::ChampDescriptorType], null: false, method: :types_de_champ field :annotation_descriptors, [Types::ChampDescriptorType], null: false, method: :types_de_champ_private @@ -102,6 +107,16 @@ module Types dossiers end + def deleted_dossiers(deleted_since: nil, order:) + dossiers = object.deleted_dossiers + + if deleted_since.present? + dossiers = dossiers.deleted_since(deleted_since) + end + + dossiers.order(deleted_at: order) + end + def self.authorized?(object, context) context.authorized_demarche?(object) end diff --git a/app/models/deleted_dossier.rb b/app/models/deleted_dossier.rb index 1d465fef9..96a78acec 100644 --- a/app/models/deleted_dossier.rb +++ b/app/models/deleted_dossier.rb @@ -20,6 +20,7 @@ class DeletedDossier < ApplicationRecord validates :dossier_id, uniqueness: true scope :order_by_updated_at, -> (order = :desc) { order(created_at: order) } + scope :deleted_since, -> (since) { where('deleted_dossiers.deleted_at >= ?', since) } enum reason: { user_request: 'user_request', diff --git a/spec/controllers/api/v2/graphql_controller_spec.rb b/spec/controllers/api/v2/graphql_controller_spec.rb index 8e2a3ae0b..ee0bf80b4 100644 --- a/spec/controllers/api/v2/graphql_controller_spec.rb +++ b/spec/controllers/api/v2/graphql_controller_spec.rb @@ -649,6 +649,44 @@ describe API::V2::GraphqlController do end end + context "deletedDossiers" do + let(:query) do + "{ + demarche(number: #{procedure.id}) { + deletedDossiers { + nodes { + id + number + state + reason + dateSupression + } + } + } + }" + end + let(:deleted_dossier) { create(:deleted_dossier, procedure: procedure) } + + before { deleted_dossier } + + it "should be returned" do + expect(gql_errors).to eq(nil) + expect(gql_data).to eq(demarche: { + deletedDossiers: { + nodes: [ + { + id: deleted_dossier.to_typed_id, + number: deleted_dossier.dossier_id, + state: deleted_dossier.state, + reason: deleted_dossier.reason, + dateSupression: deleted_dossier.deleted_at.iso8601 + } + ] + } + }) + end + end + context "champ" do let(:champ) { create(:champ_piece_justificative, dossier: dossier) } let(:byte_size) { 2712286911 } From b047c38b47e1165298f3e2fa0423163fd265e6d1 Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Thu, 24 Jun 2021 11:24:15 +0200 Subject: [PATCH 7/7] gems: upgrade delayed_job_web fix error when attempting to "retry" or "reload" a failed job via the web interface. bump delayed_job_web from 1.4.3 to 1.4.4 See [Changelog](https://github.com/ejschmitt/delayed_job_web/blob/v1.4.4/CHANGELOG.md) from 1.4.3 to 1.4.4 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 8f1078b2d..3c7f41916 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'daemons' gem 'deep_cloneable' # Enable deep clone of active record models gem 'delayed_cron_job' # Cron jobs gem 'delayed_job_active_record' -gem 'delayed_job_web' +gem 'delayed_job_web', '>= 1.4.4' gem 'devise' # Gestion des comptes utilisateurs gem 'devise-async' gem 'devise-i18n' diff --git a/Gemfile.lock b/Gemfile.lock index 4261f934c..98315f70f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -195,7 +195,7 @@ GEM delayed_job_active_record (4.1.5) activerecord (>= 3.0, < 6.2) delayed_job (>= 3.0, < 5) - delayed_job_web (1.4.3) + delayed_job_web (1.4.4) activerecord (> 3.0.0) delayed_job (> 2.0.3) rack-protection (>= 1.5.5) @@ -801,7 +801,7 @@ DEPENDENCIES deep_cloneable delayed_cron_job delayed_job_active_record - delayed_job_web + delayed_job_web (>= 1.4.4) devise devise-async devise-i18n