Skip to content

Commit

Permalink
style(import): code format
Browse files Browse the repository at this point in the history
  • Loading branch information
20cents committed Dec 3, 2024
1 parent 79472e6 commit af96252
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
9 changes: 6 additions & 3 deletions backend/geonature/core/gn_synthese/imports/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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`
Expand Down
7 changes: 2 additions & 5 deletions backend/geonature/core/imports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion backend/geonature/core/imports/routes/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_fields(scope, destination):
"name_field",
"fr_label",
"eng_label",
'mnemonique',
"mnemonique",
"mandatory",
"autogenerated",
"multi",
Expand Down
5 changes: 4 additions & 1 deletion backend/geonature/core/imports/routes/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
"
></pnx-nomenclature>
<textarea
*ngSwitchCase="'textarea'"
Expand All @@ -110,7 +112,11 @@
/>
</ng-container>
<div
*ngIf="_fm.mappingFormGroup.controls[field.name_field + '_default_value'].hasError('invalidJSON')"
*ngIf="
_fm.mappingFormGroup.controls[field.name_field + '_default_value'].hasError(
'invalidJSON'
)
"
class="invalid-feedback d-block"
>
JSON non valide
Expand Down

0 comments on commit af96252

Please sign in to comment.