Merge pull request 'Bul. json: URL fiche etud' (#3) from ScoDoc/ScoDoc:master into master

Reviewed-on: https://scodoc.org/git/lehmann/ScoDoc-Front/pulls/3
This commit is contained in:
Sébastien Lehmann 2021-12-21 16:05:38 +01:00
commit be3a9078e2
2 changed files with 8 additions and 3 deletions

View File

@ -78,4 +78,4 @@ def etudiants():
FormSemestre.date_debut <= func.now(),
FormSemestre.date_fin >= func.now(),
)
return jsonify([e.to_dict_bul(include_photo=False) for e in query])
return jsonify([e.to_dict_bul(include_urls=False) for e in query])

View File

@ -4,6 +4,8 @@
et données rattachées (adresses, annotations, ...)
"""
from flask import g, url_for
from app import db
from app import models
from app.models import APO_CODE_STR_LEN
@ -70,7 +72,7 @@ class Identite(db.Model):
"le mail associé à la première adrese de l'étudiant, ou None"
return self.adresses[0].email or None if self.adresses.count() > 0 else None
def to_dict_bul(self, include_photo=True):
def to_dict_bul(self, include_urls=True):
"""Infos exportées dans les bulletins"""
from app.scodoc import sco_photos
@ -87,7 +89,10 @@ class Identite(db.Model):
"nom": self.nom_disp(),
"prenom": self.prenom,
}
if include_photo:
if include_urls:
d["fiche_url"] = url_for(
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=self.id
)
d["photo_url"] = (sco_photos.get_etud_photo_url(self.id),)
return d