Skip to content

Commit

Permalink
fixup! fix(mtd): add exception handling for associate_actors
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentCauchois committed Oct 31, 2024
1 parent 2820e30 commit e34ce99
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backend/geonature/core/gn_meta/mtd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def process_af_and_ds(af_list, ds_list, id_role=None):
CorAcquisitionFrameworkActor,
"id_acquisition_framework",
af.id_acquisition_framework,
af.unique_acquisition_framework_id,
)
# TODO: remove actors removed from MTD
db.session.commit()
Expand All @@ -231,7 +232,13 @@ def process_af_and_ds(af_list, ds_list, id_role=None):
user_add_total_time += time.time() - start_add_user_time
ds = sync_ds(ds, list_cd_nomenclature)
if ds is not None:
associate_actors(actors, CorDatasetActor, "id_dataset", ds.id_dataset)
associate_actors(
actors,
CorDatasetActor,
"id_dataset",
ds.id_dataset,
ds.unique_dataset_id,
)

user_add_total_time = round(user_add_total_time, 2)
db.session.commit()
Expand Down
3 changes: 3 additions & 0 deletions backend/geonature/core/gn_meta/mtd/mtd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def associate_actors(
CorActor: Union[CorAcquisitionFrameworkActor, CorDatasetActor],
pk_name: Literal["id_acquisition_framework", "id_dataset"],
pk_value: str,
uuid_mtd: str,
):
"""
Associate actors with either a given :
Expand All @@ -237,6 +238,8 @@ def associate_actors(
- 'id_dataset' for DS
pk_value : str
pk value: ID of the AF or DS
uuid_mtd : str
UUID of the AF or DS
"""
type_mtd = "AF" if pk_name == "id_acquisition_framework" else "DS"
for actor in actors:
Expand Down

0 comments on commit e34ce99

Please sign in to comment.