CAS: ajout infos pour admin sur table utilisateurs

This commit is contained in:
Emmanuel Viennet 2023-02-26 22:05:21 +01:00
parent 0c38e5e62a
commit c2f845d716

View File

@ -39,7 +39,7 @@ from app import db, Departement
from app.auth.models import Permission
from app.auth.models import User
from app.models import ScoDocSiteConfig
from app.scodoc import html_sco_header
from app.scodoc import sco_preferences
from app.scodoc.gen_tables import GenTable
@ -117,7 +117,7 @@ def list_users(
if dept and not all_depts:
users = get_user_list(dept=dept, with_inactives=with_inactives)
comm = "dept. %s" % dept
comm = f"dept. {dept}"
else:
users = get_user_list(with_inactives=with_inactives)
comm = "tous"
@ -125,13 +125,13 @@ def list_users(
comm += ", avec anciens"
comm = "(" + comm + ")"
# -- Add some information and links:
r = []
rows = []
for u in users:
# Can current user modify this user ?
can_modify = can_handle_passwd(u, allow_admindepts=True)
d = u.to_dict()
r.append(d)
rows.append(d)
# Add links
if with_links and can_modify:
target = url_for(
@ -158,11 +158,15 @@ def list_users(
"status_txt",
]
# Seul l'admin peut voir les dates de dernière connexion
# et les infos CAS
if current_user.is_administrator():
columns_ids.append("last_seen")
if ScoDocSiteConfig.is_cas_enabled():
columns_ids += ["cas_id", "cas_allow_login", "cas_allow_scodoc_login"]
title = "Utilisateurs définis dans ScoDoc"
tab = GenTable(
rows=r,
rows=rows,
columns_ids=columns_ids,
titles={
"user_name": "Login",
@ -176,10 +180,13 @@ def list_users(
"last_seen": "Dernière cnx.",
"passwd_temp": "Temp.",
"status_txt": "Etat",
"cas_id": "Id CAS",
"cas_allow_login": "CAS autorisé",
"cas_allow_scodoc_login": "Cnx sans CAS",
},
caption=title,
page_title="title",
html_title=f"""<h2>{len(r)} utilisateurs {comm}</h2>
html_title=f"""<h2>{len(rows)} utilisateurs {comm}</h2>
<p class="help">Cliquer sur un nom pour changer son mot de passe</p>""",
html_class="table_leftalign list_users",
html_with_td_classes=True,