Skip to content

Commit

Permalink
add comments on core check_datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Jan 2, 2025
2 parents 4a5fea3 + ac1164f commit b351a4f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions backend/geonature/core/imports/checks/dataframe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,21 @@ def check_datasets(
}

# Warning: we check only permissions of first author, but currently there it only one author per import.

authorized_datasets = {
str(ds.unique_dataset_id): ds
for ds in db.session.execute(
# sa.select(TDatasets)
TDatasets.filter_by_creatable(
user=imprt.authors[0], module_code=module_code, object_code=object_code
)
# .where(TDatasets.unique_dataset_id.in_(uuid))
.where(TDatasets.unique_dataset_id.in_(uuid))
.options(sa.orm.raiseload("*"))
)
.scalars()
).scalars()
# .unique()
.all()
}
authorized_ds_mask = df[uuid_col].isin(authorized_datasets.keys())
unauthorized_ds_mask = valid_ds_mask & ~authorized_ds_mask
authorized_ds_mask = valid_ds_mask & df[uuid_col].isin(authorized_datasets.keys())
unauthorized_ds_mask = ~authorized_ds_mask
if unauthorized_ds_mask.any():
yield {
"error_code": ImportCodeError.DATASET_NOT_AUTHORIZED,
Expand Down

0 comments on commit b351a4f

Please sign in to comment.