From 071c15af79b1f9a20fc1ed3d4a2d4743f99746bb Mon Sep 17 00:00:00 2001 From: Jean-Marie Place Date: Wed, 13 Oct 2021 15:03:41 +0200 Subject: [PATCH 1/2] complements_import_users_from_9.0.52 --- app/scodoc/sco_import_users.py | 3 ++- app/scodoc/sco_users.py | 10 ++++++---- app/views/users.py | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/scodoc/sco_import_users.py b/app/scodoc/sco_import_users.py index 7a779b959..834b8886a 100644 --- a/app/scodoc/sco_import_users.py +++ b/app/scodoc/sco_import_users.py @@ -179,11 +179,12 @@ def import_users(users): user_ok, msg = sco_users.check_modif_user( 0, ignore_optionals=False, + ajout_en_masse=True, user_name=u["user_name"], nom=u["nom"], prenom=u["prenom"], email=u["email"], - roles=u["roles"].split(","), + roles=[r for r in u["roles"].split(",") if r], dept=u["dept"], ) if not user_ok: diff --git a/app/scodoc/sco_users.py b/app/scodoc/sco_users.py index 74853ca80..f2ca5b829 100644 --- a/app/scodoc/sco_users.py +++ b/app/scodoc/sco_users.py @@ -388,6 +388,7 @@ def user_info_page(user_name=None): def check_modif_user( edit, ignore_optionals=False, + ajout_en_masse=False, user_name="", nom="", prenom="", @@ -402,9 +403,10 @@ def check_modif_user( (si ok est faux, l'utilisateur peut quand même forcer la creation) - msg: message warning à presenter à l'utilisateur """ - MSG_OPT = """ - (vous pouvez forcer l'opération en cochant "Ignorer les avertissements" en bas de page) - """ + if ajout_en_masse: + MSG_OPT = """
Impossible de forcer l'opération lors d'une importation en masse""" + else: + MSG_OPT = """
Attention: (vous pouvez forcer l'opération en cochant "Ignorer les avertissements" en bas de page)""" # ce login existe ? user = _user_list(user_name) if edit and not user: # safety net, le user_name ne devrait pas changer @@ -438,7 +440,7 @@ def check_modif_user( and dept != "" and Departement.query.filter_by(acronym=dept).first() is None ): - return False, "département '%s' inexistant" % u["dept"] + MSG_OPT + return False, "département '%s' inexistant" % dept + MSG_OPT if ignore_optionals and not roles: return False, "aucun rôle sélectionné, êtes vous sûr ?" + MSG_OPT # ok diff --git a/app/views/users.py b/app/views/users.py index 0143e4aee..21ea0dea8 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -380,14 +380,14 @@ def create_user_form(user_name=None, edit=0, all_roles=1): if err: H.append(tf_error_message("""Erreur: %s""" % err)) return "\n".join(H) + "\n" + tf[1] + F - ok, msg = sco_users.check_modif_user( edit, - ignore_optionals=force, + ignore_optionals=not force, user_name=user_name, nom=vals["nom"], prenom=vals["prenom"], email=vals["email"], + dept=vals["dept"], roles=vals["roles"], ) if not ok: From feb57c2ac6a958e23a19646d13ed65ba26ef58fe Mon Sep 17 00:00:00 2001 From: Jean-Marie Place Date: Wed, 13 Oct 2021 15:27:19 +0200 Subject: [PATCH 2/2] =?UTF-8?q?redirection=20vers=20all=5Fdepts=20apres=20?= =?UTF-8?q?cr=C3=A9ation=20;=20blackify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_users.py | 4 +++- app/views/users.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/scodoc/sco_users.py b/app/scodoc/sco_users.py index f2ca5b829..a8d15e963 100644 --- a/app/scodoc/sco_users.py +++ b/app/scodoc/sco_users.py @@ -404,7 +404,9 @@ def check_modif_user( - msg: message warning à presenter à l'utilisateur """ if ajout_en_masse: - MSG_OPT = """
Impossible de forcer l'opération lors d'une importation en masse""" + MSG_OPT = ( + """
Impossible de forcer l'opération lors d'une importation en masse""" + ) else: MSG_OPT = """
Attention: (vous pouvez forcer l'opération en cochant "Ignorer les avertissements" en bas de page)""" # ce login existe ? diff --git a/app/views/users.py b/app/views/users.py index 21ea0dea8..93687fce7 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -548,7 +548,7 @@ def import_users_form(): H.append("
  • %s
  • " % d) H.append("") if ok: - dest = url_for("users.index_html", scodoc_dept=g.scodoc_dept) + dest = url_for("users.index_html", scodoc_dept=g.scodoc_dept, all_depts=1) H.append("

    Ok, Import terminé (%s utilisateurs créés)!

    " % nb_created) H.append('

    Continuer

    ' % dest) else: