From 07cdd29716c3aa658edbd18032d979ef8c751bb2 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 28 Apr 2022 03:24:37 +0200 Subject: [PATCH 1/2] API: /etudiants/courant/long et /etudiants/courant --- app/api/etudiants.py | 12 +++++++----- app/models/etudiants.py | 13 ++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 964dcde98..1f22463ec 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -12,12 +12,12 @@ from app.models import FormSemestreInscription, FormSemestre, Identite from app.scodoc import sco_bulletins from app.scodoc import sco_groups from app.scodoc.sco_permissions import Permission -from app.scodoc import notesdb as ndb -@bp.route("/etudiants/courant", methods=["GET"]) +@bp.route("/etudiants/courant", defaults={"long": False}) +@bp.route("/etudiants/courant/long", defaults={"long": True}) @token_permission_required(Permission.APIView) -def etudiants_courant(): +def etudiants_courant(long=False): """ Retourne la liste des étudiants courant @@ -55,8 +55,10 @@ def etudiants_courant(): FormSemestre.date_debut <= app.db.func.now(), FormSemestre.date_fin >= app.db.func.now(), ) - - data = [etu.to_dict_bul(include_urls=False) for etu in etuds] + if long: + data = [etud.to_dict_bul(include_urls=False) for etud in etuds] + else: + data = [etud.to_dict_short() for etud in etuds] return jsonify(data) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index b1fec6092..917b01363 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -141,7 +141,18 @@ class Identite(db.Model): "Le mail associé à la première adrese de l'étudiant, ou None" return getattr(self.adresses[0], field) if self.adresses.count() > 0 else None - def to_dict_scodoc7(self): + def to_dict_short(self) -> dict: + """Les champs essentiels""" + return { + "id": self.id, + "nip": self.code_nip, + "nom": self.nom, + "nom_usuel": self.nom_usuel, + "prenom": self.prenom, + "civilite": self.civilite, + } + + def to_dict_scodoc7(self) -> dict: """Représentation dictionnaire, compatible ScoDoc7 mais sans infos admission """ From f740ab8339b4ba54d7fa798f253a8cb5c21b95fd Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 28 Apr 2022 07:06:01 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20=C3=A9ditions=20evaluation=20sur=20m?= =?UTF-8?q?oduleimpl=5Fstatus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_moduleimpl_status.py | 65 ++++++++++++++++------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index a82cc2b1e..d6def3697 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -210,10 +210,17 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): ) # la plus RECENTE en tête # - caneditevals = sco_permissions_check.can_edit_notes( - current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"] + sem_locked = not sem["etat"] + can_edit_evals = ( + sco_permissions_check.can_edit_notes( + current_user, moduleimpl_id, allow_ens=sem["ens_can_edit_eval"] + ) + and not sem_locked + ) + can_edit_notes = ( + sco_permissions_check.can_edit_notes(current_user, moduleimpl_id) + and not sem_locked ) - caneditnotes = sco_permissions_check.can_edit_notes(current_user, moduleimpl_id) arrow_up, arrow_down, arrow_none = sco_groups.get_arrow_icons_tags() # module_resp = User.query.get(M["responsable_id"]) @@ -264,7 +271,7 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): H.append("""Semestre: %s""" % sem["semestre_id"]) else: H.append("""""") - if not sem["etat"]: + if sem_locked: H.append(scu.icontag("lock32_img", title="verrouillé")) H.append("""""") if modimpl.module.is_apc(): @@ -385,13 +392,15 @@ def moduleimpl_status(moduleimpl_id=None, partition_id=None): # -------- Tableau des evaluations top_table_links = "" - if sem["etat"]: # non verrouillé - top_table_links = ( - """Créer nouvelle évaluation - Trier par date - """ - % M - ) + if can_edit_evals: + top_table_links = f"""Créer nouvelle évaluation + Trier par date + """ if mod_evals: H.append( '