From 6dbba98097cb79754859808b5260653d848782e3 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 21 Dec 2021 15:33:21 +0100 Subject: [PATCH] Bul. json: URL fiche etud --- app/api/sco_api.py | 2 +- app/models/etudiants.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/api/sco_api.py b/app/api/sco_api.py index 65bc8c12..969753d1 100644 --- a/app/api/sco_api.py +++ b/app/api/sco_api.py @@ -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]) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index 5b49d68f..0ae36bd2 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -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