1
0
forked from ScoDoc/ScoDoc

enregistre date dernière connexion. + fix liste users

This commit is contained in:
Emmanuel Viennet 2021-10-03 18:19:51 +02:00
parent dd8a07ef64
commit f59308b863
2 changed files with 27 additions and 13 deletions

View File

@ -171,21 +171,25 @@ def list_users(
if not can_modify:
d["date_modif_passwd"] = "(non visible)"
columns_ids = [
"user_name",
"nom_fmt",
"prenom_fmt",
"email",
"dept",
"roles_string",
"date_expiration",
"date_modif_passwd",
"passwd_temp",
"status_txt",
]
# Seul l'admin peut voir les dates de dernière connexion
if current_user.is_administrator():
columns_ids.append("last_seen")
title = "Utilisateurs définis dans ScoDoc"
tab = GenTable(
rows=r,
columns_ids=(
"user_name",
"nom_fmt",
"prenom_fmt",
"email",
"dept",
"roles_string",
"date_expiration",
"date_modif_passwd",
"passwd_temp",
"status_txt",
),
columns_ids=columns_ids,
titles={
"user_name": "Login",
"nom_fmt": "Nom",
@ -195,6 +199,7 @@ def list_users(
"roles_string": "Rôles",
"date_expiration": "Expiration",
"date_modif_passwd": "Modif. mot de passe",
"last_seen": "Dernière cnx.",
"passwd_temp": "Temp.",
"status_txt": "Etat",
},
@ -206,7 +211,7 @@ def list_users(
html_class="table_leftalign list_users",
html_with_td_classes=True,
html_sortable=True,
base_url="%s?all=%s" % (request.base_url, all),
base_url="%s?all_depts=%s" % (request.base_url, 1 if all_depts else 0),
pdf_link=False, # table is too wide to fit in a paper page => disable pdf
preferences=sco_preferences.SemPreferences(),
)

View File

@ -1,8 +1,13 @@
# -*- coding: UTF-8 -*
"""ScoDoc Flask views
"""
import datetime
from flask import Blueprint
from flask import g, current_app
from flask_login import current_user
from app import db
from app.scodoc import notesdb as ndb
scodoc_bp = Blueprint("scodoc", __name__)
@ -20,7 +25,11 @@ from app.views import scodoc, notes, scolar, absences, users
@scodoc_bp.before_app_request
def start_scodoc_request():
"""Affecte toutes les requêtes, de tous les blueprints"""
current_app.logger.info(f"start_scodoc_request")
ndb.open_db_connection()
if current_user.is_authenticated:
current_user.last_seen = datetime.datetime.utcnow()
db.session.commit()
@scodoc_bp.teardown_app_request