From 1cde23306046e2bfce035dfbfa04649fd898f5ba Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 22 Aug 2021 16:41:19 +0200 Subject: [PATCH] fix import utilisateurs --- tools/import_scodoc7_user_db.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/import_scodoc7_user_db.py b/tools/import_scodoc7_user_db.py index c92f3b528..dc8bcd7dd 100644 --- a/tools/import_scodoc7_user_db.py +++ b/tools/import_scodoc7_user_db.py @@ -24,6 +24,10 @@ def import_scodoc7_user_db(scodoc7_db="dbname=SCOUSERS"): cursor.execute("SELECT * FROM sco_users;") for u7 in cursor: user_name = u7["user_name"].strip().replace(" ", "_") + if user_name != u7["user_name"]: + current_app.logger.warning( + f"""Changin login '{u7["user_name"]}' to '{user_name}'""" + ) if User.query.filter_by(user_name=user_name).first(): # user with same name exists ! current_app.logger.warning( @@ -31,7 +35,7 @@ def import_scodoc7_user_db(scodoc7_db="dbname=SCOUSERS"): ) else: u = User( - user_name=u7["user_name"], + user_name=user_name, email=u7["email"], date_modif_passwd=u7["date_modif_passwd"], nom=u7["nom"], @@ -55,9 +59,7 @@ def import_scodoc7_user_db(scodoc7_db="dbname=SCOUSERS"): # Cas général: eg EnsRT m = re.match(r"^(-?[A-Za-z0-9]+?)([A-Z][A-Za-z0-9]*?)$", role_dept) if not m: - msg = ( - f"User {u7['user_name']}: invalid role '{role_dept}' (ignoring)" - ) + msg = f"User {user_name}: invalid role '{role_dept}' (ignoring)" current_app.logger.warning(msg) messages.append(msg) else: @@ -71,7 +73,7 @@ def import_scodoc7_user_db(scodoc7_db="dbname=SCOUSERS"): dept = m.group(2) role = Role.query.filter_by(name=role_name).first() if not role: - msg = f"User {u7['user_name']}: ignoring role '{role_dept}'" + msg = f"User {user_name}: ignoring role '{role_dept}'" current_app.logger.warning(msg) messages.append(msg) else: