diff --git a/backend/geonature/core/auth/routes.py b/backend/geonature/core/auth/routes.py index 1a56712293..dbd0ad2df7 100644 --- a/backend/geonature/core/auth/routes.py +++ b/backend/geonature/core/auth/routes.py @@ -29,6 +29,8 @@ from geonature.utils.errors import CasAuthentificationError from geonature.utils.env import db +from pypnusershub.auth.auth_manager import auth_manager + routes = Blueprint("gn_auth", __name__, template_folder="templates") log = logging.getLogger() @@ -78,7 +80,8 @@ def insert_user_and_org(info_user): "email": info_user["email"], "active": True, } - user_info = insert_or_update_role(user_info) + user_ = User(**user_info) + user_info = insert_or_update_role(user_, auth_manager.get_provider("local_provider"), "email") user = db.session.get(User, user_id) if not user.groups: if not current_app.config["CAS"]["USERS_CAN_SEE_ORGANISM_DATA"] or organism_id is None: diff --git a/backend/geonature/core/gn_meta/mtd/__init__.py b/backend/geonature/core/gn_meta/mtd/__init__.py index 488d3e2544..902349c34d 100644 --- a/backend/geonature/core/gn_meta/mtd/__init__.py +++ b/backend/geonature/core/gn_meta/mtd/__init__.py @@ -112,8 +112,8 @@ def add_unexisting_digitizer(id_digitizer): :param id_digitizer: as id role from meta info """ if ( - not db.session.scalars( - select(func.count("*").select_from(User).filter_by(id_role=id_digitizer).limit(1)) + not db.session.execute( + select(func.count("*")).select_from(User).filter_by(id_role=id_digitizer).limit(1) ).scalar_one() > 0 ): @@ -145,12 +145,14 @@ def process_af_and_ds(af_list, ds_list, id_role=None): for af in af_list: actors = af.pop("actors") with db.session.begin_nested(): - start_add_user_time = time.time() + import time as t + + start_add_user_time = t.time() if not id_role: add_unexisting_digitizer(af["id_digitizer"]) else: add_unexisting_digitizer(id_role) - user_add_total_time += time.time() - start_add_user_time + user_add_total_time += t.time() - start_add_user_time af = sync_af(af) associate_actors( actors, @@ -165,12 +167,14 @@ def process_af_and_ds(af_list, ds_list, id_role=None): actors = ds.pop("actors") # CREATE DIGITIZER with db.session.begin_nested(): - start_add_user_time = time.time() + import time as t + + start_add_user_time = t.time() if not id_role: add_unexisting_digitizer(ds["id_digitizer"]) else: add_unexisting_digitizer(id_role) - user_add_total_time += time.time() - start_add_user_time + user_add_total_time += t.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) diff --git a/backend/geonature/core/gn_meta/mtd/mtd_utils.py b/backend/geonature/core/gn_meta/mtd/mtd_utils.py index ddcf18125f..97fd25d6f2 100644 --- a/backend/geonature/core/gn_meta/mtd/mtd_utils.py +++ b/backend/geonature/core/gn_meta/mtd/mtd_utils.py @@ -140,7 +140,7 @@ def add_or_update_organism(uuid, nom, email): """ # Test if actor already exists to avoid nextVal increase org_exist = DB.session.execute( - select(exists().select_from(BibOrganismes).filter_by(uuid_organisme=uuid)) + select(exists().select_from(BibOrganismes).where(BibOrganismes.uuid_organisme == uuid)) ).scalar_one() if org_exist: