forked from ScoDoc/DocScoDoc
enregistre date dernière connexion. + fix liste users
This commit is contained in:
parent
dd8a07ef64
commit
f59308b863
@ -171,21 +171,25 @@ def list_users(
|
|||||||
if not can_modify:
|
if not can_modify:
|
||||||
d["date_modif_passwd"] = "(non visible)"
|
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"
|
title = "Utilisateurs définis dans ScoDoc"
|
||||||
tab = GenTable(
|
tab = GenTable(
|
||||||
rows=r,
|
rows=r,
|
||||||
columns_ids=(
|
columns_ids=columns_ids,
|
||||||
"user_name",
|
|
||||||
"nom_fmt",
|
|
||||||
"prenom_fmt",
|
|
||||||
"email",
|
|
||||||
"dept",
|
|
||||||
"roles_string",
|
|
||||||
"date_expiration",
|
|
||||||
"date_modif_passwd",
|
|
||||||
"passwd_temp",
|
|
||||||
"status_txt",
|
|
||||||
),
|
|
||||||
titles={
|
titles={
|
||||||
"user_name": "Login",
|
"user_name": "Login",
|
||||||
"nom_fmt": "Nom",
|
"nom_fmt": "Nom",
|
||||||
@ -195,6 +199,7 @@ def list_users(
|
|||||||
"roles_string": "Rôles",
|
"roles_string": "Rôles",
|
||||||
"date_expiration": "Expiration",
|
"date_expiration": "Expiration",
|
||||||
"date_modif_passwd": "Modif. mot de passe",
|
"date_modif_passwd": "Modif. mot de passe",
|
||||||
|
"last_seen": "Dernière cnx.",
|
||||||
"passwd_temp": "Temp.",
|
"passwd_temp": "Temp.",
|
||||||
"status_txt": "Etat",
|
"status_txt": "Etat",
|
||||||
},
|
},
|
||||||
@ -206,7 +211,7 @@ def list_users(
|
|||||||
html_class="table_leftalign list_users",
|
html_class="table_leftalign list_users",
|
||||||
html_with_td_classes=True,
|
html_with_td_classes=True,
|
||||||
html_sortable=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
|
pdf_link=False, # table is too wide to fit in a paper page => disable pdf
|
||||||
preferences=sco_preferences.SemPreferences(),
|
preferences=sco_preferences.SemPreferences(),
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
# -*- coding: UTF-8 -*
|
# -*- coding: UTF-8 -*
|
||||||
"""ScoDoc Flask views
|
"""ScoDoc Flask views
|
||||||
"""
|
"""
|
||||||
|
import datetime
|
||||||
|
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask import g, current_app
|
from flask import g, current_app
|
||||||
|
from flask_login import current_user
|
||||||
|
|
||||||
|
from app import db
|
||||||
from app.scodoc import notesdb as ndb
|
from app.scodoc import notesdb as ndb
|
||||||
|
|
||||||
scodoc_bp = Blueprint("scodoc", __name__)
|
scodoc_bp = Blueprint("scodoc", __name__)
|
||||||
@ -20,7 +25,11 @@ from app.views import scodoc, notes, scolar, absences, users
|
|||||||
@scodoc_bp.before_app_request
|
@scodoc_bp.before_app_request
|
||||||
def start_scodoc_request():
|
def start_scodoc_request():
|
||||||
"""Affecte toutes les requêtes, de tous les blueprints"""
|
"""Affecte toutes les requêtes, de tous les blueprints"""
|
||||||
|
current_app.logger.info(f"start_scodoc_request")
|
||||||
ndb.open_db_connection()
|
ndb.open_db_connection()
|
||||||
|
if current_user.is_authenticated:
|
||||||
|
current_user.last_seen = datetime.datetime.utcnow()
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
@scodoc_bp.teardown_app_request
|
@scodoc_bp.teardown_app_request
|
||||||
|
Loading…
Reference in New Issue
Block a user