forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -14,7 +14,6 @@ from flask_login import current_user, login_required
|
||||
from app import db, log
|
||||
import app.scodoc.sco_assiduites as scass
|
||||
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_web_bp, get_model_api_object, tools
|
||||
from app.decorators import permission_required, scodoc
|
||||
@ -24,7 +23,6 @@ from app.models import (
|
||||
Identite,
|
||||
ModuleImpl,
|
||||
Scolog,
|
||||
Justificatif,
|
||||
)
|
||||
from flask_sqlalchemy.query import Query
|
||||
from app.models.assiduites import get_assiduites_justif, get_justifs_from_date
|
||||
@ -50,6 +48,8 @@ def assiduite(assiduite_id: int = None):
|
||||
"etat": "retard",
|
||||
"desc": "une description",
|
||||
"user_id: 1 or null,
|
||||
"user_name" : login scodoc or null
|
||||
"user_nom_complet": "Marie Dupont"
|
||||
"est_just": False or True,
|
||||
}
|
||||
"""
|
||||
|
@ -207,7 +207,7 @@ class User(UserMixin, db.Model):
|
||||
|
||||
@staticmethod
|
||||
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:
|
||||
token = jwt.decode(
|
||||
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
|
||||
# l'étudiant en même tant que l'assiduité (perf.: évite nouvelle requete SQL)
|
||||
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:
|
||||
"""Retourne la représentation json de l'assiduité"""
|
||||
@ -87,6 +95,9 @@ class Assiduite(db.Model):
|
||||
"entry_date": self.entry_date,
|
||||
"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_nom_complet": None
|
||||
if user is None
|
||||
else user.get_nomcomplet(), # "Marie Dupont"
|
||||
"est_just": self.est_just,
|
||||
"external_data": self.external_data,
|
||||
}
|
||||
|
@ -1746,6 +1746,7 @@ function getModuleImpl(assiduite) {
|
||||
return moduleimpls[id];
|
||||
}
|
||||
|
||||
// le nom de l'utilisateur à afficher
|
||||
function getUser(obj) {
|
||||
if (
|
||||
obj.hasOwnProperty("external_data") &&
|
||||
@ -1755,5 +1756,5 @@ function getUser(obj) {
|
||||
return obj.external_data.enseignant;
|
||||
}
|
||||
|
||||
return obj.user_id;
|
||||
return obj.user_nom_complet || obj.user_id;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@
|
||||
assiduite.assiduite_id;
|
||||
document.getElementById(
|
||||
"modal-assiduite-user"
|
||||
).textContent = `saisi le ${formatDateModal(
|
||||
).textContent = `saisie le ${formatDateModal(
|
||||
assiduite.entry_date,
|
||||
"à"
|
||||
)} \npar ${assiduite.user_id}`;
|
||||
@ -438,7 +438,7 @@
|
||||
|
||||
const userIdDiv = document.createElement("div");
|
||||
userIdDiv.className = "assiduite-user_id";
|
||||
userIdDiv.textContent = `saisi le ${formatDateModal(
|
||||
userIdDiv.textContent = `saisie le ${formatDateModal(
|
||||
assiduite.entry_date,
|
||||
"à"
|
||||
)} \npar ${assiduite.user_id}`;
|
||||
|
@ -164,13 +164,13 @@
|
||||
|
||||
const userIdDiv = document.createElement("div");
|
||||
userIdDiv.className = "assiduite-user_id";
|
||||
userIdDiv.textContent = `saisi le ${formatDateModal(
|
||||
userIdDiv.textContent = `saisie le ${formatDateModal(
|
||||
assiduite.entry_date,
|
||||
"à"
|
||||
)}`;
|
||||
|
||||
if (assiduite.user_id != null) {
|
||||
userIdDiv.textContent += `\npar ${assiduite.user_id}`
|
||||
userIdDiv.textContent += `\npar ${assiduite.user_nom_complet}`
|
||||
}
|
||||
bubble.appendChild(userIdDiv);
|
||||
|
||||
|
@ -151,7 +151,7 @@
|
||||
<span class="obj-content">${etat}</span>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
@ -164,9 +164,7 @@
|
||||
<span class="obj-title">Description</span>
|
||||
<p class="obj-content">${desc}</p>
|
||||
</div>
|
||||
<div id="id" class="obj-part">
|
||||
<span class="obj-title">Identifiant de l'assiduité</span>
|
||||
<span class="obj-content">${id}</span>
|
||||
<div id="id" class="obj-part" data-assiduite-id="${id}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user