Compare commits

..

15 Commits

Author SHA1 Message Date
leonard_montalbano
4b00a5c8ff fix diffs avec origin master 2022-07-11 13:39:50 +02:00
leonard_montalbano
c021572a1a Merge branch 'master' of https://scodoc.org/git/ScoDoc/ScoDoc into new_api 2022-07-11 12:48:55 +02:00
6d881915bd Fix: association parcours (restriction au dept.) 2022-07-10 12:08:22 +02:00
51178795e2 Améliore messages erreur bulletins pdf 2022-07-09 22:40:46 +02:00
d5ff4f79a8 Fix: jury BUT: UE CMP et ADJ affichées comme validées 2022-07-09 13:32:14 +02:00
2fcb397f9b Merge pull request 'Bug relevé "masquer rang"' (#438) from lehmann/ScoDoc-Front:master into master
Reviewed-on: https://scodoc.org/git/ScoDoc/ScoDoc/pulls/438
2022-07-09 13:31:28 +02:00
f1bbf4bfb4 Bug relevé "masquer rang" 2022-07-09 13:29:30 +02:00
1148bf59eb Améliore édition programme BUT: choix niveaux compétence / UE 2022-07-09 12:55:23 +02:00
5bc4b47e1e Lettres de décisions jury BUT 2022-07-08 23:58:27 +02:00
bf27fcbdc6 Bulletins et PV: champs décisions jury BUT 2022-07-08 18:09:45 +02:00
8e463e5971 Missing import in sco_excel 2022-07-08 06:32:43 +02:00
543c3759d9 refactoring et préparatifs pour lettres individuelles BUT 2022-07-07 23:34:14 +02:00
206825c42c Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into situation_but 2022-07-07 22:30:05 +02:00
c9f399d9f7 Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into situation_but 2022-07-07 17:23:17 +02:00
81e7914620 Refactoring: cursus Classic/ECTS/BUT 2022-07-07 16:24:52 +02:00
70 changed files with 973 additions and 944 deletions

0
LICENSE Executable file → Normal file
View File

0
README.md Executable file → Normal file
View File

View File

@ -70,7 +70,9 @@ def form_ue_choix_niveau(formation: Formation, ue: UniteEns) -> str:
<div class="ue_choix_niveau">
<form id="form_ue_choix_niveau">
<b>Niveau de compétence associé:</b>
<select onchange="set_ue_niveau_competence();" data-setter="{
<select onchange="set_ue_niveau_competence(this);"
data-ue_id="{ue.id}"
data-setter="{
url_for( "notes.set_ue_niveau_competence", scodoc_dept=g.scodoc_dept)
}">
<option value="" {'selected' if ue.niveau_competence is None else ''}>aucun</option>
@ -83,7 +85,6 @@ def form_ue_choix_niveau(formation: Formation, ue: UniteEns) -> str:
def set_ue_niveau_competence(ue_id: int, niveau_id: int):
"""Associe le niveau et l'UE"""
log(f"set_ue_niveau_competence( {ue_id}, {niveau_id} )")
ue = UniteEns.query.get_or_404(ue_id)
autres_ues = ue.formation.ues.filter_by(semestre_idx=ue.semestre_idx)
@ -96,6 +97,7 @@ def set_ue_niveau_competence(ue_id: int, niveau_id: int):
)
return "", 409 # conflict
if niveau_id == "":
niveau = ""
# suppression de l'association
ue.niveau_competence = None
else:
@ -103,4 +105,6 @@ def set_ue_niveau_competence(ue_id: int, niveau_id: int):
ue.niveau_competence = niveau
db.session.add(ue)
db.session.commit()
log(f"set_ue_niveau_competence( {ue}, {niveau} )")
return "", 204

View File

@ -326,10 +326,7 @@ class BulletinBUT:
semestre_infos["ECTS"] = {"acquis": ects_acquis, "total": ects_tot}
if sco_preferences.get_preference("bul_show_decision", formsemestre.id):
semestre_infos.update(
sco_bulletins_json.dict_decision_jury(etud.id, formsemestre.id)
)
semestre_infos.update(
but_validations.dict_decision_jury(etud, formsemestre)
sco_bulletins_json.dict_decision_jury(etud, formsemestre)
)
if etat_inscription == scu.INSCRIT:
# moyenne des moyennes générales du semestre

67
app/but/cursus_but.py Normal file
View File

@ -0,0 +1,67 @@
##############################################################################
# ScoDoc
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
# See LICENSE
##############################################################################
"""Cursus en BUT
Classe raccordant avec ScoDoc 7:
ScoDoc 7 utilisait sco_cursus_dut.SituationEtudCursus
Ce module définit une classe SituationEtudCursusBUT
avec la même interface.
"""
from typing import Union
from flask import g, url_for
from app import db
from app import log
from app.comp.res_but import ResultatsSemestreBUT
from app.comp.res_compat import NotesTableCompat
from app.comp import res_sem
from app.models import formsemestre
from app.models.but_refcomp import (
ApcAnneeParcours,
ApcCompetence,
ApcNiveau,
ApcParcours,
ApcParcoursNiveauCompetence,
)
from app.models import Scolog, ScolarAutorisationInscription
from app.models.but_validations import (
ApcValidationAnnee,
ApcValidationRCUE,
RegroupementCoherentUE,
)
from app.models.etudiants import Identite
from app.models.formations import Formation
from app.models.formsemestre import FormSemestre, FormSemestreInscription
from app.models.ues import UniteEns
from app.models.validations import ScolarFormSemestreValidation
from app.scodoc import sco_codes_parcours as sco_codes
from app.scodoc.sco_codes_parcours import RED, UE_STANDARD
from app.scodoc import sco_utils as scu
from app.scodoc.sco_exceptions import ScoException, ScoValueError
from app.scodoc import sco_cursus_dut
class SituationEtudCursusBUT(sco_cursus_dut.SituationEtudCursusClassic):
def __init__(self, etud: dict, formsemestre_id: int, res: ResultatsSemestreBUT):
super().__init__(etud, formsemestre_id, res)
# Ajustements pour le BUT
self.can_compensate_with_prev = False # jamais de compensation à la mode DUT
def check_compensation_dut(self, semc: dict, ntc: NotesTableCompat):
"Jamais de compensation façon DUT"
return False
def parcours_validated(self):
"True si le parcours est validé"
return False # XXX TODO

View File

@ -101,10 +101,17 @@ def formsemestre_saisie_jury_but(
f"""<h3>Décisions de jury enregistrées pour les étudiants de ce semestre</h3>
<div class="table_jury_but_links">
<div>
<a href="{url_for(
<ul>
<li><a href="{url_for(
"notes.pvjury_table_but",
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre2.id)
}" class="stdlink">tableau PV de jury</a>
}" class="stdlink">Tableau PV de jury</a>
</li>
<li><a href="{url_for(
"notes.formsemestre_lettres_individuelles",
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre2.id)
}" class="stdlink">Courriers individuels (classeur pdf)</a>
</li>
</div>
</div>
"""

View File

@ -118,7 +118,7 @@ class ApcReferentielCompetences(db.Model, XMLModel):
# self.formations = formations
def __repr__(self):
return f"<ApcReferentielCompetences {self.id} {self.specialite!r}>"
return f"<ApcReferentielCompetences {self.id} {self.specialite!r} {self.departement!r}>"
def to_dict(self):
"""Représentation complète du ref. de comp.
@ -348,7 +348,7 @@ class ApcNiveau(db.Model, XMLModel):
self.app_critiques = app_critiques
def __repr__(self):
return f"""<{self.__class__.__name__} ordre={self.ordre!r} annee={
return f"""<{self.__class__.__name__} {self.id} ordre={self.ordre!r} annee={
self.annee!r} {self.competence!r}>"""
def to_dict(self):
@ -451,7 +451,6 @@ class ApcAppCritique(db.Model, XMLModel):
if competence is not None:
query = query.filter(ApcNiveau.competence == competence)
return query
<<<<<<< HEAD
def __init__(self, id, niveau_id, code, libelle, modules):
self.id = id
@ -459,8 +458,6 @@ class ApcAppCritique(db.Model, XMLModel):
self.code = code
self.libelle = libelle
self.modules = modules
=======
>>>>>>> 7c340c798ad59c41653efc83bfd079f11fce1938
def to_dict(self) -> dict:
return {"libelle": self.libelle}
@ -529,7 +526,7 @@ class ApcParcours(db.Model, XMLModel):
self.annes = annes
def __repr__(self):
return f"<{self.__class__.__name__} {self.code!r}>"
return f"<{self.__class__.__name__} {self.id} {self.code!r} ref={self.referentiel}>"
def to_dict(self):
return {
@ -547,17 +544,14 @@ class ApcAnneeParcours(db.Model, XMLModel):
)
ordre = db.Column(db.Integer)
"numéro de l'année: 1, 2, 3"
<<<<<<< HEAD
def __init__(self, id, parcours_id, ordre):
self.id = id
self.parcours_id = parcours_id
self.ordre = ordre
=======
>>>>>>> 7c340c798ad59c41653efc83bfd079f11fce1938
def __repr__(self):
return f"<{self.__class__.__name__} ordre={self.ordre!r} parcours={self.parcours.code!r}>"
return f"<{self.__class__.__name__} {self.id} ordre={self.ordre!r} parcours={self.parcours.code!r}>"
def to_dict(self):
return {

View File

@ -67,7 +67,7 @@ class ApcValidationRCUE(db.Model):
return self.ue2.niveau_competence
def to_dict_bul(self) -> dict:
"Export dict pour bulletins"
"Export dict pour bulletins: le code et le niveau de compétence"
return {"code": self.code, "niveau": self.niveau().to_dict_bul()}
@ -309,7 +309,9 @@ class ApcValidationAnnee(db.Model):
def dict_decision_jury(etud: Identite, formsemestre: FormSemestre) -> dict:
"""
Un dict avec les décisions de jury BUT enregistrées.
Un dict avec les décisions de jury BUT enregistrées:
- decision_rcue : list[dict]
- decision_annee : dict
Ne reprend pas les décisions d'UE, non spécifiques au BUT.
"""
decisions = {}
@ -320,8 +322,19 @@ def dict_decision_jury(etud: Identite, formsemestre: FormSemestre) -> dict:
etudid=etud.id, formsemestre_id=formsemestre.id
)
decisions["decision_rcue"] = [v.to_dict_bul() for v in validations_rcues]
decisions["descr_decisions_rcue"] = ", ".join(
[
f"""{dec_rcue["niveau"]["competence"]["titre"]}&nbsp;{dec_rcue["niveau"]["ordre"]}:&nbsp;{dec_rcue["code"]}"""
for dec_rcue in decisions["decision_rcue"]
]
)
decisions["descr_decisions_niveaux"] = (
"Niveaux de compétences: " + decisions["descr_decisions_rcue"]
)
else:
decisions["decision_rcue"] = []
decisions["descr_decisions_rcue"] = ""
decisions["descr_decisions_niveaux"] = ""
# --- Année: prend la validation pour l'année scolaire de ce semestre
validation = (
ApcValidationAnnee.query.filter_by(

View File

@ -31,6 +31,9 @@ class Departement(db.Model):
"ScoPreference", lazy="dynamic", backref="departement"
)
semsets = db.relationship("NotesSemSet", lazy="dynamic", backref="departement")
referentiels = db.relationship(
"ApcReferentielCompetences", lazy="dynamic", backref="departement"
)
def __repr__(self):
return f"<{self.__class__.__name__}(id={self.id}, acronym='{self.acronym}')>"

View File

@ -5,7 +5,7 @@
import datetime
from functools import cached_property
from flask import flash
from flask import flash, g
import flask_sqlalchemy
from sqlalchemy.sql import text
@ -19,11 +19,11 @@ from app.models.but_refcomp import (
ApcNiveau,
ApcParcours,
ApcParcoursNiveauCompetence,
ApcReferentielCompetences,
)
from app.models.groups import GroupDescr, Partition
import app.scodoc.sco_utils as scu
from app.models.but_refcomp import ApcParcours
from app.models.but_refcomp import parcours_formsemestre
from app.models.etudiants import Identite
from app.models.modules import Module
@ -599,7 +599,11 @@ class FormSemestre(db.Model):
)
# Inscrit les étudiants des groupes de parcours:
for group in partition.groups:
query = ApcParcours.query.filter_by(code=group.group_name)
query = (
ApcParcours.query.filter_by(code=group.group_name)
.join(ApcReferentielCompetences)
.filter_by(dept_id=g.scodoc_dept_id)
)
if query.count() != 1:
log(
f"""update_inscriptions_parcours_from_groups: {

View File

@ -57,6 +57,11 @@ class ScolarFormSemestreValidation(db.Model):
def __repr__(self):
return f"{self.__class__.__name__}({self.formsemestre_id}, {self.etudid}, code={self.code}, ue={self.ue}, moy_ue={self.moy_ue})"
def to_dict(self) -> dict:
d = dict(self.__dict__)
d.pop("_sa_instance_state", None)
return d
class ScolarAutorisationInscription(db.Model):
"""Autorisation d'inscription dans un semestre"""
@ -78,6 +83,11 @@ class ScolarAutorisationInscription(db.Model):
db.ForeignKey("notes_formsemestre.id"),
)
def to_dict(self) -> dict:
d = dict(self.__dict__)
d.pop("_sa_instance_state", None)
return d
@classmethod
def autorise_etud(
cls,
@ -146,3 +156,8 @@ class ScolarEvent(db.Model):
db.Integer,
db.ForeignKey("notes_formsemestre.id"),
)
def to_dict(self) -> dict:
d = dict(self.__dict__)
d.pop("_sa_instance_state", None)
return d

View File

@ -54,22 +54,22 @@ from app.scodoc.sco_codes_parcours import (
ue_is_fondamentale,
ue_is_professionnelle,
)
from app.scodoc.sco_parcours_dut import formsemestre_get_etud_capitalisation
from app.scodoc import sco_cache
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_compute_moy
from app.scodoc import sco_cache
from app.scodoc.sco_cursus import formsemestre_get_etud_capitalisation
from app.scodoc import sco_cursus_dut
from app.scodoc import sco_edit_matiere
from app.scodoc import sco_edit_module
from app.scodoc import sco_edit_ue
from app.scodoc import sco_etud
from app.scodoc import sco_evaluations
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
def comp_ranks(T):
@ -1175,7 +1175,7 @@ class NotesTable:
):
if not cnx:
cnx = ndb.GetDBConnexion()
sco_parcours_dut.do_formsemestre_validate_ue(
sco_cursus_dut.do_formsemestre_validate_ue(
cnx,
nt_cap,
ue_cap["formsemestre_id"],

View File

@ -265,9 +265,9 @@ def DBUpdateArgs(cnx, table, vals, where=None, commit=False, convert_empty_to_nu
cursor.execute(req, vals)
# log('req=%s\n'%req)
# log('vals=%s\n'%vals)
except psycopg2.errors.StringDataRightTruncation:
except psycopg2.errors.StringDataRightTruncation as exc:
cnx.rollback()
raise ScoValueError("champs de texte trop long !")
raise ScoValueError("champs de texte trop long !") from exc
except:
cnx.rollback() # get rid of this transaction
log('Exception in DBUpdateArgs:\n\treq="%s"\n\tvals="%s"\n' % (req, vals))

View File

@ -112,8 +112,8 @@ from app.scodoc.sco_codes_parcours import (
NAR,
RAT,
)
from app.scodoc import sco_cursus
from app.scodoc import sco_formsemestre
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_etud
APO_PORTAL_ENCODING = (
@ -413,7 +413,7 @@ class ApoEtud(dict):
export_res_etape = self.export_res_etape
if (not export_res_etape) and cur_sem:
# exporte toujours le résultat de l'étape si l'étudiant est diplômé
Se = sco_parcours_dut.SituationEtudParcours(
Se = sco_cursus.get_situation_etud_cursus(
self.etud, cur_sem["formsemestre_id"]
)
export_res_etape = Se.all_other_validated()

View File

@ -434,7 +434,7 @@ def _get_etud_etat_html(etat: str) -> str:
elif etat == scu.DEF: # "DEF"
return ' <font color="red">(DEFAILLANT)</font> '
else:
return ' <font color="red">(%s)</font> ' % etat
return f' <font color="red">({etat})</font> '
def _sort_mod_by_matiere(modlist, nt, etudid):
@ -707,6 +707,7 @@ def etud_descr_situation_semestre(
descr_decisions_ue : ' UE acquises: UE1, UE2', ou vide si pas de dec. ou si pas show_uevalid
descr_mention : 'Mention Bien', ou vide si pas de mention ou si pas show_mention
"""
# Fonction utilisée par tous les bulletins (APC ou classiques)
cnx = ndb.GetDBConnexion()
infos = scu.DictDefault(defaultvalue="")
@ -728,8 +729,7 @@ def etud_descr_situation_semestre(
# il y a eu une erreur qui a laissé un event 'inscription'
# on l'efface:
log(
"etud_descr_situation_semestre: removing duplicate INSCRIPTION event for etudid=%s !"
% etudid
f"etud_descr_situation_semestre: removing duplicate INSCRIPTION event for etudid={etudid} !"
)
sco_etud.scolar_events_delete(cnx, event["event_id"])
else:
@ -738,8 +738,7 @@ def etud_descr_situation_semestre(
# assert date_dem == None, 'plusieurs démissions !'
if date_dem: # cela ne peut pas arriver sauf bug (signale a Evry 2013?)
log(
"etud_descr_situation_semestre: removing duplicate DEMISSION event for etudid=%s !"
% etudid
f"etud_descr_situation_semestre: removing duplicate DEMISSION event for etudid={etudid} !"
)
sco_etud.scolar_events_delete(cnx, event["event_id"])
else:
@ -747,8 +746,7 @@ def etud_descr_situation_semestre(
elif event_type == "DEFAILLANCE":
if date_def:
log(
"etud_descr_situation_semestre: removing duplicate DEFAILLANCE event for etudid=%s !"
% etudid
f"etud_descr_situation_semestre: removing duplicate DEFAILLANCE event for etudid={etudid} !"
)
sco_etud.scolar_events_delete(cnx, event["event_id"])
else:
@ -756,10 +754,10 @@ def etud_descr_situation_semestre(
if show_date_inscr:
if not date_inscr:
infos["date_inscription"] = ""
infos["descr_inscription"] = "Pas inscrit%s." % ne
infos["descr_inscription"] = f"Pas inscrit{ne}."
else:
infos["date_inscription"] = date_inscr
infos["descr_inscription"] = "Inscrit%s le %s." % (ne, date_inscr)
infos["descr_inscription"] = f"Inscrit{ne} le {date_inscr}."
else:
infos["date_inscription"] = ""
infos["descr_inscription"] = ""
@ -767,15 +765,15 @@ def etud_descr_situation_semestre(
infos["situation"] = infos["descr_inscription"]
if date_dem:
infos["descr_demission"] = "Démission le %s." % date_dem
infos["descr_demission"] = f"Démission le {date_dem}."
infos["date_demission"] = date_dem
infos["descr_decision_jury"] = "Démission"
infos["situation"] += " " + infos["descr_demission"]
return infos, None # ne donne pas les dec. de jury pour les demissionnaires
if date_def:
infos["descr_defaillance"] = "Défaillant%s" % ne
infos["descr_defaillance"] = f"Défaillant{ne}"
infos["date_defaillance"] = date_def
infos["descr_decision_jury"] = "Défaillant%s" % ne
infos["descr_decision_jury"] = f"Défaillant{ne}"
infos["situation"] += " " + infos["descr_defaillance"]
dpv = sco_pvjury.dict_pvjury(formsemestre_id, etudids=[etudid])
@ -798,6 +796,7 @@ def etud_descr_situation_semestre(
dec = infos["descr_decision_jury"]
else:
infos["descr_decision_jury"] = ""
infos["decision_jury"] = ""
if pv["decisions_ue_descr"] and show_uevalid:
infos["decisions_ue"] = pv["decisions_ue_descr"]
@ -809,14 +808,25 @@ def etud_descr_situation_semestre(
infos["mention"] = pv["mention"]
if pv["mention"] and show_mention:
dec += "Mention " + pv["mention"] + ". "
dec += f"Mention {pv['mention']}."
# Décisions APC / BUT
if pv.get("decision_annee", {}):
infos["descr_decision_annee"] = "Décision année: " + pv.get(
"decision_annee", {}
).get("code", "")
else:
infos["descr_decision_annee"] = ""
infos["descr_decisions_rcue"] = pv.get("descr_decisions_rcue", "")
infos["descr_decisions_niveaux"] = pv.get("descr_decisions_niveaux", "")
infos["situation"] += " " + dec
if not pv["validation_parcours"]: # parcours non terminé
if pv["autorisations_descr"]:
infos["situation"] += (
" Autorisé à s'inscrire en %s." % pv["autorisations_descr"]
)
infos[
"situation"
] += f" Autorisé à s'inscrire en {pv['autorisations_descr']}."
else:
infos["situation"] += " Diplôme obtenu."
return infos, dpv

View File

@ -25,7 +25,7 @@
#
##############################################################################
"""Génération du bulletin en format JSON (beta, non completement testé)
"""Génération du bulletin en format JSON
"""
import datetime
@ -33,8 +33,9 @@ import json
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models.formsemestre import FormSemestre
from app.models import but_validations
from app.models.etudiants import Identite
from app.models.formsemestre import FormSemestre
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
@ -139,7 +140,7 @@ def formsemestre_bulletinetud_published_dict(
etat_inscription = etud.inscription_etat(formsemestre.id)
if etat_inscription != scu.INSCRIT:
d.update(dict_decision_jury(etudid, formsemestre_id, with_decisions=True))
d.update(dict_decision_jury(etud, formsemestre, with_decisions=True))
return d
# Groupes:
@ -343,9 +344,7 @@ def formsemestre_bulletinetud_published_dict(
d["absences"] = dict(nbabs=nbabs, nbabsjust=nbabsjust)
# --- Decision Jury
d.update(
dict_decision_jury(etudid, formsemestre_id, with_decisions=xml_with_decisions)
)
d.update(dict_decision_jury(etud, formsemestre, with_decisions=xml_with_decisions))
# --- Appreciations
cnx = ndb.GetDBConnexion()
apprecs = sco_etud.appreciations_list(
@ -364,7 +363,9 @@ def formsemestre_bulletinetud_published_dict(
return d
def dict_decision_jury(etudid, formsemestre_id, with_decisions=False) -> dict:
def dict_decision_jury(
etud: Identite, formsemestre: FormSemestre, with_decisions: bool = False
) -> dict:
"""dict avec decision pour bulletins json
- decision : décision semestre
- decision_ue : list des décisions UE
@ -372,6 +373,8 @@ def dict_decision_jury(etudid, formsemestre_id, with_decisions=False) -> dict:
with_decision donne les décision même si bul_show_decision est faux.
Si formation APC, indique aussi validations année et RCUEs
Exemple:
{
'autorisation_inscription': [{'semestre_id': 4}],
@ -397,14 +400,14 @@ def dict_decision_jury(etudid, formsemestre_id, with_decisions=False) -> dict:
d = {}
if (
sco_preferences.get_preference("bul_show_decision", formsemestre_id)
sco_preferences.get_preference("bul_show_decision", formsemestre.id)
or with_decisions
):
infos, dpv = sco_bulletins.etud_descr_situation_semestre(
etudid,
formsemestre_id,
etud.id,
formsemestre.id,
show_uevalid=sco_preferences.get_preference(
"bul_show_uevalid", formsemestre_id
"bul_show_uevalid", formsemestre.id
),
)
d["situation"] = infos["situation"]
@ -456,4 +459,7 @@ def dict_decision_jury(etudid, formsemestre_id, with_decisions=False) -> dict:
)
else:
d["decision"] = dict(code="", etat="DEM")
# Ajout jury BUT:
if formsemestre.formation.is_apc():
d.update(but_validations.dict_decision_jury(etud, formsemestre))
return d

View File

@ -140,12 +140,23 @@ def process_field(field, cdict, style, suppress_empty_pars=False, format="pdf"):
text = (field or "") % scu.WrapDict(
cdict
) # note that None values are mapped to empty strings
except:
except KeyError as exc:
log(
f"""process_field: KeyError on field={field!r}
values={pprint.pformat(cdict)}
"""
)
if len(exc.args) > 0:
missing_field = exc.args[0]
text = f"""<para><i>format invalide: champs</i> {missing_field} <i>inexistant !</i></para>"""
except: # pylint: disable=bare-except
log(
f"""process_field: invalid format. field={field!r}
values={pprint.pformat(cdict)}
"""
)
# ne sera pas visible si lien vers pdf:
scu.flash_once(f"Attention: format PDF invalide (champs {field}")
text = (
"<para><i>format invalide !</i></para><para>"
+ traceback.format_exc()

View File

@ -231,7 +231,7 @@ def invalidate_formsemestre( # was inval_cache(formsemestre_id=None, pdfonly=Fa
"""expire cache pour un semestre (ou tous si formsemestre_id non spécifié).
Si pdfonly, n'expire que les bulletins pdf cachés.
"""
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus
if getattr(g, "defer_cache_invalidation", False):
g.sem_to_invalidate.add(formsemestre_id)
@ -252,7 +252,7 @@ def invalidate_formsemestre( # was inval_cache(formsemestre_id=None, pdfonly=Fa
else:
formsemestre_ids = [
formsemestre_id
] + sco_parcours_dut.list_formsemestre_utilisateurs_uecap(formsemestre_id)
] + sco_cursus.list_formsemestre_utilisateurs_uecap(formsemestre_id)
log(f"----- invalidate_formsemestre: clearing {formsemestre_ids} -----")
if not pdfonly:

View File

@ -216,7 +216,7 @@ def code_semestre_attente(code: str) -> bool:
def code_ue_validant(code: str) -> bool:
"Vrai si ce code entraine la validation des UEs du semestre."
"Vrai si ce code d'UE est validant (ie attribue les ECTS)"
return CODES_UE_VALIDES.get(code, False)

134
app/scodoc/sco_cursus.py Normal file
View File

@ -0,0 +1,134 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Gestion scolarite IUT
#
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Emmanuel Viennet emmanuel.viennet@viennet.net
#
##############################################################################
"""Gestion des cursus (jurys suivant la formation)
"""
from app.but import cursus_but
from app.scodoc import sco_cursus_dut
from app.comp.res_compat import NotesTableCompat
from app.comp import res_sem
from app.models import FormSemestre
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formations
import app.scodoc.notesdb as ndb
# SituationEtudParcours -> get_situation_etud_cursus
def get_situation_etud_cursus(
etud: dict, formsemestre_id: int
) -> sco_cursus_dut.SituationEtudCursus:
"""renvoie une instance de SituationEtudCursus (ou sous-classe spécialisée)"""
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
if formsemestre.formation.is_apc():
return cursus_but.SituationEtudCursusBUT(etud, formsemestre_id, nt)
parcours = nt.parcours
if parcours.ECTS_ONLY:
return sco_cursus_dut.SituationEtudCursusECTS(etud, formsemestre_id, nt)
return sco_cursus_dut.SituationEtudCursusClassic(etud, formsemestre_id, nt)
def formsemestre_get_etud_capitalisation(
formation_id: int, semestre_idx: int, date_debut, etudid: int
) -> list[dict]:
"""Liste des UE capitalisées (ADM) correspondant au semestre sem et à l'étudiant.
Recherche dans les semestres de la même formation (code) avec le même
semestre_id et une date de début antérieure à celle du semestre mentionné.
Et aussi les UE externes validées.
Resultat: [ { 'formsemestre_id' :
'ue_id' : ue_id dans le semestre origine
'ue_code' :
'moy_ue' :
'event_date' :
'is_external'
} ]
"""
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""
SELECT DISTINCT SFV.*, ue.ue_code
FROM notes_ue ue, notes_formations nf,
notes_formations nf2, scolar_formsemestre_validation SFV, notes_formsemestre sem
WHERE ue.formation_id = nf.id
and nf.formation_code = nf2.formation_code
and nf2.id=%(formation_id)s
and SFV.ue_id = ue.id
and SFV.code = 'ADM'
and SFV.etudid = %(etudid)s
and ( (sem.id = SFV.formsemestre_id
and sem.date_debut < %(date_debut)s
and sem.semestre_id = %(semestre_id)s )
or (
((SFV.formsemestre_id is NULL) OR (SFV.is_external)) -- les UE externes ou "anterieures"
AND (SFV.semestre_id is NULL OR SFV.semestre_id=%(semestre_id)s)
) )
""",
{
"etudid": etudid,
"formation_id": formation_id,
"semestre_id": semestre_idx,
"date_debut": date_debut,
},
)
return cursor.dictfetchall()
def list_formsemestre_utilisateurs_uecap(formsemestre_id):
"""Liste des formsemestres pouvant utiliser une UE capitalisee de ce semestre
(et qui doivent donc etre sortis du cache si l'on modifie ce
semestre): meme code formation, meme semestre_id, date posterieure"""
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT sem.id
FROM notes_formsemestre sem, notes_formations F
WHERE sem.formation_id = F.id
and F.formation_code = %(formation_code)s
and sem.semestre_id = %(semestre_id)s
and sem.date_debut >= %(date_debut)s
and sem.id != %(formsemestre_id)s;
""",
{
"formation_code": F["formation_code"],
"semestre_id": sem["semestre_id"],
"formsemestre_id": formsemestre_id,
"date_debut": ndb.DateDMYtoISO(sem["date_debut"]),
},
)
return [x[0] for x in cursor.fetchall()]

View File

@ -28,9 +28,10 @@
"""Semestres: gestion parcours DUT (Arreté du 13 août 2005)
"""
from app import db
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre, UniteEns
from app.models import FormSemestre, UniteEns, ScolarAutorisationInscription
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
@ -105,27 +106,14 @@ class DecisionSem(object):
)
)
)
# xxx debug
# log('%s: %s %s %s %s %s' % (self.codechoice,code_etat,new_code_prev,formsemestre_id_utilise_pour_compenser,devenir,assiduite) )
def SituationEtudParcours(etud: dict, formsemestre_id: int):
"""renvoie une instance de SituationEtudParcours (ou sous-classe spécialisée)"""
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
# if formsemestre.formation.is_apc():
# return SituationEtudParcoursBUT(etud, formsemestre_id, nt)
parcours = nt.parcours
#
if parcours.ECTS_ONLY:
return SituationEtudParcoursECTS(etud, formsemestre_id, nt)
else:
return SituationEtudParcoursGeneric(etud, formsemestre_id, nt)
class SituationEtudCursus:
"Semestre dans un cursus"
pass
class SituationEtudParcoursGeneric:
class SituationEtudCursusClassic(SituationEtudCursus):
"Semestre dans un parcours"
def __init__(self, etud: dict, formsemestre_id: int, nt: NotesTableCompat):
@ -353,9 +341,7 @@ class SituationEtudParcoursGeneric:
)[0]["formation_code"]
# si sem peut servir à compenser le semestre courant, positionne
# can_compensate
sem["can_compensate"] = check_compensation(
self.etudid, self.sem, self.nt, sem, nt
)
sem["can_compensate"] = self.check_compensation_dut(sem, nt)
self.ue_acros = list(ue_acros.keys())
self.ue_acros.sort()
@ -454,8 +440,7 @@ class SituationEtudParcoursGeneric:
break
if not cur or cur["formsemestre_id"] != self.formsemestre_id:
log(
"*** SituationEtudParcours: search_prev: cur not found (formsemestre_id=%s, etudid=%s)"
% (self.formsemestre_id, self.etudid)
f"*** SituationEtudCursus: search_prev: cur not found (formsemestre_id={self.formsemestre_id}, etudid={self.etudid})"
)
return None # pas de semestre courant !!!
# Cherche semestre antérieur de même formation (code) et semestre_id precedent
@ -633,31 +618,27 @@ class SituationEtudParcoursGeneric:
formsemestre_id=self.prev["formsemestre_id"]
) # > modif decisions jury (sem, UE)
# -- supprime autorisations venant de ce formsemestre
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
try:
cursor.execute(
"""delete from scolar_autorisation_inscription
where etudid = %(etudid)s and origin_formsemestre_id=%(origin_formsemestre_id)s
""",
{"etudid": self.etudid, "origin_formsemestre_id": self.formsemestre_id},
# -- Supprime autorisations venant de ce formsemestre
autorisations = ScolarAutorisationInscription.query.filter_by(
etudid=self.etudid, origin_formsemestre_id=self.formsemestre_id
)
# -- enregistre autorisations inscription
for autorisation in autorisations:
db.session.delete(autorisation)
db.session.flush()
# -- Enregistre autorisations inscription
next_semestre_ids = self.get_next_semestre_ids(decision.devenir)
for next_semestre_id in next_semestre_ids:
_scolar_autorisation_inscription_editor.create(
cnx,
{
"etudid": self.etudid,
"formation_code": self.formation.formation_code,
"semestre_id": next_semestre_id,
"origin_formsemestre_id": self.formsemestre_id,
},
autorisation = ScolarAutorisationInscription(
etudid=self.etudid,
formation_code=self.formation.formation_code,
semestre_id=next_semestre_id,
origin_formsemestre_id=self.formsemestre_id,
)
cnx.commit()
db.session.add(autorisation)
db.session.commit()
except:
cnx.rollback()
cnx.session.rollback()
raise
sco_cache.invalidate_formsemestre(
formsemestre_id=self.formsemestre_id
@ -672,12 +653,52 @@ class SituationEtudParcoursGeneric:
formsemestre_id=formsemestre_id
) # > modif decision jury
def check_compensation_dut(self, semc: dict, ntc: NotesTableCompat):
"""Compensations DUT
Vérifie si le semestre sem peut se compenser en utilisant semc
- semc non utilisé par un autre semestre
- decision du jury prise ADM ou ADJ ou ATT ou ADC
- barres UE (moy ue > 8) dans sem et semc
- moyenne des moy_gen > 10
Return boolean
"""
# -- deja utilise ?
decc = ntc.get_etud_decision_sem(self.etudid)
if (
decc
and decc["compense_formsemestre_id"]
and decc["compense_formsemestre_id"] != self.sem["formsemestre_id"]
):
return False
# -- semestres consecutifs ?
if abs(self.sem["semestre_id"] - semc["semestre_id"]) != 1:
return False
# -- decision jury:
if decc and not decc["code"] in (ADM, ADJ, ATT, ADC):
return False
# -- barres UE et moyenne des moyennes:
moy_gen = self.nt.get_etud_moy_gen(self.etudid)
moy_genc = ntc.get_etud_moy_gen(self.etudid)
try:
moy_moy = (moy_gen + moy_genc) / 2
except: # un des semestres sans aucune note !
return False
class SituationEtudParcoursECTS(SituationEtudParcoursGeneric):
if (
self.nt.etud_check_conditions_ues(self.etudid)[0]
and ntc.etud_check_conditions_ues(self.etudid)[0]
and moy_moy >= NOTES_BARRE_GEN_COMPENSATION
):
return True
else:
return False
class SituationEtudCursusECTS(SituationEtudCursusClassic):
"""Gestion parcours basés sur ECTS"""
def __init__(self, etud, formsemestre_id, nt):
SituationEtudParcoursGeneric.__init__(self, etud, formsemestre_id, nt)
SituationEtudCursusClassic.__init__(self, etud, formsemestre_id, nt)
def could_be_compensated(self):
return False # jamais de compensations dans ce parcours
@ -718,47 +739,6 @@ class SituationEtudParcoursECTS(SituationEtudParcoursGeneric):
return choices
#
def check_compensation(etudid, sem, nt, semc, ntc):
"""Verifie si le semestre sem peut se compenser en utilisant semc
- semc non utilisé par un autre semestre
- decision du jury prise ADM ou ADJ ou ATT ou ADC
- barres UE (moy ue > 8) dans sem et semc
- moyenne des moy_gen > 10
Return boolean
"""
# -- deja utilise ?
decc = ntc.get_etud_decision_sem(etudid)
if (
decc
and decc["compense_formsemestre_id"]
and decc["compense_formsemestre_id"] != sem["formsemestre_id"]
):
return False
# -- semestres consecutifs ?
if abs(sem["semestre_id"] - semc["semestre_id"]) != 1:
return False
# -- decision jury:
if decc and not decc["code"] in (ADM, ADJ, ATT, ADC):
return False
# -- barres UE et moyenne des moyennes:
moy_gen = nt.get_etud_moy_gen(etudid)
moy_genc = ntc.get_etud_moy_gen(etudid)
try:
moy_moy = (moy_gen + moy_genc) / 2
except: # un des semestres sans aucune note !
return False
if (
nt.etud_check_conditions_ues(etudid)[0]
and ntc.etud_check_conditions_ues(etudid)[0]
and moy_moy >= NOTES_BARRE_GEN_COMPENSATION
):
return True
else:
return False
# -------------------------------------------------------------------------------------------
@ -1032,102 +1012,3 @@ def etud_est_inscrit_ue(cnx, etudid, formsemestre_id, ue_id):
)
return len(cursor.fetchall())
_scolar_autorisation_inscription_editor = ndb.EditableTable(
"scolar_autorisation_inscription",
"autorisation_inscription_id",
("etudid", "formation_code", "semestre_id", "date", "origin_formsemestre_id"),
output_formators={"date": ndb.DateISOtoDMY},
input_formators={"date": ndb.DateDMYtoISO},
)
scolar_autorisation_inscription_list = _scolar_autorisation_inscription_editor.list
def formsemestre_get_autorisation_inscription(etudid, origin_formsemestre_id):
"""Liste des autorisations d'inscription pour cet étudiant
émanant du semestre indiqué.
"""
cnx = ndb.GetDBConnexion()
return scolar_autorisation_inscription_list(
cnx, {"origin_formsemestre_id": origin_formsemestre_id, "etudid": etudid}
)
def formsemestre_get_etud_capitalisation(
formation_id: int, semestre_idx: int, date_debut, etudid: int
) -> list[dict]:
"""Liste des UE capitalisées (ADM) correspondant au semestre sem et à l'étudiant.
Recherche dans les semestres de la même formation (code) avec le même
semestre_id et une date de début antérieure à celle du semestre mentionné.
Et aussi les UE externes validées.
Resultat: [ { 'formsemestre_id' :
'ue_id' : ue_id dans le semestre origine
'ue_code' :
'moy_ue' :
'event_date' :
'is_external'
} ]
"""
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""
SELECT DISTINCT SFV.*, ue.ue_code
FROM notes_ue ue, notes_formations nf,
notes_formations nf2, scolar_formsemestre_validation SFV, notes_formsemestre sem
WHERE ue.formation_id = nf.id
and nf.formation_code = nf2.formation_code
and nf2.id=%(formation_id)s
and SFV.ue_id = ue.id
and SFV.code = 'ADM'
and SFV.etudid = %(etudid)s
and ( (sem.id = SFV.formsemestre_id
and sem.date_debut < %(date_debut)s
and sem.semestre_id = %(semestre_id)s )
or (
((SFV.formsemestre_id is NULL) OR (SFV.is_external)) -- les UE externes ou "anterieures"
AND (SFV.semestre_id is NULL OR SFV.semestre_id=%(semestre_id)s)
) )
""",
{
"etudid": etudid,
"formation_id": formation_id,
"semestre_id": semestre_idx,
"date_debut": date_debut,
},
)
return cursor.dictfetchall()
def list_formsemestre_utilisateurs_uecap(formsemestre_id):
"""Liste des formsemestres pouvant utiliser une UE capitalisee de ce semestre
(et qui doivent donc etre sortis du cache si l'on modifie ce
semestre): meme code formation, meme semestre_id, date posterieure"""
cnx = ndb.GetDBConnexion()
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
F = sco_formations.formation_list(args={"formation_id": sem["formation_id"]})[0]
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute(
"""SELECT sem.id
FROM notes_formsemestre sem, notes_formations F
WHERE sem.formation_id = F.id
and F.formation_code = %(formation_code)s
and sem.semestre_id = %(semestre_id)s
and sem.date_debut >= %(date_debut)s
and sem.id != %(formsemestre_id)s;
""",
{
"formation_code": F["formation_code"],
"semestre_id": sem["semestre_id"],
"formsemestre_id": formsemestre_id,
"date_debut": ndb.DateDMYtoISO(sem["date_debut"]),
},
)
return [x[0] for x in cursor.fetchall()]

View File

@ -31,6 +31,7 @@ from flask import g, request
from flask_login import current_user
from app import db
from app.but import apc_edit_ue
from app.models import Formation, UniteEns, Matiere, Module, FormSemestre, ModuleImpl
from app.models.validations import ScolarFormSemestreValidation
from app.scodoc.sco_codes_parcours import UE_SPORT
@ -109,6 +110,7 @@ def html_edit_formation_apc(
icons=icons,
ues_by_sem=ues_by_sem,
ects_by_sem=ects_by_sem,
form_ue_choix_niveau=apc_edit_ue.form_ue_choix_niveau,
),
]
for semestre_idx in semestre_ids:

View File

@ -292,21 +292,25 @@ def do_formation_create(args):
def do_formation_edit(args):
"edit a formation"
# log('do_formation_edit( args=%s )'%args)
# On autorise la modif de la formation meme si elle est verrouillee
# car cela ne change que du cosmetique, (sauf eventuellement le code formation ?)
# mais si verrouillée on ne peut changer le type de parcours
if sco_formations.formation_has_locked_sems(args["formation_id"]):
if "type_parcours" in args:
del args["type_parcours"]
# On ne peut jamais supprimer le code formation:
if "formation_code" in args and not args["formation_code"]:
del args["formation_code"]
cnx = ndb.GetDBConnexion()
sco_formations._formationEditor.edit(cnx, args)
formation: Formation = Formation.query.get(args["formation_id"])
formation: Formation = Formation.query.get_or_404(args["formation_id"])
# On autorise la modif de la formation meme si elle est verrouillee
# car cela ne change que du cosmetique, (sauf eventuellement le code formation ?)
# mais si verrouillée on ne peut changer le type de parcours
if formation.has_locked_sems():
if "type_parcours" in args:
del args["type_parcours"]
for field in formation.__dict__:
if field and field[0] != "_" and field in args:
setattr(formation, field, args[field])
db.session.add(formation)
db.session.commit()
formation.invalidate_cached_sems()

View File

@ -140,7 +140,7 @@ def do_ue_create(args):
def do_ue_delete(ue_id, delete_validations=False, force=False):
"delete UE and attached matieres (but not modules)"
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus_dut
ue = UniteEns.query.get_or_404(ue_id)
formation = ue.formation
@ -164,7 +164,7 @@ def do_ue_delete(ue_id, delete_validations=False, force=False):
# raise ScoLockedFormError()
# Il y a-t-il des etudiants ayant validé cette UE ?
# si oui, propose de supprimer les validations
validations = sco_parcours_dut.scolar_formsemestre_validation_list(
validations = sco_cursus_dut.scolar_formsemestre_validation_list(
cnx, args={"ue_id": ue.id}
)
if validations and not delete_validations and not force:
@ -466,7 +466,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
+ ue_div
+ html_sco_header.sco_footer()
)
elif tf[2]:
elif tf[0] == 1:
if create:
if not tf[2]["ue_code"]:
del tf[2]["ue_code"]
@ -684,6 +684,7 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""): # was ue_list
javascripts=[
"libjs/jinplace-1.2.1.min.js",
"js/ue_list.js",
"js/edit_ue.js",
"libjs/jQuery-tagEditor/jquery.tag-editor.min.js",
"libjs/jQuery-tagEditor/jquery.caret.min.js",
"js/module_tag_editor.js",

View File

@ -45,6 +45,7 @@ from openpyxl.worksheet.worksheet import Worksheet
import app.scodoc.sco_utils as scu
from app import log
from app.scodoc.sco_exceptions import ScoValueError
from app.scodoc import notesdb, sco_preferences
class COLORS(Enum):
@ -793,7 +794,7 @@ def excel_feuille_listeappel(
# ligne 3
cell_2 = ws.make_cell("Enseignant :", style2)
cell_6 = ws.make_cell(("Groupe %s" % groupname), style3)
cell_6 = ws.make_cell(f"Groupe {groupname}", style3)
ws.append_row([None, cell_2, None, None, None, None, cell_6])
# ligne 4: Avertissement pour ne pas confondre avec listes notes

View File

@ -101,7 +101,7 @@ def get_formsemestre(formsemestre_id, raise_soft_exc=False):
return g.stored_get_formsemestre[formsemestre_id]
if not isinstance(formsemestre_id, int):
log(f"get_formsemestre: invalid id '{formsemestre_id}'")
raise ScoInvalidIdType("formsemestre_id must be an integer !")
raise ScoInvalidIdType("get_formsemestre: formsemestre_id must be an integer !")
sems = do_formsemestre_list(args={"formsemestre_id": formsemestre_id})
if not sems:
log("get_formsemestre: invalid formsemestre_id (%s)" % formsemestre_id)

View File

@ -60,7 +60,7 @@ from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups_copy
from app.scodoc import sco_modalites
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus_dut
from app.scodoc import sco_permissions_check
from app.scodoc import sco_portal_apogee
from app.scodoc import sco_preferences
@ -1362,14 +1362,14 @@ def _reassociate_moduleimpls(cnx, formsemestre_id, ues_old2new, modules_old2new)
if e["ue_id"]:
e["ue_id"] = ues_old2new[e["ue_id"]]
sco_etud.scolar_events_edit(cnx, e)
validations = sco_parcours_dut.scolar_formsemestre_validation_list(
validations = sco_cursus_dut.scolar_formsemestre_validation_list(
cnx, args={"formsemestre_id": formsemestre_id}
)
for e in validations:
if e["ue_id"]:
e["ue_id"] = ues_old2new[e["ue_id"]]
# log('e=%s' % e )
sco_parcours_dut.scolar_formsemestre_validation_edit(cnx, e)
sco_cursus_dut.scolar_formsemestre_validation_edit(cnx, e)
def formsemestre_delete(formsemestre_id):

View File

@ -51,7 +51,7 @@ from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_formsemestre_validation
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus_dut
from app.scodoc import sco_etud
@ -450,7 +450,7 @@ def _list_ue_with_coef_and_validations(sem, etudid):
else:
ue["uecoef"] = {}
# add validation
validation = sco_parcours_dut.scolar_formsemestre_validation_list(
validation = sco_cursus_dut.scolar_formsemestre_validation_list(
cnx,
args={
"formsemestre_id": formsemestre_id,

View File

@ -59,8 +59,9 @@ from app.scodoc import sco_edit_ue
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_parcours_dut
from app.scodoc.sco_parcours_dut import etud_est_inscrit_ue
from app.scodoc import sco_cursus
from app.scodoc import sco_cursus_dut
from app.scodoc.sco_cursus_dut import etud_est_inscrit_ue
from app.scodoc import sco_photos
from app.scodoc import sco_preferences
from app.scodoc import sco_pvjury
@ -108,7 +109,7 @@ def formsemestre_validation_etud_form(
check = True
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
Se = sco_cursus.get_situation_etud_cursus(etud, formsemestre_id)
if not Se.sem["etat"]:
raise ScoValueError("validation: semestre verrouille")
@ -274,15 +275,12 @@ def formsemestre_validation_etud_form(
ass = "non assidu"
H.append("<p>Décision existante du %(event_date)s: %(code)s" % decision_jury)
H.append(" (%s)" % ass)
auts = sco_parcours_dut.formsemestre_get_autorisation_inscription(
etudid, formsemestre_id
)
if auts:
autorisations = ScolarAutorisationInscription.query.filter_by(
etudid=etudid, origin_formsemestre_id=formsemestre_id
).all()
if autorisations:
H.append(". Autorisé%s à s'inscrire en " % etud["ne"])
alist = []
for aut in auts:
alist.append(str(aut["semestre_id"]))
H.append(", ".join(["S%s" % x for x in alist]) + ".")
H.append(", ".join([f"S{aut.semestre_id}" for aut in autorisations]) + ".")
H.append("</p>")
# Cas particulier pour ATJ: corriger precedent avant de continuer
@ -382,7 +380,7 @@ def formsemestre_validation_etud(
):
"""Enregistre validation"""
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
Se = sco_cursus.get_situation_etud_cursus(etud, formsemestre_id)
# retrouve la decision correspondant au code:
choices = Se.get_possible_choices(assiduite=True)
choices += Se.get_possible_choices(assiduite=False)
@ -415,7 +413,7 @@ def formsemestre_validation_etud_manu(
if assidu:
assidu = True
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
Se = sco_cursus.get_situation_etud_cursus(etud, formsemestre_id)
if code_etat in Se.parcours.UNUSED_CODES:
raise ScoValueError("code decision invalide dans ce parcours")
# Si code ADC, extrait le semestre utilisé:
@ -430,7 +428,7 @@ def formsemestre_validation_etud_manu(
formsemestre_id_utilise_pour_compenser = None
# Construit le choix correspondant:
choice = sco_parcours_dut.DecisionSem(
choice = sco_cursus_dut.DecisionSem(
code_etat=code_etat,
new_code_prev=new_code_prev,
devenir=devenir,
@ -910,7 +908,7 @@ def do_formsemestre_validation_auto(formsemestre_id):
conflicts = [] # liste des etudiants avec decision differente déjà saisie
for etudid in etudids:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
Se = sco_cursus.get_situation_etud_cursus(etud, formsemestre_id)
ins = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
{"etudid": etudid, "formsemestre_id": formsemestre_id}
)[0]
@ -932,15 +930,13 @@ def do_formsemestre_validation_auto(formsemestre_id):
if decision_sem and decision_sem["code"] != ADM:
ok = False
conflicts.append(etud)
autorisations = sco_parcours_dut.formsemestre_get_autorisation_inscription(
etudid, formsemestre_id
)
if (
len(autorisations) != 0
): # accepte le cas ou il n'y a pas d'autorisation : BUG 23/6/7, A RETIRER ENSUITE
autorisations = ScolarAutorisationInscription.query.filter_by(
etudid=etudid, origin_formsemestre_id=formsemestre_id
).all()
if len(autorisations) != 0:
if (
len(autorisations) != 1
or autorisations[0]["semestre_id"] != next_semestre_id
len(autorisations) > 1
or autorisations[0].semestre_id != next_semestre_id
):
if ok:
conflicts.append(etud)
@ -1176,7 +1172,7 @@ def do_formsemestre_validate_previous_ue(
)
else:
sco_formsemestre.do_formsemestre_uecoef_delete(cnx, formsemestre_id, ue_id)
sco_parcours_dut.do_formsemestre_validate_ue(
sco_cursus_dut.do_formsemestre_validate_ue(
cnx,
nt,
formsemestre_id, # "importe" cette UE dans le semestre (new 3/2015)

View File

@ -56,8 +56,9 @@ import app.scodoc.notesdb as ndb
from app import log, cache
from app.scodoc.scolog import logdb
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_cache
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_cursus
from app.scodoc import sco_etud
from app.scodoc import sco_permissions_check
from app.scodoc import sco_xml
@ -1489,13 +1490,13 @@ def _get_prev_moy(etudid, formsemestre_id):
"""Donne la derniere moyenne generale calculee pour cette étudiant,
ou 0 si on n'en trouve pas (nouvel inscrit,...).
"""
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus_dut
info = sco_etud.get_etud_info(etudid=etudid, filled=True)
if not info:
raise ScoValueError("etudiant invalide: etudid=%s" % etudid)
etud = info[0]
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
Se = sco_cursus.get_situation_etud_cursus(etud, formsemestre_id)
if Se.prev:
prev_sem = FormSemestre.query.get(Se.prev["formsemestre_id"])
nt: NotesTableCompat = res_sem.load_formsemestre_results(prev_sem)

View File

@ -49,7 +49,7 @@ from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus
from app.scodoc import sco_portal_apogee
from app.scodoc import sco_preferences
from app.scodoc import sco_etud
@ -776,7 +776,7 @@ def groups_table(
m.update(etud)
sco_etud.etud_add_lycee_infos(etud)
# et ajoute le parcours
Se = sco_parcours_dut.SituationEtudParcours(
Se = sco_cursus.get_situation_etud_cursus(
etud, groups_infos.formsemestre_id
)
m["parcours"] = Se.get_parcours_descr()

View File

@ -121,7 +121,8 @@ def _list_dept_logos(dept_id=None, prefix=scu.LOGO_FILE_PREFIX):
:return: le résultat de la recherche ou None si aucune image trouvée
"""
allowed_ext = "|".join(scu.LOGOS_IMAGES_ALLOWED_TYPES)
filename_parser = re.compile(f"{prefix}([^.]*).({allowed_ext})")
# parse filename 'logo_<logoname>.<ext> . be carefull: logoname may include '.'
filename_parser = re.compile(f"{prefix}(([^.]*.)+)({allowed_ext})")
logos = {}
path_dir = Path(scu.SCODOC_LOGOS_DIR)
if dept_id:
@ -135,7 +136,7 @@ def _list_dept_logos(dept_id=None, prefix=scu.LOGO_FILE_PREFIX):
if os.access(path_dir.joinpath(entry).absolute(), os.R_OK):
result = filename_parser.match(entry.name)
if result:
logoname = result.group(1)
logoname = result.group(1)[:-1] # retreive logoname from filename (less final dot)
logos[logoname] = Logo(logoname=logoname, dept_id=dept_id).select()
return logos if len(logos.keys()) > 0 else None
@ -191,6 +192,9 @@ class Logo:
)
self.mm = "Not initialized: call the select or create function before access"
def __repr__(self) -> str:
return f"Logo(logoname='{self.logoname}', filename='{self.filename}')"
def _set_format(self, fmt):
self.suffix = fmt
self.filepath = self.basepath + "." + fmt

View File

@ -39,7 +39,7 @@ from app.models import ModuleImpl
from app.models.evaluations import Evaluation
import app.scodoc.sco_utils as scu
from app.scodoc.sco_exceptions import ScoInvalidIdType
from app.scodoc.sco_parcours_dut import formsemestre_has_decisions
from app.scodoc.sco_cursus_dut import formsemestre_has_decisions
from app.scodoc.sco_permissions import Permission
from app.scodoc import html_sco_header

View File

@ -46,7 +46,7 @@ from app.scodoc import sco_codes_parcours
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_status
from app.scodoc import sco_groups
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus
from app.scodoc import sco_permissions_check
from app.scodoc import sco_photos
from app.scodoc import sco_users
@ -269,7 +269,7 @@ def ficheEtud(etudid=None):
sem_info[sem["formsemestre_id"]] = grlink
if info["sems"]:
Se = sco_parcours_dut.SituationEtudParcours(etud, info["last_formsemestre_id"])
Se = sco_cursus.get_situation_etud_cursus(etud, info["last_formsemestre_id"])
info["liste_inscriptions"] = formsemestre_recap_parcours_table(
Se,
etudid,

View File

@ -55,6 +55,7 @@ from reportlab.lib import styles
from flask import g
from app.scodoc import sco_utils as scu
from app.scodoc.sco_utils import CONFIG
from app import log
from app.scodoc.sco_exceptions import ScoGenError, ScoValueError
@ -67,7 +68,7 @@ PAGE_WIDTH = defaultPageSize[0]
DEFAULT_PDF_FOOTER_TEMPLATE = CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE
def SU(s):
def SU(s: str) -> str:
"convert s from string to string suitable for ReportLab"
if not s:
return ""
@ -145,9 +146,9 @@ def makeParas(txt, style, suppress_empty=False):
) from e
else:
raise e
except Exception as e:
except Exception as exc:
log(traceback.format_exc())
log("Invalid pdf para format: %s" % txt)
log(f"Invalid pdf para format: {txt}")
try:
result = [
Paragraph(
@ -155,13 +156,14 @@ def makeParas(txt, style, suppress_empty=False):
style,
)
]
except ValueError as e: # probleme font ? essaye sans style
except ValueError as exc2: # probleme font ? essaye sans style
# recupere font en cause ?
m = re.match(r".*family/bold/italic for (.*)", e.args[0], re.DOTALL)
if m:
message = f"police non disponible: {m[1]}"
else:
message = "format invalide"
scu.flash_once(f"problème génération PDF: {message}")
return [
Paragraph(
SU(f'<font color="red"><b>Erreur: {message}</b></font>'),

View File

@ -24,14 +24,14 @@ def can_edit_notes(authuser, moduleimpl_id, allow_ens=True):
seul le directeur des études peut saisir des notes (et il ne devrait pas).
"""
from app.scodoc import sco_formsemestre
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus_dut
M = sco_moduleimpl.moduleimpl_list(moduleimpl_id=moduleimpl_id)[0]
sem = sco_formsemestre.get_formsemestre(M["formsemestre_id"])
if not sem["etat"]:
return False # semestre verrouillé
if sco_parcours_dut.formsemestre_has_decisions(sem["formsemestre_id"]):
if sco_cursus_dut.formsemestre_has_decisions(sem["formsemestre_id"]):
# il y a des décisions de jury dans ce semestre !
return (
authuser.has_permission(Permission.ScoEditAllNotes)

View File

@ -37,14 +37,14 @@ from flask_login import current_user
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre, Identite
from app.models import FormSemestre, Identite, ScolarAutorisationInscription
from app.scodoc import sco_abs
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_groups
from app.scodoc import sco_etud
from app.scodoc import sco_excel
from app.scodoc import sco_formsemestre
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cursus
from app.scodoc import sco_preferences
import app.scodoc.sco_utils as scu
import sco_version
@ -78,7 +78,7 @@ def feuille_preparation_jury(formsemestre_id):
nbabs = {}
nbabsjust = {}
for etud in etuds:
Se = sco_parcours_dut.SituationEtudParcours(
Se = sco_cursus.get_situation_etud_cursus(
etud.to_dict_scodoc7(), formsemestre_id
)
if Se.prev:
@ -103,14 +103,14 @@ def feuille_preparation_jury(formsemestre_id):
moy[etud.id] = nt.get_etud_moy_gen(etud.id)
for ue in nt.get_ues_stat_dict(filter_sport=True):
ue_status = nt.get_etud_ue_status(etud.id, ue["ue_id"])
ue_code_s = ue["ue_code"] + "_%s" % nt.sem["semestre_id"]
ue_code_s = f'{ue["ue_code"]}_{nt.sem["semestre_id"]}'
moy_ue[ue_code_s][etud.id] = ue_status["moy"] if ue_status else ""
ue_acro[ue_code_s] = (ue["numero"], ue["acronyme"], ue["titre"])
if Se.prev:
try:
moy_inter[etud.id] = (moy[etud.id] + prev_moy[etud.id]) / 2.0
except:
except (KeyError, TypeError):
pass
decision = nt.get_etud_decision_sem(etud.id)
@ -119,10 +119,13 @@ def feuille_preparation_jury(formsemestre_id):
if decision["compense_formsemestre_id"]:
code[etud.id] += "+" # indique qu'il a servi a compenser
assidu[etud.id] = {False: "Non", True: "Oui"}.get(decision["assidu"], "")
aut_list = sco_parcours_dut.formsemestre_get_autorisation_inscription(
etud.id, formsemestre_id
autorisations_etud = ScolarAutorisationInscription.query.filter_by(
etudid=etud.id, origin_formsemestre_id=formsemestre_id
).all()
autorisations[etud.id] = ", ".join(
[f"S{x.semestre_id}" for x in autorisations_etud]
)
autorisations[etud.id] = ", ".join(["S%s" % x["semestre_id"] for x in aut_list])
# parcours:
parcours[etud.id] = Se.get_parcours_descr()
# groupe principal (td)
@ -153,11 +156,11 @@ def feuille_preparation_jury(formsemestre_id):
sid = sem["semestre_id"]
sn = sp = ""
if sid >= 0:
sn = "S%s" % sid
sn = f"S{sid}"
if prev_moy: # si qq chose dans precedent
sp = "S%s" % (sid - 1)
sp = f"S{sid - 1}"
ws = sco_excel.ScoExcelSheet(sheet_name="Prepa Jury %s" % sn)
sheet = sco_excel.ScoExcelSheet(sheet_name=f"Prepa Jury {sn}")
# génération des styles
style_bold = sco_excel.excel_make_style(size=10, bold=True)
style_center = sco_excel.excel_make_style(halign="center")
@ -173,10 +176,10 @@ def feuille_preparation_jury(formsemestre_id):
)
# Première ligne
ws.append_single_cell_row(
sheet.append_single_cell_row(
"Feuille préparation Jury %s" % scu.unescape_html(sem["titreannee"]), style_bold
)
ws.append_blank_row()
sheet.append_blank_row()
# Ligne de titre
titles = ["Rang"]
@ -198,25 +201,25 @@ def feuille_preparation_jury(formsemestre_id):
]
if prev_moy: # si qq chose dans precedent
titles += [prev_ue_acro[x][1] for x in ue_prev_codes] + [
"Moy %s" % sp,
"Décision %s" % sp,
f"Moy {sp}",
f"Décision {sp}",
]
titles += [ue_acro[x][1] for x in ue_codes] + ["Moy %s" % sn]
titles += [ue_acro[x][1] for x in ue_codes] + [f"Moy {sn}"]
if moy_inter:
titles += ["Moy %s-%s" % (sp, sn)]
titles += [f"Moy {sp}-{sn}"]
titles += ["Abs", "Abs Injust."]
if code:
titles.append("Proposit. %s" % sn)
titles.append("Proposit. {sn}")
if autorisations:
titles.append("Autorisations")
# titles.append('Assidu')
ws.append_row(ws.make_row(titles, style_boldcenter))
if prev_moy:
tit_prev_moy = "Moy " + sp
col_prev_moy = titles.index(tit_prev_moy)
tit_moy = "Moy " + sn
col_moy = titles.index(tit_moy)
col_abs = titles.index("Abs")
sheet.append_row(sheet.make_row(titles, style_boldcenter))
# if prev_moy:
# tit_prev_moy = "Moy " + sp
# # col_prev_moy = titles.index(tit_prev_moy)
# tit_moy = "Moy " + sn
# col_moy = titles.index(tit_moy)
# col_abs = titles.index("Abs")
def fmt(x):
"reduit les notes a deux chiffres"
@ -229,13 +232,13 @@ def feuille_preparation_jury(formsemestre_id):
i = 1 # numero etudiant
for etud in etuds:
cells = []
cells.append(ws.make_cell(str(i)))
cells.append(sheet.make_cell(str(i)))
if sco_preferences.get_preference("prepa_jury_nip"):
cells.append(ws.make_cell(etud.code_nip))
cells.append(sheet.make_cell(etud.code_nip))
if sco_preferences.get_preference("prepa_jury_ine"):
cells.append(ws.make_cell(etud.code_ine))
cells.append(sheet.make_cell(etud.code_ine))
admission = etud.admission.first()
cells += ws.make_row(
cells += sheet.make_row(
[
etud.id,
etud.civilite_str,
@ -253,50 +256,52 @@ def feuille_preparation_jury(formsemestre_id):
if prev_moy:
for ue_acro in ue_prev_codes:
cells.append(
ws.make_cell(
sheet.make_cell(
fmt(prev_moy_ue.get(ue_acro, {}).get(etud.id, "")), style_note
)
)
co += 1
cells.append(
ws.make_cell(fmt(prev_moy.get(etud.id, "")), style_bold)
sheet.make_cell(fmt(prev_moy.get(etud.id, "")), style_bold)
) # moy gen prev
cells.append(
ws.make_cell(fmt(prev_code.get(etud.id, "")), style_moy)
sheet.make_cell(fmt(prev_code.get(etud.id, "")), style_moy)
) # decision prev
co += 2
for ue_acro in ue_codes:
cells.append(
ws.make_cell(fmt(moy_ue.get(ue_acro, {}).get(etud.id, "")), style_note)
sheet.make_cell(
fmt(moy_ue.get(ue_acro, {}).get(etud.id, "")), style_note
)
)
co += 1
cells.append(
ws.make_cell(fmt(moy.get(etud.id, "")), style_note_bold)
sheet.make_cell(fmt(moy.get(etud.id, "")), style_note_bold)
) # moy gen
co += 1
if moy_inter:
cells.append(ws.make_cell(fmt(moy_inter.get(etud.id, "")), style_note))
cells.append(ws.make_cell(str(nbabs.get(etud.id, "")), style_center))
cells.append(ws.make_cell(str(nbabsjust.get(etud.id, "")), style_center))
cells.append(sheet.make_cell(fmt(moy_inter.get(etud.id, "")), style_note))
cells.append(sheet.make_cell(str(nbabs.get(etud.id, "")), style_center))
cells.append(sheet.make_cell(str(nbabsjust.get(etud.id, "")), style_center))
if code:
cells.append(ws.make_cell(code.get(etud.id, ""), style_moy))
cells.append(ws.make_cell(autorisations.get(etud.id, ""), style_moy))
cells.append(sheet.make_cell(code.get(etud.id, ""), style_moy))
cells.append(sheet.make_cell(autorisations.get(etud.id, ""), style_moy))
# l.append(assidu.get(etud.id, ''))
ws.append_row(cells)
sheet.append_row(cells)
i += 1
#
ws.append_blank_row()
sheet.append_blank_row()
# Explications des codes
codes = list(sco_codes_parcours.CODES_EXPL.keys())
codes.sort()
ws.append_single_cell_row("Explication des codes")
sheet.append_single_cell_row("Explication des codes")
for code in codes:
ws.append_row(
ws.make_row(["", "", "", code, sco_codes_parcours.CODES_EXPL[code]])
sheet.append_row(
sheet.make_row(["", "", "", code, sco_codes_parcours.CODES_EXPL[code]])
)
ws.append_row(
ws.make_row(
sheet.append_row(
sheet.make_row(
[
"",
"",
@ -307,16 +312,16 @@ def feuille_preparation_jury(formsemestre_id):
)
)
# UE : Correspondances acronyme et titre complet
ws.append_blank_row()
ws.append_single_cell_row("Titre des UE")
sheet.append_blank_row()
sheet.append_single_cell_row("Titre des UE")
if prev_moy:
for ue in ntp.get_ues_stat_dict(filter_sport=True):
ws.append_row(ws.make_row(["", "", "", ue["acronyme"], ue["titre"]]))
sheet.append_row(sheet.make_row(["", "", "", ue["acronyme"], ue["titre"]]))
for ue in nt.get_ues_stat_dict(filter_sport=True):
ws.append_row(ws.make_row(["", "", "", ue["acronyme"], ue["titre"]]))
sheet.append_row(sheet.make_row(["", "", "", ue["acronyme"], ue["titre"]]))
#
ws.append_blank_row()
ws.append_single_cell_row(
sheet.append_blank_row()
sheet.append_single_cell_row(
"Préparé par %s le %s sur %s pour %s"
% (
sco_version.SCONAME,
@ -325,7 +330,7 @@ def feuille_preparation_jury(formsemestre_id):
current_user,
)
)
xls = ws.generate()
xls = sheet.generate()
flash("Feuille préparation jury générée")
return scu.send_file(
xls,

View File

@ -57,32 +57,38 @@ from flask import g, request
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre, UniteEns
from app.models import (
FormSemestre,
UniteEns,
ScolarAutorisationInscription,
but_validations,
)
from app.models.etudiants import Identite
import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb
from app import log
from app.scodoc import html_sco_header
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_cache
from app.scodoc import sco_cursus
from app.scodoc import sco_cursus_dut
from app.scodoc import sco_edit_ue
from app.scodoc import sco_etud
from app.scodoc import sco_formations
from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups
from app.scodoc import sco_groups_view
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_pdf
from app.scodoc import sco_preferences
from app.scodoc import sco_pvpdf
from app.scodoc import sco_etud
from app.scodoc.gen_tables import GenTable
from app.scodoc.sco_codes_parcours import NO_SEMESTRE_ID
from app.scodoc.sco_pdf import PDFLOCK
from app.scodoc.TrivialFormulator import TrivialFormulator
def _descr_decisions_ues(nt, etudid, decisions_ue, decision_sem):
"""Liste des UE validées dans ce semestre"""
def _descr_decisions_ues(nt, etudid, decisions_ue, decision_sem) -> list[dict]:
"""Liste des UE validées dans ce semestre (incluant les UE capitalisées)"""
if not decisions_ue:
return []
uelist = []
@ -90,17 +96,20 @@ def _descr_decisions_ues(nt, etudid, decisions_ue, decision_sem):
for ue_id in decisions_ue.keys():
try:
if decisions_ue[ue_id] and (
decisions_ue[ue_id]["code"] == sco_codes_parcours.ADM
sco_codes_parcours.code_ue_validant(decisions_ue[ue_id]["code"])
or (
# XXX ceci devrait dépendre du parcours et non pas être une option ! #sco8
scu.CONFIG.CAPITALIZE_ALL_UES
decision_sem
and scu.CONFIG.CAPITALIZE_ALL_UES
and sco_codes_parcours.code_semestre_validant(decision_sem["code"])
)
):
ue = sco_edit_ue.ue_list(args={"ue_id": ue_id})[0]
uelist.append(ue)
except:
log("descr_decisions_ues: ue_id=%s decisions_ue=%s" % (ue_id, decisions_ue))
log(
f"Exception in descr_decisions_ues: ue_id={ue_id} decisions_ue={decisions_ue}"
)
# Les UE capitalisées dans d'autres semestres:
if etudid in nt.validations.ue_capitalisees.index:
for ue_id in nt.validations.ue_capitalisees.loc[[etudid]]["ue_id"]:
@ -138,12 +147,9 @@ def _descr_decision_sem_abbrev(etat, decision_sem):
return decision
def descr_autorisations(autorisations):
def descr_autorisations(autorisations: list[ScolarAutorisationInscription]) -> str:
"résumé textuel des autorisations d'inscription (-> 'S1, S3' )"
alist = []
for aut in autorisations:
alist.append("S" + str(aut["semestre_id"]))
return ", ".join(alist)
return ", ".join([f"S{a.semestre_id}" for a in autorisations])
def _comp_ects_by_ue_code(nt, decision_ues):
@ -233,8 +239,11 @@ def dict_pvjury(
L = []
D = {} # même chose que L, mais { etudid : dec }
for etudid in etudids:
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
Se = sco_parcours_dut.SituationEtudParcours(etud, formsemestre_id)
# etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0]
etud: Identite = Identite.query.get(etudid)
Se = sco_cursus.get_situation_etud_cursus(
etud.to_dict_scodoc7(), formsemestre_id
)
semestre_non_terminal = semestre_non_terminal or Se.semestre_non_terminal
d = {}
d["identite"] = nt.identdict[etudid]
@ -243,6 +252,8 @@ def dict_pvjury(
) # I|D|DEF (inscription ou démission ou défaillant)
d["decision_sem"] = nt.get_etud_decision_sem(etudid)
d["decisions_ue"] = nt.get_etud_decision_ues(etudid)
if formsemestre.formation.is_apc():
d.update(but_validations.dict_decision_jury(etud, formsemestre))
d["last_formsemestre_id"] = Se.get_semestres()[
-1
] # id du dernier semestre (chronologiquement) dans lequel il a été inscrit
@ -280,17 +291,18 @@ def dict_pvjury(
else:
d["decision_sem_descr"] = _descr_decision_sem(d["etat"], d["decision_sem"])
d["autorisations"] = sco_parcours_dut.formsemestre_get_autorisation_inscription(
etudid, formsemestre_id
)
d["autorisations_descr"] = descr_autorisations(d["autorisations"])
autorisations = ScolarAutorisationInscription.query.filter_by(
etudid=etudid, origin_formsemestre_id=formsemestre_id
).all()
d["autorisations"] = [a.to_dict() for a in autorisations]
d["autorisations_descr"] = descr_autorisations(autorisations)
d["validation_parcours"] = Se.parcours_validated()
d["parcours"] = Se.get_parcours_descr(filter_futur=True)
if with_parcours_decisions:
d["parcours_decisions"] = Se.get_parcours_decisions()
# Observations sur les compensations:
compensators = sco_parcours_dut.scolar_formsemestre_validation_list(
compensators = sco_cursus_dut.scolar_formsemestre_validation_list(
cnx, args={"compense_formsemestre_id": formsemestre_id, "etudid": etudid}
)
obs = []
@ -307,12 +319,7 @@ def dict_pvjury(
d["decision_sem"]["compense_formsemestre_id"]
)
obs.append(
"%s compense %s (%s)"
% (
sem["sem_id_txt"],
compensed["sem_id_txt"],
compensed["anneescolaire"],
)
f"""{sem["sem_id_txt"]} compense {compensed["sem_id_txt"]} ({compensed["anneescolaire"]})"""
)
d["observation"] = ", ".join(obs)

View File

@ -30,9 +30,11 @@
import io
import re
from PIL import Image as PILImage
import reportlab
from reportlab.lib.units import cm, mm
from reportlab.lib.enums import TA_RIGHT, TA_JUSTIFY
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_JUSTIFY
from reportlab.platypus import Paragraph, Spacer, Frame, PageBreak
from reportlab.platypus import Table, TableStyle, Image
from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate
@ -41,16 +43,16 @@ from reportlab.lib import styles
from reportlab.lib.colors import Color
from flask import g
from app.models import FormSemestre, Identite
import app.scodoc.sco_utils as scu
from app.scodoc import sco_bulletins_pdf
from app.scodoc import sco_codes_parcours
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_pdf
from app.scodoc import sco_preferences
from app.scodoc.sco_logos import find_logo
from app.scodoc.sco_parcours_dut import SituationEtudParcours
from app.scodoc.sco_cursus_dut import SituationEtudCursus
from app.scodoc.sco_pdf import SU
import sco_version
@ -125,6 +127,7 @@ def page_footer(canvas, doc, logo, preferences, with_page_numbers=True):
def page_header(canvas, doc, logo, preferences, only_on_first_page=False):
"Ajoute au canvas le frame avec le logo"
if only_on_first_page and int(doc.page) > 1:
return
height = doc.pagesize[1]
@ -147,12 +150,12 @@ def page_header(canvas, doc, logo, preferences, only_on_first_page=False):
class CourrierIndividuelTemplate(PageTemplate):
"""Template pour courrier avisant des decisions de jury (1 page /etudiant)"""
"""Template pour courrier avisant des decisions de jury (1 page par étudiant)"""
def __init__(
self,
document,
pagesbookmarks={},
pagesbookmarks=None,
author=None,
title=None,
subject=None,
@ -163,7 +166,7 @@ class CourrierIndividuelTemplate(PageTemplate):
template_name="CourrierJuryTemplate",
):
"""Initialise our page template."""
self.pagesbookmarks = pagesbookmarks
self.pagesbookmarks = pagesbookmarks or {}
self.pdfmeta_author = author
self.pdfmeta_title = title
self.pdfmeta_subject = subject
@ -237,32 +240,32 @@ class CourrierIndividuelTemplate(PageTemplate):
width=LOGO_HEADER_WIDTH,
)
def beforeDrawPage(self, canvas, doc):
def beforeDrawPage(self, canv, doc):
"""Draws a logo and an contribution message on each page."""
# ---- Add some meta data and bookmarks
if self.pdfmeta_author:
canvas.setAuthor(SU(self.pdfmeta_author))
canv.setAuthor(SU(self.pdfmeta_author))
if self.pdfmeta_title:
canvas.setTitle(SU(self.pdfmeta_title))
canv.setTitle(SU(self.pdfmeta_title))
if self.pdfmeta_subject:
canvas.setSubject(SU(self.pdfmeta_subject))
canv.setSubject(SU(self.pdfmeta_subject))
bm = self.pagesbookmarks.get(doc.page, None)
if bm != None:
key = bm
txt = SU(bm)
canvas.bookmarkPage(key)
canvas.addOutlineEntry(txt, bm)
canv.bookmarkPage(key)
canv.addOutlineEntry(txt, bm)
# ---- Background image
if self.background_image_filename and self.with_page_background:
canvas.drawImage(
canv.drawImage(
self.background_image_filename, 0, 0, doc.pagesize[0], doc.pagesize[1]
)
# ---- Header/Footer
if self.with_header:
page_header(
canvas,
canv,
doc,
self.logo_header,
self.preferences,
@ -270,7 +273,7 @@ class CourrierIndividuelTemplate(PageTemplate):
)
if self.with_footer:
page_footer(
canvas,
canv,
doc,
self.logo_footer,
self.preferences,
@ -332,6 +335,42 @@ class PVTemplate(CourrierIndividuelTemplate):
# self.__pageNum += 1
def _simulate_br(paragraph_txt: str, para="<para>") -> str:
"""Reportlab bug turnaround (could be removed in a future version).
p is a string with Reportlab intra-paragraph XML tags.
Replaces <br/> (currently ignored by Reportlab) by </para><para>
Also replaces <br> by <br/>
"""
return ("</para>" + para).join(
re.split(r"<.*?br.*?/>", paragraph_txt.replace("<br>", "<br/>"))
)
def _make_signature_image(signature, leftindent, formsemestre_id) -> Table:
"crée un paragraphe avec l'image signature"
# cree une image PIL pour avoir la taille (W,H)
f = io.BytesIO(signature)
img = PILImage.open(f)
width, height = img.size
pdfheight = (
1.0
* sco_preferences.get_preference("pv_sig_image_height", formsemestre_id)
* mm
)
f.seek(0, 0)
style = styles.ParagraphStyle({})
style.leading = 1.0 * sco_preferences.get_preference(
"SCOLAR_FONT_SIZE", formsemestre_id
) # vertical space
style.leftIndent = leftindent
return Table(
[("", Image(f, width=width * pdfheight / float(height), height=pdfheight))],
colWidths=(9 * cm, 7 * cm),
)
def pdf_lettres_individuelles(
formsemestre_id,
etudids=None,
@ -352,7 +391,7 @@ def pdf_lettres_individuelles(
etuds = [x["identite"] for x in dpv["decisions"]]
sco_etud.fill_etuds_info(etuds)
#
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
prefs = sco_preferences.SemPreferences(formsemestre_id)
params = {
"date_jury": date_jury,
@ -363,18 +402,22 @@ def pdf_lettres_individuelles(
}
# copie preferences
for name in sco_preferences.get_base_preferences().prefs_name:
params[name] = sco_preferences.get_preference(name, sem["formsemestre_id"])
params[name] = sco_preferences.get_preference(name, formsemestre_id)
bookmarks = {}
objects = [] # list of PLATYPUS objects
npages = 0
for e in dpv["decisions"]:
if e["decision_sem"]: # decision prise
etud = sco_etud.get_etud_info(e["identite"]["etudid"], filled=True)[0]
params["nomEtud"] = etud["nomprenom"]
bookmarks[npages + 1] = scu.suppress_accents(etud["nomprenom"])
for decision in dpv["decisions"]:
if (
decision["decision_sem"]
or decision.get("decision_annee")
or decision.get("decision_rcue")
): # decision prise
etud: Identite = Identite.query.get(decision["identite"]["etudid"])
params["nomEtud"] = etud.nomprenom
bookmarks[npages + 1] = scu.suppress_accents(etud.nomprenom)
objects += pdf_lettre_individuelle(
dpv["formsemestre"], e, etud, params, signature
dpv["formsemestre"], decision, etud, params, signature
)
objects.append(PageBreak())
npages += 1
@ -394,8 +437,8 @@ def pdf_lettres_individuelles(
document.addPageTemplates(
CourrierIndividuelTemplate(
document,
author="%s %s (E. Viennet)" % (sco_version.SCONAME, sco_version.SCOVERSION),
title="Lettres décision %s" % sem["titreannee"],
author=f"{sco_version.SCONAME} {sco_version.SCOVERSION} (E. Viennet)",
title=f"Lettres décision {formsemestre.titre_annee()}",
subject="Décision jury",
margins=margins,
pagesbookmarks=bookmarks,
@ -408,36 +451,41 @@ def pdf_lettres_individuelles(
return data
def _descr_jury(sem, diplome):
def _descr_jury(formsemestre: FormSemestre, diplome):
if not diplome:
t = "passage de Semestre %d en Semestre %d" % (
sem["semestre_id"],
sem["semestre_id"] + 1,
)
s = "passage de semestre"
if formsemestre.formation.is_apc():
t = f"""BUT{(formsemestre.semestre_id+1)//2}"""
s = t
else:
t = f"""passage de Semestre {formsemestre.semestre_id} en Semestre {formsemestre.semestre_id + 1}"""
s = "passage de semestre"
else:
t = "délivrance du diplôme"
s = t
return t, s # titre long, titre court
def pdf_lettre_individuelle(sem, decision, etud, params, signature=None):
def pdf_lettre_individuelle(sem, decision, etud: Identite, params, signature=None):
"""
Renvoie une liste d'objets PLATYPUS pour intégration
dans un autre document.
"""
#
formsemestre_id = sem["formsemestre_id"]
Se: SituationEtudParcours = decision["Se"]
t, s = _descr_jury(sem, Se.parcours_validated() or not Se.semestre_non_terminal)
formsemestre = FormSemestre.query.get(formsemestre_id)
Se: SituationEtudCursus = decision["Se"]
t, s = _descr_jury(
formsemestre, Se.parcours_validated() or not Se.semestre_non_terminal
)
objects = []
style = reportlab.lib.styles.ParagraphStyle({})
style.fontSize = 14
style.fontName = sco_preferences.get_preference("PV_FONTNAME", formsemestre_id)
style.leading = 18
style.alignment = TA_JUSTIFY
style.alignment = TA_LEFT
params["semestre_id"] = sem["semestre_id"]
params["semestre_id"] = formsemestre.semestre_id
params["decision_sem_descr"] = decision["decision_sem_descr"]
params["type_jury"] = t # type de jury (passage ou delivrance)
params["type_jury_abbrv"] = s # idem, abbrégé
@ -450,28 +498,18 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None):
params["INSTITUTION_CITY"] = (
sco_preferences.get_preference("INSTITUTION_CITY", formsemestre_id) or ""
)
if decision["prev_decision_sem"]:
params["prev_semestre_id"] = decision["prev"]["semestre_id"]
params["prev_code_descr"] = decision["prev_code_descr"]
params["prev_decision_sem_txt"] = ""
params["decision_orig"] = ""
params.update(decision["identite"])
# fix domicile
if params["domicile"]:
params["domicile"] = params["domicile"].replace("\\n", "<br/>")
# Décision semestre courant:
if sem["semestre_id"] >= 0:
params["decision_orig"] = "du semestre S%s" % sem["semestre_id"]
else:
params["decision_orig"] = ""
if decision["prev_decision_sem"]:
params["prev_decision_sem_txt"] = (
"""<b>Décision du semestre antérieur S%(prev_semestre_id)s :</b> %(prev_code_descr)s"""
% params
)
else:
params["prev_decision_sem_txt"] = ""
# UE capitalisées:
if decision["decisions_ue"] and decision["decisions_ue_descr"]:
params["decision_ue_txt"] = (
@ -498,7 +536,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None):
params[
"autorisations_txt"
] = """Vous êtes autorisé%s à continuer dans le%s semestre%s : <b>%s</b>""" % (
etud["ne"],
etud.e,
s,
s,
decision["autorisations_descr"],
@ -513,6 +551,14 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None):
else:
params["diplome_txt"] = ""
# Les fonctions ci-dessous ajoutent ou modifient des champs:
if formsemestre.formation.is_apc():
# ajout champs spécifiques PV BUT
add_apc_infos(formsemestre, params, decision)
else:
# ajout champs spécifiques PV DUT
add_classic_infos(formsemestre, params, decision)
# Corps de la lettre:
objects += sco_bulletins_pdf.process_field(
sco_preferences.get_preference("PV_LETTER_TEMPLATE", sem["formsemestre_id"]),
@ -567,39 +613,30 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None):
return objects
def _simulate_br(p, para="<para>"):
"""Reportlab bug turnaround (could be removed in a future version).
p is a string with Reportlab intra-paragraph XML tags.
Replaces <br/> (currently ignored by Reportlab) by </para><para>
def add_classic_infos(formsemestre: FormSemestre, params: dict, decision: dict):
"""Ajoute les champs pour les formations classiques, donc avec codes semestres"""
if decision["prev_decision_sem"]:
params["prev_code_descr"] = decision["prev_code_descr"]
params[
"prev_decision_sem_txt"
] = f"""<b>Décision du semestre antérieur S{params['prev_semestre_id']} :</b> {params['prev_code_descr']}"""
# Décision semestre courant:
if formsemestre.semestre_id >= 0:
params["decision_orig"] = f"du semestre S{formsemestre.semestre_id}"
else:
params["decision_orig"] = ""
def add_apc_infos(formsemestre: FormSemestre, params: dict, decision: dict):
"""Ajoute les champs pour les formations APC (BUT), donc avec codes RCUE et année"""
annee_but = (formsemestre.semestre_id + 1) // 2
params["decision_orig"] = f"année BUT{annee_but}"
params["decision_sem_descr"] = decision.get("decision_annee", {}).get("code", "")
params[
"decision_ue_txt"
] = f"""{params["decision_ue_txt"]}<br/>
<b>Niveaux de compétences:</b><br/> {decision.get("descr_decisions_rcue", "")}
"""
l = re.split(r"<.*?br.*?/>", p)
return ("</para>" + para).join(l)
def _make_signature_image(signature, leftindent, formsemestre_id):
"cree un paragraphe avec l'image signature"
# cree une image PIL pour avoir la taille (W,H)
from PIL import Image as PILImage
f = io.BytesIO(signature)
im = PILImage.open(f)
width, height = im.size
pdfheight = (
1.0
* sco_preferences.get_preference("pv_sig_image_height", formsemestre_id)
* mm
)
f.seek(0, 0)
style = styles.ParagraphStyle({})
style.leading = 1.0 * sco_preferences.get_preference(
"SCOLAR_FONT_SIZE", formsemestre_id
) # vertical space
style.leftIndent = leftindent
return Table(
[("", Image(f, width=width * pdfheight / float(height), height=pdfheight))],
colWidths=(9 * cm, 7 * cm),
)
# ----------------------------------------------
@ -699,7 +736,8 @@ def _pvjury_pdf_type(
sem = dpv["formsemestre"]
formsemestre_id = sem["formsemestre_id"]
titre_jury, _ = _descr_jury(sem, diplome)
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
titre_jury, _ = _descr_jury(formsemestre, diplome)
titre_diplome = pv_title or dpv["formation"]["titre_officiel"]
objects = []

View File

@ -41,7 +41,7 @@ import pydot
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre
from app.models import FormSemestre, ScolarAutorisationInscription
import app.scodoc.sco_utils as scu
from app.models import FormationModalite
@ -51,7 +51,6 @@ from app.scodoc import sco_codes_parcours
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_preferences
import sco_version
from app.scodoc.gen_tables import GenTable
@ -81,10 +80,10 @@ def formsemestre_etuds_stats(sem, only_primo=False):
if "codedecision" not in etud:
etud["codedecision"] = "(nd)" # pas de decision jury
# Ajout devenir (autorisations inscriptions), utile pour stats passage
aut_list = sco_parcours_dut.formsemestre_get_autorisation_inscription(
etudid, sem["formsemestre_id"]
)
autorisations = ["S%s" % x["semestre_id"] for x in aut_list]
aut_list = ScolarAutorisationInscription.query.filter_by(
etudid=etudid, origin_formsemestre_id=sem["formsemestre_id"]
).all()
autorisations = [f"S{a.semestre_id}" for a in aut_list]
autorisations.sort()
autorisations_str = ", ".join(autorisations)
etud["devenir"] = autorisations_str

View File

@ -664,6 +664,15 @@ def flash_errors(form):
# see https://getbootstrap.com/docs/4.0/components/alerts/
def flash_once(message: str):
"""Flash the message, but only once per request"""
if not hasattr(g, "sco_flashed_once"):
g.sco_flashed_once = set()
if not message in g.sco_flashed_once:
flash(message)
g.sco_flashed_once.add(message)
def sendCSVFile(data, filename): # DEPRECATED utiliser send_file
"""publication fichier CSV."""
return send_file(data, filename=filename, mime=CSV_MIMETYPE, attached=True)

View File

@ -169,7 +169,7 @@ section>div:nth-child(1){
border: none;
margin-left: auto;
}
.rang{
.rang, .competence{
font-weight: bold;
}
.ue .rang{

View File

@ -2210,6 +2210,7 @@ ul.notes_module_list {
list-style-type: none;
}
/*Choix niveau dans form edit UE */
div.ue_choix_niveau {
background-color: rgb(191, 242, 255);
border: 1px solid blue;
@ -2219,6 +2220,19 @@ div.ue_choix_niveau {
margin-right: 15px;
}
/* Choix niveau dans edition programme (ue_table) */
div.formation_list_ues div.ue_choix_niveau {
margin-left: 64px;
margin-right: 64px;
margin-top: 2px;
padding: 4px;
font-size: 14px;
}
div.formation_list_ues div.ue_choix_niveau b {
font-weight: normal;
}
div#ue_list_modules {
background-color: rgb(251, 225, 165);
border: 1px solid blue;

View File

@ -1,13 +1,16 @@
// Affiche et met a jour la liste des UE partageant le meme code
$().ready(function () {
update_ue_list();
$("#tf_ue_code").bind("keyup", update_ue_list);
if (document.querySelector("#tf_ue_id")) {
/* fonctions spécifiques pour edition UE */
update_ue_list();
$("#tf_ue_code").bind("keyup", update_ue_list);
$("select#tf_type").change(function () {
$("select#tf_type").change(function () {
update_bonus_description();
});
update_bonus_description();
});
update_bonus_description();
}
});
function update_bonus_description() {
@ -33,11 +36,10 @@ function update_ue_list() {
});
}
function set_ue_niveau_competence() {
let ue_id = document.querySelector("#tf_ue_id").value;
let select = document.querySelector("#form_ue_choix_niveau select");
let niveau_id = select.value;
let set_ue_niveau_competence_url = select.dataset.setter;
function set_ue_niveau_competence(elem) {
let ue_id = elem.dataset.ue_id;
let niveau_id = elem.value;
let set_ue_niveau_competence_url = elem.dataset.setter;
$.post(set_ue_niveau_competence_url,
{
ue_id: ue_id,

View File

@ -232,7 +232,7 @@ class releveBUT extends HTMLElement {
${(()=>{
let output = "";
data.semestre.decision_rcue.forEach(competence=>{
output += `<div class=rang>${competence.niveau.competence.titre}</div><div>${competence.code}</div>`;
output += `<div class=competence>${competence.niveau.competence.titre}</div><div>${competence.code}</div>`;
})
return output;
})()}

View File

@ -30,7 +30,7 @@
<span class="ue_type_{{ue.type}}">
<span class="ue_color_indicator" style="background:{{
ue.color if ue.color is not none else 'blue'}}"></span>
<b>{{ue.acronyme}}</b> <a class="discretelink" href="{{
<b>{{ue.acronyme}} <a class="discretelink" href="{{
url_for('notes.ue_infos', scodoc_dept=g.scodoc_dept, ue_id=ue.id)}}"
title="{{ue.acronyme}}: {{
('pas de compétence associée'
@ -40,6 +40,7 @@
else ''
}}"
>{{ue.titre}}</a>
</b>
{% set virg = joiner(", ") %}
<span class="ue_code">(
{%- if ue.ue_code -%}{{ virg() }}code {{ue.ue_code}} {%- endif -%}
@ -53,9 +54,6 @@
)
</span>
</span>
{% if (ue.niveau_competence is none) and ue.type == 0 %}
<span class="fontred">pas de compétence associée</span>
{% endif %}
{% if editable and not ue.is_locked() %}
<a class="stdlink" href="{{ url_for('notes.ue_edit',
@ -63,6 +61,9 @@
}}">modifier</a>
{% endif %}
{{ form_ue_choix_niveau(formation, ue)|safe }}
{% if ue.type == 1 and ue.modules.count() == 0 %}
<span class="warning" title="pas de module, donc pas de bonus calculé">aucun module rattaché !</span>
{% endif %}

View File

@ -296,7 +296,9 @@ def formsemestre_bulletinetud(
format = format or "html"
if not isinstance(formsemestre_id, int):
raise ScoInvalidIdType("formsemestre_id must be an integer !")
raise ScoInvalidIdType(
"formsemestre_bulletinetud: formsemestre_id must be an integer !"
)
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
if etudid:
etud = models.Identite.query.get_or_404(etudid)
@ -826,7 +828,9 @@ def XMLgetFormsemestres(etape_apo=None, formsemestre_id=None):
if not formsemestre_id:
return flask.abort(404, "argument manquant: formsemestre_id")
if not isinstance(formsemestre_id, int):
return flask.abort(404, "formsemestre_id must be an integer !")
return flask.abort(
404, "XMLgetFormsemestres: formsemestre_id must be an integer !"
)
args = {}
if etape_apo:
args["etape_apo"] = etape_apo
@ -2548,9 +2552,8 @@ def formsemestre_validation_suppress_etud(
)
if not dialog_confirmed:
d = sco_bulletins_json.dict_decision_jury(
etudid, formsemestre_id, with_decisions=True
etud, formsemestre, with_decisions=True
)
d.update(but_validations.dict_decision_jury(etud, formsemestre))
descr_ues = [f"{u['acronyme']}: {u['code']}" for u in d.get("decision_ue", [])]
dec_annee = d.get("decision_annee")

0
bench.py Executable file → Normal file
View File

View File

@ -14,17 +14,17 @@ config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logger = logging.getLogger("alembic.env")
logger = logging.getLogger('alembic.env')
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
config.set_main_option(
"sqlalchemy.url",
str(current_app.extensions["migrate"].db.get_engine().url).replace("%", "%%"),
)
target_metadata = current_app.extensions["migrate"].db.metadata
'sqlalchemy.url',
str(current_app.extensions['migrate'].db.get_engine().url).replace(
'%', '%%'))
target_metadata = current_app.extensions['migrate'].db.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
@ -45,7 +45,9 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, target_metadata=target_metadata, literal_binds=True)
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True
)
with context.begin_transaction():
context.run_migrations()
@ -63,20 +65,20 @@ def run_migrations_online():
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, "autogenerate", False):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info("No changes in schema detected.")
logger.info('No changes in schema detected.')
connectable = current_app.extensions["migrate"].db.get_engine()
connectable = current_app.extensions['migrate'].db.get_engine()
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions["migrate"].configure_args
**current_app.extensions['migrate'].configure_args
)
with context.begin_transaction():

View File

@ -10,23 +10,21 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "017e32eb4773"
down_revision = "6b071b7947e5"
revision = '017e32eb4773'
down_revision = '6b071b7947e5'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("identite", sa.Column("scodoc7_id", sa.Text(), nullable=True))
op.add_column(
"notes_formsemestre", sa.Column("scodoc7_id", sa.Text(), nullable=True)
)
op.add_column('identite', sa.Column('scodoc7_id', sa.Text(), nullable=True))
op.add_column('notes_formsemestre', sa.Column('scodoc7_id', sa.Text(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("notes_formsemestre", "scodoc7_id")
op.drop_column("identite", "scodoc7_id")
op.drop_column('notes_formsemestre', 'scodoc7_id')
op.drop_column('identite', 'scodoc7_id')
# ### end Alembic commands ###

View File

@ -10,38 +10,21 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "1efe07413835"
down_revision = "75cf18659984"
revision = '1efe07413835'
down_revision = '75cf18659984'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"absences_notifications_formsemestre_id_fkey",
"absences_notifications",
type_="foreignkey",
)
op.create_foreign_key(
None,
"absences_notifications",
"notes_formsemestre",
["formsemestre_id"],
["id"],
ondelete="CASCADE",
)
op.drop_constraint('absences_notifications_formsemestre_id_fkey', 'absences_notifications', type_='foreignkey')
op.create_foreign_key(None, 'absences_notifications', 'notes_formsemestre', ['formsemestre_id'], ['id'], ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "absences_notifications", type_="foreignkey")
op.create_foreign_key(
"absences_notifications_formsemestre_id_fkey",
"absences_notifications",
"notes_formsemestre",
["formsemestre_id"],
["id"],
)
op.drop_constraint(None, 'absences_notifications', type_='foreignkey')
op.create_foreign_key('absences_notifications_formsemestre_id_fkey', 'absences_notifications', 'notes_formsemestre', ['formsemestre_id'], ['id'])
# ### end Alembic commands ###

View File

@ -10,57 +10,25 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "39818df276aa"
down_revision = "1efe07413835"
revision = '39818df276aa'
down_revision = '1efe07413835'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"itemsuivi_tags_assoc_tag_id_fkey", "itemsuivi_tags_assoc", type_="foreignkey"
)
op.drop_constraint(
"itemsuivi_tags_assoc_itemsuivi_id_fkey",
"itemsuivi_tags_assoc",
type_="foreignkey",
)
op.create_foreign_key(
None,
"itemsuivi_tags_assoc",
"itemsuivi",
["itemsuivi_id"],
["id"],
ondelete="CASCADE",
)
op.create_foreign_key(
None,
"itemsuivi_tags_assoc",
"itemsuivi_tags",
["tag_id"],
["id"],
ondelete="CASCADE",
)
op.drop_constraint('itemsuivi_tags_assoc_tag_id_fkey', 'itemsuivi_tags_assoc', type_='foreignkey')
op.drop_constraint('itemsuivi_tags_assoc_itemsuivi_id_fkey', 'itemsuivi_tags_assoc', type_='foreignkey')
op.create_foreign_key(None, 'itemsuivi_tags_assoc', 'itemsuivi', ['itemsuivi_id'], ['id'], ondelete='CASCADE')
op.create_foreign_key(None, 'itemsuivi_tags_assoc', 'itemsuivi_tags', ['tag_id'], ['id'], ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "itemsuivi_tags_assoc", type_="foreignkey")
op.drop_constraint(None, "itemsuivi_tags_assoc", type_="foreignkey")
op.create_foreign_key(
"itemsuivi_tags_assoc_itemsuivi_id_fkey",
"itemsuivi_tags_assoc",
"itemsuivi",
["itemsuivi_id"],
["id"],
)
op.create_foreign_key(
"itemsuivi_tags_assoc_tag_id_fkey",
"itemsuivi_tags_assoc",
"itemsuivi_tags",
["tag_id"],
["id"],
)
op.drop_constraint(None, 'itemsuivi_tags_assoc', type_='foreignkey')
op.drop_constraint(None, 'itemsuivi_tags_assoc', type_='foreignkey')
op.create_foreign_key('itemsuivi_tags_assoc_itemsuivi_id_fkey', 'itemsuivi_tags_assoc', 'itemsuivi', ['itemsuivi_id'], ['id'])
op.create_foreign_key('itemsuivi_tags_assoc_tag_id_fkey', 'itemsuivi_tags_assoc', 'itemsuivi_tags', ['tag_id'], ['id'])
# ### end Alembic commands ###

View File

@ -10,24 +10,19 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "669065fb2d20"
down_revision = "a217bf588f4c"
revision = '669065fb2d20'
down_revision = 'a217bf588f4c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"notes_formsemestre",
sa.Column(
"block_moyennes", sa.Boolean(), server_default="false", nullable=False
),
)
op.add_column('notes_formsemestre', sa.Column('block_moyennes', sa.Boolean(), server_default='false', nullable=False))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("notes_formsemestre", "block_moyennes")
op.drop_column('notes_formsemestre', 'block_moyennes')
# ### end Alembic commands ###

View File

@ -10,31 +10,25 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "6b071b7947e5"
down_revision = "993ce4a01d57"
revision = '6b071b7947e5'
down_revision = '993ce4a01d57'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"notes_modules",
"code",
existing_type=sa.VARCHAR(length=32),
type_=sa.Text(),
existing_nullable=False,
)
op.alter_column('notes_modules', 'code',
existing_type=sa.VARCHAR(length=32),
type_=sa.Text(),
existing_nullable=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"notes_modules",
"code",
existing_type=sa.Text(),
type_=sa.VARCHAR(length=32),
existing_nullable=False,
)
op.alter_column('notes_modules', 'code',
existing_type=sa.Text(),
type_=sa.VARCHAR(length=32),
existing_nullable=False)
# ### end Alembic commands ###

View File

@ -10,33 +10,26 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "6cfc21a7ae1b"
down_revision = "ada0d1f3d84f"
revision = '6cfc21a7ae1b'
down_revision = 'ada0d1f3d84f'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"module_ue_coef",
sa.Column("module_id", sa.Integer(), nullable=False),
sa.Column("ue_id", sa.Integer(), nullable=False),
sa.Column("coef", sa.Float(), nullable=False),
sa.ForeignKeyConstraint(
["module_id"],
["notes_modules.id"],
),
sa.ForeignKeyConstraint(
["ue_id"],
["notes_ue.id"],
),
sa.PrimaryKeyConstraint("module_id", "ue_id"),
op.create_table('module_ue_coef',
sa.Column('module_id', sa.Integer(), nullable=False),
sa.Column('ue_id', sa.Integer(), nullable=False),
sa.Column('coef', sa.Float(), nullable=False),
sa.ForeignKeyConstraint(['module_id'], ['notes_modules.id'], ),
sa.ForeignKeyConstraint(['ue_id'], ['notes_ue.id'], ),
sa.PrimaryKeyConstraint('module_id', 'ue_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("module_ue_coef")
op.drop_table('module_ue_coef')
# ### end Alembic commands ###

View File

@ -10,50 +10,25 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "75cf18659984"
down_revision = "d74b4e16fb3c"
revision = '75cf18659984'
down_revision = 'd74b4e16fb3c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"notes_modules_tags_tag_id_fkey", "notes_modules_tags", type_="foreignkey"
)
op.drop_constraint(
"notes_modules_tags_module_id_fkey", "notes_modules_tags", type_="foreignkey"
)
op.create_foreign_key(
None, "notes_modules_tags", "notes_tags", ["tag_id"], ["id"], ondelete="CASCADE"
)
op.create_foreign_key(
None,
"notes_modules_tags",
"notes_modules",
["module_id"],
["id"],
ondelete="CASCADE",
)
op.drop_constraint('notes_modules_tags_tag_id_fkey', 'notes_modules_tags', type_='foreignkey')
op.drop_constraint('notes_modules_tags_module_id_fkey', 'notes_modules_tags', type_='foreignkey')
op.create_foreign_key(None, 'notes_modules_tags', 'notes_tags', ['tag_id'], ['id'], ondelete='CASCADE')
op.create_foreign_key(None, 'notes_modules_tags', 'notes_modules', ['module_id'], ['id'], ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "notes_modules_tags", type_="foreignkey")
op.drop_constraint(None, "notes_modules_tags", type_="foreignkey")
op.create_foreign_key(
"notes_modules_tags_module_id_fkey",
"notes_modules_tags",
"notes_modules",
["module_id"],
["id"],
)
op.create_foreign_key(
"notes_modules_tags_tag_id_fkey",
"notes_modules_tags",
"notes_tags",
["tag_id"],
["id"],
)
op.drop_constraint(None, 'notes_modules_tags', type_='foreignkey')
op.drop_constraint(None, 'notes_modules_tags', type_='foreignkey')
op.create_foreign_key('notes_modules_tags_module_id_fkey', 'notes_modules_tags', 'notes_modules', ['module_id'], ['id'])
op.create_foreign_key('notes_modules_tags_tag_id_fkey', 'notes_modules_tags', 'notes_tags', ['tag_id'], ['id'])
# ### end Alembic commands ###

View File

@ -10,77 +10,46 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "92789d50f6b6"
down_revision = "00ad500fb118"
revision = '92789d50f6b6'
down_revision = '00ad500fb118'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("modules_acs")
op.drop_table("app_crit")
op.add_column("apc_annee_parcours", sa.Column("ordre", sa.Integer(), nullable=True))
op.drop_column("apc_annee_parcours", "numero")
op.create_index(
op.f("ix_apc_app_critique_code"), "apc_app_critique", ["code"], unique=False
)
op.create_unique_constraint(
"apc_competence_referentiel_id_titre_key",
"apc_competence",
["referentiel_id", "titre"],
)
op.create_index(
op.f("ix_apc_competence_titre"), "apc_competence", ["titre"], unique=False
)
op.add_column(
"apc_referentiel_competences",
sa.Column("scodoc_date_loaded", sa.DateTime(), nullable=True),
)
op.add_column(
"apc_referentiel_competences",
sa.Column("scodoc_orig_filename", sa.Text(), nullable=True),
)
op.drop_table('modules_acs')
op.drop_table('app_crit')
op.add_column('apc_annee_parcours', sa.Column('ordre', sa.Integer(), nullable=True))
op.drop_column('apc_annee_parcours', 'numero')
op.create_index(op.f('ix_apc_app_critique_code'), 'apc_app_critique', ['code'], unique=False)
op.create_unique_constraint('apc_competence_referentiel_id_titre_key', 'apc_competence', ['referentiel_id', 'titre'])
op.create_index(op.f('ix_apc_competence_titre'), 'apc_competence', ['titre'], unique=False)
op.add_column('apc_referentiel_competences', sa.Column('scodoc_date_loaded', sa.DateTime(), nullable=True))
op.add_column('apc_referentiel_competences', sa.Column('scodoc_orig_filename', sa.Text(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("apc_referentiel_competences", "scodoc_orig_filename")
op.drop_column("apc_referentiel_competences", "scodoc_date_loaded")
op.drop_index(op.f("ix_apc_competence_titre"), table_name="apc_competence")
op.drop_constraint(
"apc_competence_referentiel_id_titre_key", "apc_competence", type_="unique"
op.drop_column('apc_referentiel_competences', 'scodoc_orig_filename')
op.drop_column('apc_referentiel_competences', 'scodoc_date_loaded')
op.drop_index(op.f('ix_apc_competence_titre'), table_name='apc_competence')
op.drop_constraint('apc_competence_referentiel_id_titre_key', 'apc_competence', type_='unique')
op.drop_index(op.f('ix_apc_app_critique_code'), table_name='apc_app_critique')
op.add_column('apc_annee_parcours', sa.Column('numero', sa.INTEGER(), autoincrement=False, nullable=True))
op.drop_column('apc_annee_parcours', 'ordre')
op.create_table('app_crit',
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('app_crit_id_seq'::regclass)"), autoincrement=True, nullable=False),
sa.Column('code', sa.TEXT(), autoincrement=False, nullable=False),
sa.Column('titre', sa.TEXT(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name='app_crit_pkey'),
postgresql_ignore_search_path=False
)
op.drop_index(op.f("ix_apc_app_critique_code"), table_name="apc_app_critique")
op.add_column(
"apc_annee_parcours",
sa.Column("numero", sa.INTEGER(), autoincrement=False, nullable=True),
)
op.drop_column("apc_annee_parcours", "ordre")
op.create_table(
"app_crit",
sa.Column(
"id",
sa.INTEGER(),
server_default=sa.text("nextval('app_crit_id_seq'::regclass)"),
autoincrement=True,
nullable=False,
),
sa.Column("code", sa.TEXT(), autoincrement=False, nullable=False),
sa.Column("titre", sa.TEXT(), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint("id", name="app_crit_pkey"),
postgresql_ignore_search_path=False,
)
op.create_table(
"modules_acs",
sa.Column("module_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column("ac_id", sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(
["ac_id"], ["app_crit.id"], name="modules_acs_ac_id_fkey"
),
sa.ForeignKeyConstraint(
["module_id"], ["notes_modules.id"], name="modules_acs_module_id_fkey"
),
op.create_table('modules_acs',
sa.Column('module_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('ac_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['ac_id'], ['app_crit.id'], name='modules_acs_ac_id_fkey'),
sa.ForeignKeyConstraint(['module_id'], ['notes_modules.id'], name='modules_acs_module_id_fkey')
)
# ### end Alembic commands ###

View File

@ -10,50 +10,27 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "a217bf588f4c"
down_revision = "f73251d1d825"
revision = 'a217bf588f4c'
down_revision = 'f73251d1d825'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"notes_semset_formsemestre",
"semset_id",
existing_type=sa.INTEGER(),
nullable=False,
)
op.drop_constraint(
"notes_semset_formsemestre_semset_id_fkey",
"notes_semset_formsemestre",
type_="foreignkey",
)
op.create_foreign_key(
None,
"notes_semset_formsemestre",
"notes_semset",
["semset_id"],
["id"],
ondelete="CASCADE",
)
op.alter_column('notes_semset_formsemestre', 'semset_id',
existing_type=sa.INTEGER(),
nullable=False)
op.drop_constraint('notes_semset_formsemestre_semset_id_fkey', 'notes_semset_formsemestre', type_='foreignkey')
op.create_foreign_key(None, 'notes_semset_formsemestre', 'notes_semset', ['semset_id'], ['id'], ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "notes_semset_formsemestre", type_="foreignkey")
op.create_foreign_key(
"notes_semset_formsemestre_semset_id_fkey",
"notes_semset_formsemestre",
"notes_semset",
["semset_id"],
["id"],
)
op.alter_column(
"notes_semset_formsemestre",
"semset_id",
existing_type=sa.INTEGER(),
nullable=True,
)
op.drop_constraint(None, 'notes_semset_formsemestre', type_='foreignkey')
op.create_foreign_key('notes_semset_formsemestre_semset_id_fkey', 'notes_semset_formsemestre', 'notes_semset', ['semset_id'], ['id'])
op.alter_column('notes_semset_formsemestre', 'semset_id',
existing_type=sa.INTEGER(),
nullable=True)
# ### end Alembic commands ###

View File

@ -10,23 +10,21 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "c8efc54586d8"
down_revision = "6cfc21a7ae1b"
revision = 'c8efc54586d8'
down_revision = '6cfc21a7ae1b'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("notes_ue", sa.Column("semestre_idx", sa.Integer(), nullable=True))
op.create_index(
op.f("ix_notes_ue_semestre_idx"), "notes_ue", ["semestre_idx"], unique=False
)
op.add_column('notes_ue', sa.Column('semestre_idx', sa.Integer(), nullable=True))
op.create_index(op.f('ix_notes_ue_semestre_idx'), 'notes_ue', ['semestre_idx'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_notes_ue_semestre_idx"), table_name="notes_ue")
op.drop_column("notes_ue", "semestre_idx")
op.drop_index(op.f('ix_notes_ue_semestre_idx'), table_name='notes_ue')
op.drop_column('notes_ue', 'semestre_idx')
# ### end Alembic commands ###

View File

@ -10,25 +10,23 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "d3d92b2d0092"
down_revision = "017e32eb4773"
revision = 'd3d92b2d0092'
down_revision = '017e32eb4773'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("itemsuivi_tags", sa.Column("dept_id", sa.Integer(), nullable=True))
op.create_index(
op.f("ix_itemsuivi_tags_dept_id"), "itemsuivi_tags", ["dept_id"], unique=False
)
op.create_foreign_key(None, "itemsuivi_tags", "departement", ["dept_id"], ["id"])
op.add_column('itemsuivi_tags', sa.Column('dept_id', sa.Integer(), nullable=True))
op.create_index(op.f('ix_itemsuivi_tags_dept_id'), 'itemsuivi_tags', ['dept_id'], unique=False)
op.create_foreign_key(None, 'itemsuivi_tags', 'departement', ['dept_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "itemsuivi_tags", type_="foreignkey")
op.drop_index(op.f("ix_itemsuivi_tags_dept_id"), table_name="itemsuivi_tags")
op.drop_column("itemsuivi_tags", "dept_id")
op.drop_constraint(None, 'itemsuivi_tags', type_='foreignkey')
op.drop_index(op.f('ix_itemsuivi_tags_dept_id'), table_name='itemsuivi_tags')
op.drop_column('itemsuivi_tags', 'dept_id')
# ### end Alembic commands ###

View File

@ -10,73 +10,49 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "f6e7d2e01be1"
down_revision = "d3d92b2d0092"
revision = 'f6e7d2e01be1'
down_revision = 'd3d92b2d0092'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"notes_formsemestre_etapes",
"etape_apo",
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True,
)
op.alter_column(
"notes_formsemestre_inscription",
"etape",
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True,
)
op.alter_column(
"notes_modules",
"code_apogee",
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True,
)
op.alter_column(
"notes_ue",
"code_apogee",
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True,
)
op.alter_column('notes_formsemestre_etapes', 'etape_apo',
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True)
op.alter_column('notes_formsemestre_inscription', 'etape',
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True)
op.alter_column('notes_modules', 'code_apogee',
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True)
op.alter_column('notes_ue', 'code_apogee',
existing_type=sa.VARCHAR(length=16),
type_=sa.String(length=24),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"notes_ue",
"code_apogee",
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True,
)
op.alter_column(
"notes_modules",
"code_apogee",
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True,
)
op.alter_column(
"notes_formsemestre_inscription",
"etape",
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True,
)
op.alter_column(
"notes_formsemestre_etapes",
"etape_apo",
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True,
)
op.alter_column('notes_ue', 'code_apogee',
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True)
op.alter_column('notes_modules', 'code_apogee',
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True)
op.alter_column('notes_formsemestre_inscription', 'etape',
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True)
op.alter_column('notes_formsemestre_etapes', 'etape_apo',
existing_type=sa.String(length=24),
type_=sa.VARCHAR(length=16),
existing_nullable=True)
# ### end Alembic commands ###

View File

@ -10,29 +10,26 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "f73251d1d825"
down_revision = "f6e7d2e01be1"
revision = 'f73251d1d825'
down_revision = 'f6e7d2e01be1'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"scodoc_site_config",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.String(length=128), nullable=False),
sa.Column("value", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_scodoc_site_config_name"), "scodoc_site_config", ["name"], unique=False
op.create_table('scodoc_site_config',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=False),
sa.Column('value', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_scodoc_site_config_name'), 'scodoc_site_config', ['name'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_scodoc_site_config_name"), table_name="scodoc_site_config")
op.drop_table("scodoc_site_config")
op.drop_index(op.f('ix_scodoc_site_config_name'), table_name='scodoc_site_config')
op.drop_table('scodoc_site_config')
# ### end Alembic commands ###

View File

@ -10,31 +10,21 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "f86c013c9fbd"
down_revision = "669065fb2d20"
revision = 'f86c013c9fbd'
down_revision = '669065fb2d20'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"notes_formations_acronyme_titre_version_key",
"notes_formations",
type_="unique",
)
op.create_unique_constraint(
None, "notes_formations", ["dept_id", "acronyme", "titre", "version"]
)
op.drop_constraint('notes_formations_acronyme_titre_version_key', 'notes_formations', type_='unique')
op.create_unique_constraint(None, 'notes_formations', ['dept_id', 'acronyme', 'titre', 'version'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, "notes_formations", type_="unique")
op.create_unique_constraint(
"notes_formations_acronyme_titre_version_key",
"notes_formations",
["acronyme", "titre", "version"],
)
op.drop_constraint(None, 'notes_formations', type_='unique')
op.create_unique_constraint('notes_formations_acronyme_titre_version_key', 'notes_formations', ['acronyme', 'titre', 'version'])
# ### end Alembic commands ###

View File

@ -7,84 +7,65 @@ Source: http://wikipython.flibuste.net/moin.py/JouerAvecUnicode#head-1213938516c
"""
_reptable = {}
def _fill_reptable():
_corresp = [
("A", [0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x0100, 0x0102, 0x0104]),
("AE", [0x00C6]),
("a", [0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x0101, 0x0103, 0x0105]),
("ae", [0x00E6]),
("C", [0x00C7, 0x0106, 0x0108, 0x010A, 0x010C]),
("c", [0x00E7, 0x0107, 0x0109, 0x010B, 0x010D]),
("D", [0x00D0, 0x010E, 0x0110]),
("d", [0x00F0, 0x010F, 0x0111]),
("E", [0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0112, 0x0114, 0x0116, 0x0118, 0x011A]),
("e", [0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0113, 0x0115, 0x0117, 0x0119, 0x011B]),
("G", [0x011C, 0x011E, 0x0120, 0x0122]),
("g", [0x011D, 0x011F, 0x0121, 0x0123]),
("H", [0x0124, 0x0126]),
("h", [0x0125, 0x0127]),
("I", [0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x0128, 0x012A, 0x012C, 0x012E, 0x0130]),
("i", [0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x0129, 0x012B, 0x012D, 0x012F, 0x0131]),
("IJ", [0x0132]),
("ij", [0x0133]),
("J", [0x0134]),
("j", [0x0135]),
("K", [0x0136]),
("k", [0x0137, 0x0138]),
("L", [0x0139, 0x013B, 0x013D, 0x013F, 0x0141]),
("l", [0x013A, 0x013C, 0x013E, 0x0140, 0x0142]),
("N", [0x00D1, 0x0143, 0x0145, 0x0147, 0x014A]),
("n", [0x00F1, 0x0144, 0x0146, 0x0148, 0x0149, 0x014B]),
("O", [0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D8, 0x014C, 0x014E, 0x0150]),
("o", [0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F8, 0x014D, 0x014F, 0x0151]),
("OE", [0x0152]),
("oe", [0x0153]),
("R", [0x0154, 0x0156, 0x0158]),
("r", [0x0155, 0x0157, 0x0159]),
("S", [0x015A, 0x015C, 0x015E, 0x0160]),
("s", [0x015B, 0x015D, 0x015F, 0x01610, 0x017F]),
("T", [0x0162, 0x0164, 0x0166]),
("t", [0x0163, 0x0165, 0x0167]),
(
"U",
[
0x00D9,
0x00DA,
0x00DB,
0x00DC,
0x0168,
0x016A,
0x016C,
0x016E,
0x0170,
0x172,
],
),
("u", [0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x016D, 0x016F, 0x0171]),
("W", [0x0174]),
("w", [0x0175]),
("Y", [0x00DD, 0x0176, 0x0178]),
("y", [0x00FD, 0x00FF, 0x0177]),
("Z", [0x0179, 0x017B, 0x017D]),
("z", [0x017A, 0x017C, 0x017E]),
("2", [0x00B2]), # deux exposant
(" ", [0x00A0]), # &nbsp
("", [0xB0]), # degre
("", [0xA9]), # copyright
("1/2", [0xBD]), # 1/2
]
(u"A", [0x00C0,0x00C1,0x00C2,0x00C3,0x00C4,0x00C5,0x0100,0x0102,0x0104]),
(u"AE", [0x00C6]),
(u"a", [0x00E0,0x00E1,0x00E2,0x00E3,0x00E4,0x00E5,0x0101,0x0103,0x0105]),
(u"ae", [0x00E6]),
(u"C", [0x00C7,0x0106,0x0108,0x010A,0x010C]),
(u"c", [0x00E7,0x0107,0x0109,0x010B,0x010D]),
(u"D", [0x00D0,0x010E,0x0110]),
(u"d", [0x00F0,0x010F,0x0111]),
(u"E", [0x00C8,0x00C9,0x00CA,0x00CB,0x0112,0x0114,0x0116,0x0118,0x011A]),
(u"e", [0x00E8,0x00E9,0x00EA,0x00EB,0x0113,0x0115,0x0117,0x0119,0x011B]),
(u"G", [0x011C,0x011E,0x0120,0x0122]),
(u"g", [0x011D,0x011F,0x0121,0x0123]),
(u"H", [0x0124,0x0126]),
(u"h", [0x0125,0x0127]),
(u"I", [0x00CC,0x00CD,0x00CE,0x00CF,0x0128,0x012A,0x012C,0x012E,0x0130]),
(u"i", [0x00EC,0x00ED,0x00EE,0x00EF,0x0129,0x012B,0x012D,0x012F,0x0131]),
(u"IJ", [0x0132]),
(u"ij", [0x0133]),
(u"J", [0x0134]),
(u"j", [0x0135]),
(u"K", [0x0136]),
(u"k", [0x0137,0x0138]),
(u"L", [0x0139,0x013B,0x013D,0x013F,0x0141]),
(u"l", [0x013A,0x013C,0x013E,0x0140,0x0142]),
(u"N", [0x00D1,0x0143,0x0145,0x0147,0x014A]),
(u"n", [0x00F1,0x0144,0x0146,0x0148,0x0149,0x014B]),
(u"O", [0x00D2,0x00D3,0x00D4,0x00D5,0x00D6,0x00D8,0x014C,0x014E,0x0150]),
(u"o", [0x00F2,0x00F3,0x00F4,0x00F5,0x00F6,0x00F8,0x014D,0x014F,0x0151]),
(u"OE", [0x0152]),
(u"oe", [0x0153]),
(u"R", [0x0154,0x0156,0x0158]),
(u"r", [0x0155,0x0157,0x0159]),
(u"S", [0x015A,0x015C,0x015E,0x0160]),
(u"s", [0x015B,0x015D,0x015F,0x01610,0x017F]),
(u"T", [0x0162,0x0164,0x0166]),
(u"t", [0x0163,0x0165,0x0167]),
(u"U", [0x00D9,0x00DA,0x00DB,0x00DC,0x0168,0x016A,0x016C,0x016E,0x0170,0x172]),
(u"u", [0x00F9,0x00FA,0x00FB,0x00FC,0x0169,0x016B,0x016D,0x016F,0x0171]),
(u"W", [0x0174]),
(u"w", [0x0175]),
(u"Y", [0x00DD,0x0176,0x0178]),
(u"y", [0x00FD,0x00FF,0x0177]),
(u"Z", [0x0179,0x017B,0x017D]),
(u"z", [0x017A,0x017C,0x017E]),
(u"2", [0x00B2]), # deux exposant
(u" ", [0x00A0]), # &nbsp
(u"", [0xB0]), # degre
(u"", [0xA9]), # copyright
(u"1/2", [0xBD]), # 1/2
]
global _reptable
for repchar, codes in _corresp:
for code in codes:
for repchar,codes in _corresp :
for code in codes :
_reptable[code] = repchar
_fill_reptable()
def suppression_diacritics(s):
def suppression_diacritics(s) :
"""Suppression des accents et autres marques.
@param s: le texte à nettoyer.
@ -92,6 +73,6 @@ def suppression_diacritics(s):
@return: le texte nettoyé de ses marques diacritiques.
@rtype: unicode
"""
if isinstance(s, str):
s = unicode(s, "utf8", "replace")
if isinstance(s,str) :
s = unicode(s,"utf8","replace")
return s.translate(_reptable)

0
pylintrc Executable file → Normal file
View File

2
sco_version.py Executable file → Normal file
View File

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

View File

@ -178,7 +178,7 @@ def test_abs_groupe_etat(api_headers):
# XXX TODO
# def reset_etud_abs(api_headers):
# """
# Test 'abs_groupe_etat'
# Test 'reset_etud_abs'
#
# Routes :
# - /absences/etudid/<int:etudid>/list_abs/<string:list_abs>/reset_etud_abs

View File

@ -70,7 +70,7 @@ def test_evaluations(api_headers):
assert eval["moduleimpl_id"] == moduleimpl_id
def test_evaluation_notes(api_headers):
def test_evaluation_notes(api_headers): # XXX TODO changer la boucle pour parcourir le dict sans les indices
"""
Test 'evaluation_notes'

View File

@ -20,6 +20,7 @@ from config import TestConfig
from tests.unit import sco_fake_gen
import app
from app import db
from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat
from app.models import FormSemestre
@ -31,8 +32,7 @@ from app.scodoc import sco_codes_parcours
from app.scodoc import sco_evaluations
from app.scodoc import sco_evaluation_db
from app.scodoc import sco_formsemestre_validation
from app.scodoc import sco_parcours_dut
from app.scodoc import sco_cache
from app.scodoc import sco_cursus_dut
from app.scodoc import sco_saisie_notes
from app.scodoc import sco_utils as scu
@ -194,20 +194,20 @@ def run_sco_basic(verbose=False):
# --- Permission saisie notes et décisions de jury, avec ou sans démission ou défaillance
# on n'a pas encore saisi de décisions
assert not sco_parcours_dut.formsemestre_has_decisions(formsemestre_id)
assert not sco_cursus_dut.formsemestre_has_decisions(formsemestre_id)
# Saisie d'un décision AJ, non assidu
etudid = etuds[-1]["etudid"]
sco_parcours_dut.formsemestre_validate_ues(
sco_cursus_dut.formsemestre_validate_ues(
formsemestre_id, etudid, sco_codes_parcours.AJ, False
)
assert sco_parcours_dut.formsemestre_has_decisions(
assert sco_cursus_dut.formsemestre_has_decisions(
formsemestre_id
), "décisions manquantes"
# Suppression de la décision
sco_formsemestre_validation.formsemestre_validation_suppress_etud(
formsemestre_id, etudid
)
assert not sco_parcours_dut.formsemestre_has_decisions(
assert not sco_cursus_dut.formsemestre_has_decisions(
formsemestre_id
), "décisions non effacées"