From af962521f029047483c21988bba98a1eea547f38 Mon Sep 17 00:00:00 2001 From: Vincent Bourgeois Date: Tue, 3 Dec 2024 12:52:29 +0100 Subject: [PATCH] style(import): code format --- backend/geonature/core/gn_synthese/imports/actions.py | 9 ++++++--- backend/geonature/core/imports/models.py | 7 ++----- backend/geonature/core/imports/routes/fields.py | 2 +- backend/geonature/core/imports/routes/imports.py | 5 ++++- .../e43b01a18850_fieldmapping_default_values.py | 5 +++-- .../mapping-theme/mapping-theme.component.html | 10 ++++++++-- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/backend/geonature/core/gn_synthese/imports/actions.py b/backend/geonature/core/gn_synthese/imports/actions.py index deb6131447..7ee33918fd 100644 --- a/backend/geonature/core/gn_synthese/imports/actions.py +++ b/backend/geonature/core/gn_synthese/imports/actions.py @@ -88,7 +88,7 @@ def check_transient_data(task, logger, imprt: TImports): selected_fields = { field_name: fields[field_name] for field_name, source_field in imprt.fieldmapping.items() - if source_field.get('column_src', None) in imprt.columns + if source_field.get("column_src", None) in imprt.columns } init_rows_validity(imprt) task.update_state(state="PROGRESS", meta={"progress": 0.05}) @@ -339,12 +339,15 @@ def import_data_to_destination(imprt: TImports) -> None: if field_name not in fields: # not a destination field continue field = fields[field_name] - column_src = source_field.get('column_src', None) + column_src = source_field.get("column_src", None) if field.multi: if not set(column_src).isdisjoint(imprt.columns): insert_fields |= {field} else: - if column_src in imprt.columns or source_field.get('default_value', None) is not None: + if ( + column_src in imprt.columns + or source_field.get("default_value", None) is not None + ): insert_fields |= {field} insert_fields -= {fields["unique_dataset_id"]} # Column only used for filling `id_dataset` diff --git a/backend/geonature/core/imports/models.py b/backend/geonature/core/imports/models.py index 1a57428962..b070493a46 100644 --- a/backend/geonature/core/imports/models.py +++ b/backend/geonature/core/imports/models.py @@ -665,14 +665,11 @@ def validate_values(values): {"type": "string"}, {"type": "array"}, ] - } + }, }, "required": [], "additionalProperties": False, - "anyOf": [ - { "required": ["column_src"] }, - { "required": ["default_value"] } - ] + "anyOf": [{"required": ["column_src"]}, {"required": ["default_value"]}], } for field in fields }, diff --git a/backend/geonature/core/imports/routes/fields.py b/backend/geonature/core/imports/routes/fields.py index ec7c592b14..79fa66e89e 100644 --- a/backend/geonature/core/imports/routes/fields.py +++ b/backend/geonature/core/imports/routes/fields.py @@ -72,7 +72,7 @@ def get_fields(scope, destination): "name_field", "fr_label", "eng_label", - 'mnemonique', + "mnemonique", "mandatory", "autogenerated", "multi", diff --git a/backend/geonature/core/imports/routes/imports.py b/backend/geonature/core/imports/routes/imports.py index aa81c9a4f0..92b1dbb819 100644 --- a/backend/geonature/core/imports/routes/imports.py +++ b/backend/geonature/core/imports/routes/imports.py @@ -368,7 +368,10 @@ def get_import_values(scope, imprt): # this nomenclated field is not mapped continue source = imprt.fieldmapping[field.name_field] - if source.get("column_src", None) not in imprt.columns and source.get("default_value", None) is None: + if ( + source.get("column_src", None) not in imprt.columns + and source.get("default_value", None) is None + ): # the file do not contain this field expected by the mapping and there is no default value continue # TODO: vérifier que l’on a pas trop de valeurs différentes ? diff --git a/backend/geonature/migrations/versions/imports/e43b01a18850_fieldmapping_default_values.py b/backend/geonature/migrations/versions/imports/e43b01a18850_fieldmapping_default_values.py index 98084485bd..066ccd52de 100644 --- a/backend/geonature/migrations/versions/imports/e43b01a18850_fieldmapping_default_values.py +++ b/backend/geonature/migrations/versions/imports/e43b01a18850_fieldmapping_default_values.py @@ -5,13 +5,14 @@ Create Date: 2024-11-28 17:33:06.243150 """ + from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'e43b01a18850' -down_revision = '2b0b3bd0248c' +revision = "e43b01a18850" +down_revision = "2b0b3bd0248c" branch_labels = None depends_on = None diff --git a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html index c222066290..c8249dcb15 100644 --- a/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html +++ b/frontend/src/app/modules/imports/components/import_process/fields-mapping-step/mapping-theme/mapping-theme.component.html @@ -94,7 +94,9 @@ *ngSwitchCase="'nomenclature'" [bindAllItem]="true" [codeNomenclatureType]="field.mnemonique" - [parentFormControl]="_fm.mappingFormGroup.get(field.name_field + '_default_value')" + [parentFormControl]=" + _fm.mappingFormGroup.get(field.name_field + '_default_value') + " >