From bd9fe7eb7c0c3fbe973c6e9b6746c59876b3a98b Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 20 Dec 2022 22:11:34 +0100 Subject: [PATCH] feat(export): add pays, region and departement codes --- app/models/champs/departement_champ.rb | 4 ++++ app/models/champs/pays_champ.rb | 4 ++++ app/models/champs/region_champ.rb | 4 ++++ app/models/types_de_champ/departement_type_de_champ.rb | 3 +++ app/models/types_de_champ/pays_type_de_champ.rb | 3 +++ app/models/types_de_champ/region_type_de_champ.rb | 3 +++ spec/services/procedure_export_service_spec.rb | 9 +++++++++ 7 files changed, 30 insertions(+) diff --git a/app/models/champs/departement_champ.rb b/app/models/champs/departement_champ.rb index 962d2e182..f197a58c4 100644 --- a/app/models/champs/departement_champ.rb +++ b/app/models/champs/departement_champ.rb @@ -21,6 +21,10 @@ # type_de_champ_id :integer # class Champs::DepartementChamp < Champs::TextChamp + def for_export + [name, code] + end + def to_s formatted_value end diff --git a/app/models/champs/pays_champ.rb b/app/models/champs/pays_champ.rb index 80d580cb7..8246a18ee 100644 --- a/app/models/champs/pays_champ.rb +++ b/app/models/champs/pays_champ.rb @@ -21,6 +21,10 @@ # type_de_champ_id :integer # class Champs::PaysChamp < Champs::TextChamp + def for_export + [formatted_value, code] + end + def to_s formatted_value end diff --git a/app/models/champs/region_champ.rb b/app/models/champs/region_champ.rb index ec9450af8..3426b337c 100644 --- a/app/models/champs/region_champ.rb +++ b/app/models/champs/region_champ.rb @@ -21,6 +21,10 @@ # type_de_champ_id :integer # class Champs::RegionChamp < Champs::TextChamp + def for_export + [name, code] + end + def selected code end diff --git a/app/models/types_de_champ/departement_type_de_champ.rb b/app/models/types_de_champ/departement_type_de_champ.rb index 58a8cb3d0..e4b36b91f 100644 --- a/app/models/types_de_champ/departement_type_de_champ.rb +++ b/app/models/types_de_champ/departement_type_de_champ.rb @@ -1,2 +1,5 @@ class TypesDeChamp::DepartementTypeDeChamp < TypesDeChamp::TextTypeDeChamp + def libelle_for_export(index) + [libelle, "#{libelle} (Code)"][index] + end end diff --git a/app/models/types_de_champ/pays_type_de_champ.rb b/app/models/types_de_champ/pays_type_de_champ.rb index c35e06d78..4067f22d0 100644 --- a/app/models/types_de_champ/pays_type_de_champ.rb +++ b/app/models/types_de_champ/pays_type_de_champ.rb @@ -1,2 +1,5 @@ class TypesDeChamp::PaysTypeDeChamp < TypesDeChamp::TextTypeDeChamp + def libelle_for_export(index) + [libelle, "#{libelle} (Code)"][index] + end end diff --git a/app/models/types_de_champ/region_type_de_champ.rb b/app/models/types_de_champ/region_type_de_champ.rb index b694303fb..3d22f492d 100644 --- a/app/models/types_de_champ/region_type_de_champ.rb +++ b/app/models/types_de_champ/region_type_de_champ.rb @@ -1,2 +1,5 @@ class TypesDeChamp::RegionTypeDeChamp < TypesDeChamp::TextTypeDeChamp + def libelle_for_export(index) + [libelle, "#{libelle} (Code)"][index] + end end diff --git a/spec/services/procedure_export_service_spec.rb b/spec/services/procedure_export_service_spec.rb index 1d62e4d73..3f3d93f08 100644 --- a/spec/services/procedure_export_service_spec.rb +++ b/spec/services/procedure_export_service_spec.rb @@ -68,8 +68,11 @@ describe ProcedureExportService do "communes (Code insee)", "communes (Département)", "departements", + "departements (Code)", "regions", + "regions (Code)", "pays", + "pays (Code)", "dossier_link", "piece_justificative", "rna", @@ -172,8 +175,11 @@ describe ProcedureExportService do "communes (Code insee)", "communes (Département)", "departements", + "departements (Code)", "regions", + "regions (Code)", "pays", + "pays (Code)", "dossier_link", "piece_justificative", "rna", @@ -259,8 +265,11 @@ describe ProcedureExportService do "communes (Code insee)", "communes (Département)", "departements", + "departements (Code)", "regions", + "regions (Code)", "pays", + "pays (Code)", "dossier_link", "piece_justificative", "rna",