1
0
forked from ScoDoc/ScoDoc

Migration: remplace espaces (et strip) les anciens logins.

This commit is contained in:
Emmanuel Viennet 2021-08-22 15:41:39 +02:00
parent c3d6c1f40f
commit 8f4b8ccdf6

View File

@ -23,10 +23,11 @@ def import_scodoc7_user_db(scodoc7_db="dbname=SCOUSERS"):
cursor = cnx.cursor(cursor_factory=psycopg2.extras.DictCursor)
cursor.execute("SELECT * FROM sco_users;")
for u7 in cursor:
if User.query.filter_by(user_name=u7["user_name"]).first():
user_name = u7["user_name"].strip().replace(" ", "_")
if User.query.filter_by(user_name=user_name).first():
# user with same name exists !
current_app.logger.warning(
"User {} exists and is left unchanged".format(u7["user_name"])
f"""User {user_name} (de {u7["user_name"]}) exists and is left unchanged"""
)
else:
u = User(