Merge branch 'dev93' of https://scodoc.org/git/ScoDoc/ScoDoc into new_api

This commit is contained in:
leonard_montalbano 2022-04-26 13:43:04 +02:00
commit 06844380ad
7 changed files with 93 additions and 61 deletions

View File

@ -6,8 +6,6 @@
"""ScoDoc 9 models : Référentiel Compétence BUT 2021
"""
from datetime import datetime
from enum import unique
from typing import Any
from sqlalchemy.orm import class_mapper
import sqlalchemy
@ -28,6 +26,8 @@ def attribute_names(cls):
class XMLModel:
"""Mixin class, to ease loading Orebut XMLs"""
_xml_attribs = {} # to be overloaded
id = "_"
@ -162,6 +162,7 @@ class ApcCompetence(db.Model, XMLModel):
class ApcSituationPro(db.Model, XMLModel):
"Situation professionnelle"
id = db.Column(db.Integer, primary_key=True)
competence_id = db.Column(
db.Integer, db.ForeignKey("apc_competence.id"), nullable=False
@ -173,6 +174,7 @@ class ApcSituationPro(db.Model, XMLModel):
class ApcComposanteEssentielle(db.Model, XMLModel):
"Composante essentielle"
id = db.Column(db.Integer, primary_key=True)
competence_id = db.Column(
db.Integer, db.ForeignKey("apc_competence.id"), nullable=False
@ -199,6 +201,9 @@ class ApcNiveau(db.Model, XMLModel):
cascade="all, delete-orphan",
)
def __repr__(self):
return f"<{self.__class__.__name__} ordre={self.ordre}>"
def to_dict(self):
return {
"libelle": self.libelle,
@ -222,14 +227,14 @@ class ApcAppCritique(db.Model, XMLModel):
backref=db.backref("app_critiques", lazy="dynamic"),
)
def to_dict(self):
def to_dict(self) -> dict:
return {"libelle": self.libelle}
def get_label(self):
def get_label(self) -> str:
return self.code + " - " + self.titre
def __repr__(self):
return "<AppCritique {}>".format(self.code)
return f"<{self.__class__.__name__} {self.code}>"
def get_saes(self):
"""Liste des SAE associées"""
@ -258,6 +263,9 @@ class ApcParcours(db.Model, XMLModel):
cascade="all, delete-orphan",
)
def __repr__(self):
return f"<{self.__class__.__name__} {self.code}>"
def to_dict(self):
return {
"code": self.code,
@ -274,6 +282,9 @@ class ApcAnneeParcours(db.Model, XMLModel):
)
ordre = db.Column(db.Integer)
def __repr__(self):
return f"<{self.__class__.__name__} ordre={self.ordre}>"
def to_dict(self):
return {
"ordre": self.ordre,
@ -320,3 +331,6 @@ class ApcParcoursNiveauCompetence(db.Model):
cascade="save-update, merge, delete, delete-orphan",
),
)
def __repr__(self):
return f"<{self.__class__.__name__} {self.competence} {self.annee_parcours}>"

View File

@ -7,7 +7,6 @@ from app.comp import df_cache
from app.models import SHORT_STR_LEN
from app.models.modules import Module
from app.models.ues import UniteEns
from app.scodoc import notesdb as ndb
from app.scodoc import sco_cache
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_utils as scu

View File

@ -32,7 +32,7 @@ import email
import time
from flask import g, request
from flask import flash, render_template, url_for
from flask import flash, jsonify, render_template, url_for
from flask_login import current_user
from app import email
@ -76,6 +76,34 @@ from app.scodoc import sco_bulletins_legacy
from app.scodoc import sco_bulletins_ucac # format expérimental UCAC Cameroun
def get_formsemestre_bulletin_etud_json(
formsemestre: FormSemestre,
etud: Identite,
force_publishing=False,
version="long",
) -> str:
"""Le JSON du bulletin d'un étudiant, quel que soit le type de formation."""
if formsemestre.formation.is_apc():
r = bulletin_but.BulletinBUT(formsemestre)
return jsonify(
r.bulletin_etud(
etud,
formsemestre,
force_publishing=force_publishing,
version=version,
)
)
return formsemestre_bulletinetud(
etud,
formsemestre_id=formsemestre.id,
format="json",
version=version,
xml_with_decisions=True,
force_publishing=force_publishing,
)
# -------------
def make_context_dict(formsemestre: FormSemestre, etud: dict) -> dict:
"""Construit dictionnaire avec valeurs pour substitution des textes
(preferences bul_pdf_*)
@ -799,7 +827,10 @@ def formsemestre_bulletinetud(
force_publishing=False, # force publication meme si semestre non publie sur "portail"
prefer_mail_perso=False,
):
"page bulletin de notes"
"""Page bulletin de notes
pour les formations classiques hors BUT (page HTML)
ou le format "oldjson".
"""
format = format or "html"
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
if not formsemestre:

View File

@ -34,7 +34,7 @@
})
.catch(error => {
let div = document.createElement("div");
div.innerText = "Une erreur s'est produite lors du transfère des données.";
div.innerText = "Une erreur s'est produite lors du transfert des données.";
div.style.fontSize = "24px";
div.style.color = "#d93030";

View File

@ -13,14 +13,13 @@
<script src="/ScoDoc/static/js/ref_competences.js"></script>
<div class="help">
Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à partir du fichier <tt>{{ref.scodoc_orig_filename or "(inconnu)"}}</tt>.
Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à
partir du fichier <tt>{{ref.scodoc_orig_filename or "(inconnu)"}}</tt>.
</div>
<div class="part2">
<a class="stdlink"
href="{{url_for('notes.refcomp_table', scodoc_dept=g.scodoc_dept)}}"
>revenir à la liste des référentiels</a>
<a class="stdlink" href="{{url_for('notes.refcomp_table', scodoc_dept=g.scodoc_dept)}}">liste des référentiels</a>
</div>
{% endblock %}

View File

@ -312,53 +312,42 @@ def formsemestre_bulletinetud(
raise ScoValueError(
"Paramètre manquant: spécifier etudid, code_nip ou code_ine"
)
if formsemestre.formation.is_apc() and format != "oldjson":
if format == "json":
r = bulletin_but.BulletinBUT(formsemestre)
return jsonify(
r.bulletin_etud(
etud,
formsemestre,
force_publishing=force_publishing,
version=version,
)
)
elif format == "html":
return render_template(
"but/bulletin.html",
appreciations=models.BulAppreciations.query.filter_by(
etudid=etudid, formsemestre_id=formsemestre.id
).order_by(models.BulAppreciations.date),
bul_url=url_for(
"notes.formsemestre_bulletinetud",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
etudid=etudid,
format="json",
force_publishing=1, # pour ScoDoc lui même
version=version,
),
can_edit_appreciations=formsemestre.est_responsable(current_user)
or (current_user.has_permission(Permission.ScoEtudInscrit)),
etud=etud,
formsemestre=formsemestre,
inscription_courante=etud.inscription_courante(),
inscription_str=etud.inscription_descr()["inscription_str"],
is_apc=formsemestre.formation.is_apc(),
menu_autres_operations=sco_bulletins.make_menu_autres_operations(
formsemestre, etud, "notes.formsemestre_bulletinetud", version
),
sco=ScoData(etud=etud),
scu=scu,
time=time,
title=f"Bul. {etud.nom} - BUT",
version=version,
)
if not (etudid or code_nip or code_ine):
raise ScoValueError(
"Paramètre manquant: spécifier code_nip ou etudid ou code_ine"
if format == "json":
return sco_bulletins.get_formsemestre_bulletin_etud_json(
formsemestre, etud, version=version
)
if formsemestre.formation.is_apc() and format == "html":
return render_template(
"but/bulletin.html",
appreciations=models.BulAppreciations.query.filter_by(
etudid=etudid, formsemestre_id=formsemestre.id
).order_by(models.BulAppreciations.date),
bul_url=url_for(
"notes.formsemestre_bulletinetud",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
etudid=etudid,
format="json",
force_publishing=1, # pour ScoDoc lui même
version=version,
),
can_edit_appreciations=formsemestre.est_responsable(current_user)
or (current_user.has_permission(Permission.ScoEtudInscrit)),
etud=etud,
formsemestre=formsemestre,
inscription_courante=etud.inscription_courante(),
inscription_str=etud.inscription_descr()["inscription_str"],
is_apc=formsemestre.formation.is_apc(),
menu_autres_operations=sco_bulletins.make_menu_autres_operations(
formsemestre, etud, "notes.formsemestre_bulletinetud", version
),
sco=ScoData(etud=etud),
scu=scu,
time=time,
title=f"Bul. {etud.nom} - BUT",
version=version,
)
if format == "oldjson":
format = "json"
r = sco_bulletins.formsemestre_bulletinetud(

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.2.11"
SCOVERSION = "9.2.12"
SCONAME = "ScoDoc"