forked from ScoDoc/ScoDoc
#768: identifiant utilisateur assiduité. N'affiche plus l'id.
This commit is contained in:
parent
b699add4c4
commit
c403b093c6
@ -14,7 +14,6 @@ from flask_login import current_user, login_required
|
|||||||
from app import db, log
|
from app import db, log
|
||||||
import app.scodoc.sco_assiduites as scass
|
import app.scodoc.sco_assiduites as scass
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
from app.scodoc import sco_preferences
|
|
||||||
from app.api import api_bp as bp
|
from app.api import api_bp as bp
|
||||||
from app.api import api_web_bp, get_model_api_object, tools
|
from app.api import api_web_bp, get_model_api_object, tools
|
||||||
from app.decorators import permission_required, scodoc
|
from app.decorators import permission_required, scodoc
|
||||||
@ -24,7 +23,6 @@ from app.models import (
|
|||||||
Identite,
|
Identite,
|
||||||
ModuleImpl,
|
ModuleImpl,
|
||||||
Scolog,
|
Scolog,
|
||||||
Justificatif,
|
|
||||||
)
|
)
|
||||||
from flask_sqlalchemy.query import Query
|
from flask_sqlalchemy.query import Query
|
||||||
from app.models.assiduites import get_assiduites_justif, get_justifs_from_date
|
from app.models.assiduites import get_assiduites_justif, get_justifs_from_date
|
||||||
@ -50,6 +48,8 @@ def assiduite(assiduite_id: int = None):
|
|||||||
"etat": "retard",
|
"etat": "retard",
|
||||||
"desc": "une description",
|
"desc": "une description",
|
||||||
"user_id: 1 or null,
|
"user_id: 1 or null,
|
||||||
|
"user_name" : login scodoc or null
|
||||||
|
"user_nom_complet": "Marie Dupont"
|
||||||
"est_just": False or True,
|
"est_just": False or True,
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@ -207,7 +207,7 @@ class User(UserMixin, db.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def verify_reset_password_token(token):
|
def verify_reset_password_token(token):
|
||||||
"Vérification du token de reéinitialisation du mot de passe"
|
"Vérification du token de ré-initialisation du mot de passe"
|
||||||
try:
|
try:
|
||||||
token = jwt.decode(
|
token = jwt.decode(
|
||||||
token, current_app.config["SECRET_KEY"], algorithms=["HS256"]
|
token, current_app.config["SECRET_KEY"], algorithms=["HS256"]
|
||||||
|
@ -66,6 +66,14 @@ class Assiduite(db.Model):
|
|||||||
# Déclare la relation "joined" car on va très souvent vouloir récupérer
|
# Déclare la relation "joined" car on va très souvent vouloir récupérer
|
||||||
# l'étudiant en même tant que l'assiduité (perf.: évite nouvelle requete SQL)
|
# l'étudiant en même tant que l'assiduité (perf.: évite nouvelle requete SQL)
|
||||||
etudiant = db.relationship("Identite", back_populates="assiduites", lazy="joined")
|
etudiant = db.relationship("Identite", back_populates="assiduites", lazy="joined")
|
||||||
|
# En revanche, user est rarement accédé:
|
||||||
|
user = db.relationship(
|
||||||
|
"User",
|
||||||
|
backref=db.backref(
|
||||||
|
"assiduites", lazy="select", order_by="Assiduite.entry_date"
|
||||||
|
),
|
||||||
|
lazy="select",
|
||||||
|
)
|
||||||
|
|
||||||
def to_dict(self, format_api=True) -> dict:
|
def to_dict(self, format_api=True) -> dict:
|
||||||
"""Retourne la représentation json de l'assiduité"""
|
"""Retourne la représentation json de l'assiduité"""
|
||||||
@ -87,6 +95,9 @@ class Assiduite(db.Model):
|
|||||||
"entry_date": self.entry_date,
|
"entry_date": self.entry_date,
|
||||||
"user_id": None if user is None else user.id, # l'uid
|
"user_id": None if user is None else user.id, # l'uid
|
||||||
"user_name": None if user is None else user.user_name, # le login
|
"user_name": None if user is None else user.user_name, # le login
|
||||||
|
"user_nom_complet": None
|
||||||
|
if user is None
|
||||||
|
else user.get_nomcomplet(), # "Marie Dupont"
|
||||||
"est_just": self.est_just,
|
"est_just": self.est_just,
|
||||||
"external_data": self.external_data,
|
"external_data": self.external_data,
|
||||||
}
|
}
|
||||||
|
@ -1746,6 +1746,7 @@ function getModuleImpl(assiduite) {
|
|||||||
return moduleimpls[id];
|
return moduleimpls[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// le nom de l'utilisateur à afficher
|
||||||
function getUser(obj) {
|
function getUser(obj) {
|
||||||
if (
|
if (
|
||||||
obj.hasOwnProperty("external_data") &&
|
obj.hasOwnProperty("external_data") &&
|
||||||
@ -1755,5 +1756,5 @@ function getUser(obj) {
|
|||||||
return obj.external_data.enseignant;
|
return obj.external_data.enseignant;
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj.user_id;
|
return obj.user_nom_complet || obj.user_id;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@
|
|||||||
assiduite.assiduite_id;
|
assiduite.assiduite_id;
|
||||||
document.getElementById(
|
document.getElementById(
|
||||||
"modal-assiduite-user"
|
"modal-assiduite-user"
|
||||||
).textContent = `saisi le ${formatDateModal(
|
).textContent = `saisie le ${formatDateModal(
|
||||||
assiduite.entry_date,
|
assiduite.entry_date,
|
||||||
"à"
|
"à"
|
||||||
)} \npar ${assiduite.user_id}`;
|
)} \npar ${assiduite.user_id}`;
|
||||||
@ -438,7 +438,7 @@
|
|||||||
|
|
||||||
const userIdDiv = document.createElement("div");
|
const userIdDiv = document.createElement("div");
|
||||||
userIdDiv.className = "assiduite-user_id";
|
userIdDiv.className = "assiduite-user_id";
|
||||||
userIdDiv.textContent = `saisi le ${formatDateModal(
|
userIdDiv.textContent = `saisie le ${formatDateModal(
|
||||||
assiduite.entry_date,
|
assiduite.entry_date,
|
||||||
"à"
|
"à"
|
||||||
)} \npar ${assiduite.user_id}`;
|
)} \npar ${assiduite.user_id}`;
|
||||||
|
@ -164,13 +164,13 @@
|
|||||||
|
|
||||||
const userIdDiv = document.createElement("div");
|
const userIdDiv = document.createElement("div");
|
||||||
userIdDiv.className = "assiduite-user_id";
|
userIdDiv.className = "assiduite-user_id";
|
||||||
userIdDiv.textContent = `saisi le ${formatDateModal(
|
userIdDiv.textContent = `saisie le ${formatDateModal(
|
||||||
assiduite.entry_date,
|
assiduite.entry_date,
|
||||||
"à"
|
"à"
|
||||||
)}`;
|
)}`;
|
||||||
|
|
||||||
if (assiduite.user_id != null) {
|
if (assiduite.user_id != null) {
|
||||||
userIdDiv.textContent += `\npar ${assiduite.user_id}`
|
userIdDiv.textContent += `\npar ${assiduite.user_nom_complet}`
|
||||||
}
|
}
|
||||||
bubble.appendChild(userIdDiv);
|
bubble.appendChild(userIdDiv);
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@
|
|||||||
<span class="obj-content">${etat}</span>
|
<span class="obj-content">${etat}</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="user" class="obj-part">
|
<div id="user" class="obj-part">
|
||||||
<span class="obj-title">Créée par</span>
|
<span class="obj-title">par</span>
|
||||||
<span class="obj-content">${user}</span>
|
<span class="obj-content">${user}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -164,9 +164,7 @@
|
|||||||
<span class="obj-title">Description</span>
|
<span class="obj-title">Description</span>
|
||||||
<p class="obj-content">${desc}</p>
|
<p class="obj-content">${desc}</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="id" class="obj-part">
|
<div id="id" class="obj-part" data-assiduite-id="${id}">
|
||||||
<span class="obj-title">Identifiant de l'assiduité</span>
|
|
||||||
<span class="obj-content">${id}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user