forked from ScoDoc/ScoDoc
Models => ScoDocModel. Elimine warnings SQLAlechmy 2.
This commit is contained in:
parent
6aaacbe42e
commit
7aec0cd2f3
@ -96,7 +96,7 @@ def departement_get(dept_id: int):
|
||||
/departement/id/1;
|
||||
|
||||
"""
|
||||
dept = Departement.query.get_or_404(dept_id)
|
||||
dept = Departement.get_or_404(dept_id)
|
||||
return dept.to_dict()
|
||||
|
||||
|
||||
@ -212,7 +212,7 @@ def departement_etudiants_by_id(dept_id: int):
|
||||
"""
|
||||
Retourne la liste des étudiants d'un département d'id donné.
|
||||
"""
|
||||
dept = Departement.query.get_or_404(dept_id)
|
||||
dept = Departement.get_or_404(dept_id)
|
||||
return [etud.to_dict_short() for etud in dept.etudiants]
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ def departement_formsemestres_ids_by_id(dept_id: int):
|
||||
/departement/id/1/formsemestres_ids;
|
||||
|
||||
"""
|
||||
dept = Departement.query.get_or_404(dept_id)
|
||||
dept = Departement.get_or_404(dept_id)
|
||||
return [formsemestre.id for formsemestre in dept.formsemestres]
|
||||
|
||||
|
||||
@ -273,7 +273,7 @@ def departement_formsemestres_courants(acronym: str = "", dept_id: int | None =
|
||||
dept = (
|
||||
Departement.query.filter_by(acronym=acronym).first_or_404()
|
||||
if acronym
|
||||
else Departement.query.get_or_404(dept_id)
|
||||
else Departement.get_or_404(dept_id)
|
||||
)
|
||||
date_courante = request.args.get("date_courante")
|
||||
date_courante = datetime.fromisoformat(date_courante) if date_courante else None
|
||||
|
@ -215,7 +215,7 @@ def evaluation_create(moduleimpl_id: int):
|
||||
/moduleimpl/1/evaluation/create;{""description"":""Exemple éval.""}
|
||||
|
||||
"""
|
||||
moduleimpl: ModuleImpl = ModuleImpl.query.get_or_404(moduleimpl_id)
|
||||
moduleimpl: ModuleImpl = ModuleImpl.get_or_404(moduleimpl_id)
|
||||
if not moduleimpl.can_edit_evaluation(current_user):
|
||||
return scu.json_error(403, "opération non autorisée")
|
||||
data = request.get_json(force=True) # may raise 400 Bad Request
|
||||
|
@ -199,7 +199,7 @@ def ue_set_parcours(ue_id: int):
|
||||
parcours = []
|
||||
else:
|
||||
parcours = [
|
||||
ApcParcours.query.get_or_404(int(parcour_id)) for parcour_id in parcours_ids
|
||||
ApcParcours.get_or_404(int(parcour_id)) for parcour_id in parcours_ids
|
||||
]
|
||||
log(f"ue_set_parcours: ue_id={ue.id} parcours_ids={parcours_ids}")
|
||||
ok, error_message = ue.set_parcours(parcours)
|
||||
@ -226,7 +226,7 @@ def ue_assoc_niveau(ue_id: int, niveau_id: int):
|
||||
if g.scodoc_dept:
|
||||
query = query.join(Formation).filter_by(dept_id=g.scodoc_dept_id)
|
||||
ue: UniteEns = query.first_or_404()
|
||||
niveau: ApcNiveau = ApcNiveau.query.get_or_404(niveau_id)
|
||||
niveau: ApcNiveau = ApcNiveau.get_or_404(niveau_id)
|
||||
ok, error_message = ue.set_niveau_competence(niveau)
|
||||
if not ok:
|
||||
if g.scodoc_dept: # "usage web"
|
||||
|
@ -615,13 +615,13 @@ def formsemestre_etat_evaluations(formsemestre_id: int):
|
||||
result = []
|
||||
for modimpl_id in nt.modimpls_results:
|
||||
modimpl_results: ModuleImplResults = nt.modimpls_results[modimpl_id]
|
||||
modimpl: ModuleImpl = ModuleImpl.query.get_or_404(modimpl_id)
|
||||
modimpl: ModuleImpl = ModuleImpl.get_or_404(modimpl_id)
|
||||
modimpl_dict = modimpl.to_dict(convert_objects=True, with_module=False)
|
||||
|
||||
list_eval = []
|
||||
for evaluation_id in modimpl_results.evaluations_etat:
|
||||
eval_etat = modimpl_results.evaluations_etat[evaluation_id]
|
||||
evaluation = Evaluation.query.get_or_404(evaluation_id)
|
||||
evaluation = Evaluation.get_or_404(evaluation_id)
|
||||
eval_dict = evaluation.to_dict_api()
|
||||
eval_dict["etat"] = eval_etat.to_dict()
|
||||
|
||||
|
@ -277,7 +277,7 @@ def validation_rcue_record(etudid: int):
|
||||
except ValueError:
|
||||
return json_error(API_CLIENT_ERROR, "invalid date string")
|
||||
if parcours_id is not None:
|
||||
parcours: ApcParcours = ApcParcours.query.get_or_404(parcours_id)
|
||||
parcours: ApcParcours = ApcParcours.get_or_404(parcours_id)
|
||||
if parcours.referentiel_id != ue1.niveau_competence.competence.referentiel_id:
|
||||
return json_error(API_CLIENT_ERROR, "niveau et parcours incompatibles")
|
||||
|
||||
|
@ -159,7 +159,7 @@ def group_etudiants_query(group_id: int):
|
||||
@as_json
|
||||
def group_set_etudiant(group_id: int, etudid: int):
|
||||
"""Affecte l'étudiant au groupe indiqué."""
|
||||
etud = Identite.query.get_or_404(etudid)
|
||||
etud = Identite.get_or_404(etudid)
|
||||
query = GroupDescr.query.filter_by(id=group_id)
|
||||
if g.scodoc_dept:
|
||||
query = (
|
||||
@ -192,7 +192,7 @@ def group_set_etudiant(group_id: int, etudid: int):
|
||||
@as_json
|
||||
def group_remove_etud(group_id: int, etudid: int):
|
||||
"""Retire l'étudiant de ce groupe. S'il n'y est pas, ne fait rien."""
|
||||
etud = Identite.query.get_or_404(etudid)
|
||||
etud = Identite.get_or_404(etudid)
|
||||
query = GroupDescr.query.filter_by(id=group_id)
|
||||
if g.scodoc_dept:
|
||||
query = (
|
||||
@ -224,7 +224,7 @@ def partition_remove_etud(partition_id: int, etudid: int):
|
||||
|
||||
(NB: en principe, un étudiant ne doit être que dans 0 ou 1 groupe d'une partition)
|
||||
"""
|
||||
etud = Identite.query.get_or_404(etudid)
|
||||
etud = Identite.get_or_404(etudid)
|
||||
query = Partition.query.filter_by(id=partition_id)
|
||||
if g.scodoc_dept:
|
||||
query = query.join(FormSemestre).filter_by(dept_id=g.scodoc_dept_id)
|
||||
@ -533,7 +533,7 @@ def formsemestre_set_partitions_order(formsemestre_id: int):
|
||||
message="paramètre liste des partitions invalide",
|
||||
)
|
||||
for p_id, numero in zip(partition_ids, range(len(partition_ids))):
|
||||
partition = Partition.query.get_or_404(p_id)
|
||||
partition = Partition.get_or_404(p_id)
|
||||
partition.numero = numero
|
||||
db.session.add(partition)
|
||||
db.session.commit()
|
||||
@ -579,7 +579,7 @@ def partition_order_groups(partition_id: int):
|
||||
message="paramètre liste de groupe invalide",
|
||||
)
|
||||
for group_id, numero in zip(group_ids, range(len(group_ids))):
|
||||
group = GroupDescr.query.get_or_404(group_id)
|
||||
group = GroupDescr.get_or_404(group_id)
|
||||
group.numero = numero
|
||||
db.session.add(group)
|
||||
db.session.commit()
|
||||
|
@ -188,7 +188,7 @@ def user_edit(uid: int):
|
||||
```
|
||||
"""
|
||||
args = request.get_json(force=True) # may raise 400 Bad Request
|
||||
user: User = User.query.get_or_404(uid)
|
||||
user: User = User.get_or_404(uid)
|
||||
# L'utilisateur doit avoir le droit dans le département de départ et celui d'arrivée
|
||||
orig_dept = user.dept
|
||||
dest_dept = args.get("dept", False)
|
||||
@ -241,7 +241,7 @@ def user_password(uid: int):
|
||||
/user/3/password;{""password"" : ""rePlaCemeNT456averylongandcomplicated""}
|
||||
"""
|
||||
data = request.get_json(force=True) # may raise 400 Bad Request
|
||||
user: User = User.query.get_or_404(uid)
|
||||
user: User = User.get_or_404(uid)
|
||||
password = data.get("password")
|
||||
if not password:
|
||||
return json_error(404, "user_password: missing password")
|
||||
@ -272,7 +272,7 @@ def user_password(uid: int):
|
||||
@as_json
|
||||
def user_role_add(uid: int, role_name: str, dept: str = None):
|
||||
"""Ajoute un rôle à l'utilisateur dans le département donné."""
|
||||
user: User = User.query.get_or_404(uid)
|
||||
user: User = User.get_or_404(uid)
|
||||
role: Role = Role.query.filter_by(name=role_name).first_or_404()
|
||||
if dept is not None: # check
|
||||
_ = Departement.query.filter_by(acronym=dept).first_or_404()
|
||||
@ -301,7 +301,7 @@ def user_role_add(uid: int, role_name: str, dept: str = None):
|
||||
@as_json
|
||||
def user_role_remove(uid: int, role_name: str, dept: str = None):
|
||||
"""Retire le rôle (dans le département donné) à cet utilisateur."""
|
||||
user: User = User.query.get_or_404(uid)
|
||||
user: User = User.get_or_404(uid)
|
||||
role: Role = Role.query.filter_by(name=role_name).first_or_404()
|
||||
if dept is not None: # check
|
||||
_ = Departement.query.filter_by(acronym=dept).first_or_404()
|
||||
|
@ -626,7 +626,7 @@ class AnonymousUser(AnonymousUserMixin):
|
||||
login.anonymous_user = AnonymousUser
|
||||
|
||||
|
||||
class Role(db.Model):
|
||||
class Role(ScoDocModel):
|
||||
"""Roles for ScoDoc"""
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
@ -730,7 +730,7 @@ class Role(db.Model):
|
||||
return Role.query.filter_by(name=name).first()
|
||||
|
||||
|
||||
class UserRole(db.Model):
|
||||
class UserRole(ScoDocModel):
|
||||
"""Associate user to role, in a dept.
|
||||
If dept is None, the role applies to all departments (eg super admin).
|
||||
"""
|
||||
|
@ -57,7 +57,7 @@ from app.views import ScoData
|
||||
@permission_required(Permission.ScoView)
|
||||
def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"):
|
||||
"""Page HTML affichant le bulletin BUT simplifié"""
|
||||
etud: Identite = Identite.query.get_or_404(etudid)
|
||||
etud: Identite = Identite.get_or_404(etudid)
|
||||
formsemestre: FormSemestre = (
|
||||
FormSemestre.query.filter_by(id=formsemestre_id)
|
||||
.join(FormSemestreInscription)
|
||||
|
@ -508,7 +508,7 @@ def but_validations_ues_parcours(
|
||||
# Les UEs associées au tronc commun (à aucun parcours)
|
||||
# UniteEns.query.filter(~UniteEns.id.in_(UEParcours.query.with_entities(UEParcours.ue_id)))
|
||||
|
||||
parcour = ApcParcours.query.get(parcour_id)
|
||||
parcour: ApcParcours = db.session.get(ApcParcours, parcour_id)
|
||||
if not parcour:
|
||||
raise ScoValueError(f"but_validations_ues_parcours: {parcour_id} inexistant")
|
||||
# Les validations d'UE de ce parcours ou du tronc commun pour cet étudiant:
|
||||
|
@ -1,7 +1,7 @@
|
||||
from app import db
|
||||
from app import db, models
|
||||
|
||||
|
||||
class Entreprise(db.Model):
|
||||
class Entreprise(models.ScoDocModel):
|
||||
__tablename__ = "are_entreprises"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
siret = db.Column(db.Text, index=True, unique=True)
|
||||
@ -45,7 +45,7 @@ class Entreprise(db.Model):
|
||||
}
|
||||
|
||||
|
||||
class EntrepriseSite(db.Model):
|
||||
class EntrepriseSite(models.ScoDocModel):
|
||||
__tablename__ = "are_sites"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
entreprise_id = db.Column(
|
||||
@ -65,7 +65,7 @@ class EntrepriseSite(db.Model):
|
||||
)
|
||||
|
||||
def to_dict(self):
|
||||
entreprise = Entreprise.query.get_or_404(self.entreprise_id)
|
||||
entreprise = Entreprise.get_or_404(self.entreprise_id)
|
||||
return {
|
||||
"siret_entreprise": entreprise.siret,
|
||||
"id_site": self.id,
|
||||
@ -77,7 +77,7 @@ class EntrepriseSite(db.Model):
|
||||
}
|
||||
|
||||
|
||||
class EntrepriseCorrespondant(db.Model):
|
||||
class EntrepriseCorrespondant(models.ScoDocModel):
|
||||
__tablename__ = "are_correspondants"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
site_id = db.Column(db.Integer, db.ForeignKey("are_sites.id", ondelete="cascade"))
|
||||
@ -92,7 +92,7 @@ class EntrepriseCorrespondant(db.Model):
|
||||
notes = db.Column(db.Text)
|
||||
|
||||
def to_dict(self):
|
||||
site = EntrepriseSite.query.get_or_404(self.site_id)
|
||||
site = EntrepriseSite.get_or_404(self.site_id)
|
||||
return {
|
||||
"id": self.id,
|
||||
"civilite": self.civilite,
|
||||
@ -108,7 +108,7 @@ class EntrepriseCorrespondant(db.Model):
|
||||
}
|
||||
|
||||
|
||||
class EntrepriseContact(db.Model):
|
||||
class EntrepriseContact(models.ScoDocModel):
|
||||
__tablename__ = "are_contacts"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
date = db.Column(db.DateTime(timezone=True))
|
||||
@ -119,7 +119,7 @@ class EntrepriseContact(db.Model):
|
||||
notes = db.Column(db.Text)
|
||||
|
||||
|
||||
class EntrepriseOffre(db.Model):
|
||||
class EntrepriseOffre(models.ScoDocModel):
|
||||
__tablename__ = "are_offres"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
entreprise_id = db.Column(
|
||||
@ -147,7 +147,7 @@ class EntrepriseOffre(db.Model):
|
||||
}
|
||||
|
||||
|
||||
class EntrepriseHistorique(db.Model):
|
||||
class EntrepriseHistorique(models.ScoDocModel):
|
||||
__tablename__ = "are_historique"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
||||
@ -158,7 +158,7 @@ class EntrepriseHistorique(db.Model):
|
||||
text = db.Column(db.Text)
|
||||
|
||||
|
||||
class EntrepriseStageApprentissage(db.Model):
|
||||
class EntrepriseStageApprentissage(models.ScoDocModel):
|
||||
__tablename__ = "are_stages_apprentissages"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
entreprise_id = db.Column(
|
||||
@ -176,7 +176,7 @@ class EntrepriseStageApprentissage(db.Model):
|
||||
notes = db.Column(db.Text)
|
||||
|
||||
|
||||
class EntrepriseTaxeApprentissage(db.Model):
|
||||
class EntrepriseTaxeApprentissage(models.ScoDocModel):
|
||||
__tablename__ = "are_taxe_apprentissage"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
entreprise_id = db.Column(
|
||||
@ -187,7 +187,7 @@ class EntrepriseTaxeApprentissage(db.Model):
|
||||
notes = db.Column(db.Text)
|
||||
|
||||
|
||||
class EntrepriseEnvoiOffre(db.Model):
|
||||
class EntrepriseEnvoiOffre(models.ScoDocModel):
|
||||
__tablename__ = "are_envoi_offre"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade"))
|
||||
@ -196,7 +196,7 @@ class EntrepriseEnvoiOffre(db.Model):
|
||||
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
||||
|
||||
|
||||
class EntrepriseEnvoiOffreEtudiant(db.Model):
|
||||
class EntrepriseEnvoiOffreEtudiant(models.ScoDocModel):
|
||||
__tablename__ = "are_envoi_offre_etudiant"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade"))
|
||||
@ -207,14 +207,14 @@ class EntrepriseEnvoiOffreEtudiant(db.Model):
|
||||
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
||||
|
||||
|
||||
class EntrepriseOffreDepartement(db.Model):
|
||||
class EntrepriseOffreDepartement(models.ScoDocModel):
|
||||
__tablename__ = "are_offre_departement"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
offre_id = db.Column(db.Integer, db.ForeignKey("are_offres.id", ondelete="cascade"))
|
||||
dept_id = db.Column(db.Integer, db.ForeignKey("departement.id", ondelete="cascade"))
|
||||
|
||||
|
||||
class EntreprisePreferences(db.Model):
|
||||
class EntreprisePreferences(models.ScoDocModel):
|
||||
__tablename__ = "are_preferences"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.Text)
|
||||
|
@ -1489,7 +1489,7 @@ def add_stage_apprentissage(entreprise_id):
|
||||
)
|
||||
if form.validate_on_submit():
|
||||
etudid = form.etudid.data
|
||||
etudiant = Identite.query.get_or_404(etudid)
|
||||
etudiant = Identite.get_or_404(etudid)
|
||||
formation = etudiant.inscription_courante_date(
|
||||
form.date_debut.data, form.date_fin.data
|
||||
)
|
||||
@ -1552,7 +1552,7 @@ def edit_stage_apprentissage(entreprise_id, stage_apprentissage_id):
|
||||
)
|
||||
if form.validate_on_submit():
|
||||
etudid = form.etudid.data
|
||||
etudiant = Identite.query.get_or_404(etudid)
|
||||
etudiant = Identite.get_or_404(etudid)
|
||||
formation = etudiant.inscription_courante_date(
|
||||
form.date_debut.data, form.date_fin.data
|
||||
)
|
||||
|
@ -50,7 +50,7 @@ from app.scodoc import codes_cursus
|
||||
|
||||
def formation_delete(formation_id=None, dialog_confirmed=False):
|
||||
"""Delete a formation"""
|
||||
formation: Formation = Formation.query.get_or_404(formation_id)
|
||||
formation: Formation = Formation.get_or_404(formation_id)
|
||||
|
||||
H = [
|
||||
f"""<h2>Suppression de la formation {formation.titre} ({formation.acronyme})</h2>""",
|
||||
@ -159,7 +159,7 @@ def formation_edit(formation_id=None, create=False):
|
||||
is_locked = False
|
||||
else:
|
||||
# edit an existing formation
|
||||
formation: Formation = Formation.query.get_or_404(formation_id)
|
||||
formation: Formation = Formation.get_or_404(formation_id)
|
||||
form_dict = formation.to_dict()
|
||||
form_dict["commentaire"] = form_dict["commentaire"] or ""
|
||||
initvalues = form_dict
|
||||
@ -347,7 +347,7 @@ def do_formation_edit(args) -> bool:
|
||||
if "formation_code" in args and not args["formation_code"]:
|
||||
del args["formation_code"]
|
||||
|
||||
formation: Formation = Formation.query.get_or_404(args["formation_id"])
|
||||
formation: Formation = Formation.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
|
||||
@ -386,7 +386,7 @@ def do_formation_edit(args) -> bool:
|
||||
def module_move(module_id, after=0, redirect=True):
|
||||
"""Move before/after previous one (decrement/increment numero)"""
|
||||
redirect = bool(redirect)
|
||||
module = Module.query.get_or_404(module_id)
|
||||
module = Module.get_or_404(module_id)
|
||||
after = int(after) # 0: deplace avant, 1 deplace apres
|
||||
if after not in (0, 1):
|
||||
raise ValueError(f'invalid value for "after" ({after})')
|
||||
@ -430,7 +430,7 @@ def module_move(module_id, after=0, redirect=True):
|
||||
|
||||
def ue_move(ue_id, after=0, redirect=1):
|
||||
"""Move UE before/after previous one (decrement/increment numero)"""
|
||||
ue = UniteEns.query.get_or_404(ue_id)
|
||||
ue = UniteEns.get_or_404(ue_id)
|
||||
redirect = int(redirect)
|
||||
after = int(after) # 0: deplace avant, 1 deplace apres
|
||||
if after not in (0, 1):
|
||||
|
@ -45,7 +45,7 @@ from app.scodoc.sco_exceptions import (
|
||||
|
||||
def matiere_create(ue_id=None):
|
||||
"""Formulaire création d'une matiere"""
|
||||
ue: UniteEns = UniteEns.query.get_or_404(ue_id)
|
||||
ue: UniteEns = UniteEns.get_or_404(ue_id)
|
||||
default_numero = max([mat.numero for mat in ue.matieres] or [9]) + 1
|
||||
H = [
|
||||
f"""<h2>Création d'une matière dans l'UE {ue.titre or ''} ({ue.acronyme})</h2>
|
||||
|
@ -52,7 +52,7 @@ from app.scodoc import codes_cursus
|
||||
|
||||
def module_delete(module_id=None):
|
||||
"""Formulaire suppression d'un module"""
|
||||
module = Module.query.get_or_404(module_id)
|
||||
module = Module.get_or_404(module_id)
|
||||
|
||||
if not module.can_be_deleted():
|
||||
raise ScoNonEmptyFormationObject(
|
||||
@ -149,13 +149,13 @@ def module_edit(
|
||||
formation = ue.formation
|
||||
orig_semestre_idx = ue.semestre_idx if semestre_id is None else semestre_id
|
||||
else:
|
||||
formation = Formation.query.get_or_404(formation_id)
|
||||
formation = Formation.get_or_404(formation_id)
|
||||
module = None
|
||||
unlocked = True
|
||||
else:
|
||||
if not module_id:
|
||||
raise ValueError("missing module_id !")
|
||||
module = models.Module.query.get_or_404(module_id)
|
||||
module = models.Module.get_or_404(module_id)
|
||||
ue = module.ue
|
||||
module_dict = module.to_dict()
|
||||
formation = module.formation
|
||||
@ -714,7 +714,7 @@ def module_edit(
|
||||
old_ue_id = module.ue.id
|
||||
new_ue_id = tf[2]["ue_id"]
|
||||
if (old_ue_id != new_ue_id) and in_use:
|
||||
new_ue = UniteEns.query.get_or_404(new_ue_id)
|
||||
new_ue = UniteEns.get_or_404(new_ue_id)
|
||||
if new_ue.semestre_idx != module.ue.semestre_idx:
|
||||
# pas changer de semestre un module utilisé !
|
||||
raise ScoValueError(
|
||||
@ -808,7 +808,7 @@ def formation_add_malus_modules(
|
||||
):
|
||||
"""Création d'un module de "malus" dans chaque UE d'une formation"""
|
||||
|
||||
formation = Formation.query.get_or_404(formation_id)
|
||||
formation = Formation.get_or_404(formation_id)
|
||||
|
||||
nb = 0
|
||||
ues = formation.ues
|
||||
|
@ -219,7 +219,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
|
||||
"""Formulaire modification ou création d'une UE"""
|
||||
create = int(create)
|
||||
if not create:
|
||||
ue: UniteEns = UniteEns.query.get_or_404(ue_id)
|
||||
ue: UniteEns = UniteEns.get_or_404(ue_id)
|
||||
ue_dict = ue.to_dict()
|
||||
formation_id = ue.formation_id
|
||||
title = f"Modification de l'UE {ue.acronyme} {ue.titre}"
|
||||
@ -573,7 +573,7 @@ def next_ue_numero(formation_id, semestre_id=None) -> int:
|
||||
|
||||
def ue_delete(ue_id=None, delete_validations=False, dialog_confirmed=False):
|
||||
"""Delete an UE"""
|
||||
ue = UniteEns.query.get_or_404(ue_id)
|
||||
ue = UniteEns.get_or_404(ue_id)
|
||||
if ue.modules.all():
|
||||
raise ScoValueError(
|
||||
f"""Suppression de l'UE {ue.titre} impossible car
|
||||
@ -1370,7 +1370,7 @@ def ue_sharing_code(ue_code: str = "", ue_id: int = None, hide_ue_id: int = None
|
||||
hide_ue_id spécifie un id à retirer de la liste.
|
||||
"""
|
||||
if ue_id is not None:
|
||||
ue = UniteEns.query.get_or_404(ue_id)
|
||||
ue = UniteEns.get_or_404(ue_id)
|
||||
if not ue_code:
|
||||
ue_code = ue.ue_code
|
||||
formation_code = ue.formation.formation_code
|
||||
|
@ -653,7 +653,7 @@ def formation_list_table(detail: bool) -> GenTable:
|
||||
|
||||
def formation_create_new_version(formation_id, redirect=True):
|
||||
"duplicate formation, with new version number"
|
||||
formation = Formation.query.get_or_404(formation_id)
|
||||
formation = Formation.get_or_404(formation_id)
|
||||
resp = formation_export(
|
||||
formation_id, export_ids=True, export_external_ues=True, fmt="xml"
|
||||
)
|
||||
|
@ -60,7 +60,7 @@ def formsemestre_associate_new_version(
|
||||
formsemestre_id: optionnel, formsemestre de départ, qui sera associé à la nouvelle version
|
||||
"""
|
||||
formsemestre_id = int(formsemestre_id) if formsemestre_id else None
|
||||
formation: Formation = Formation.query.get_or_404(formation_id)
|
||||
formation: Formation = Formation.get_or_404(formation_id)
|
||||
other_formsemestre_ids = {int(x) for x in (other_formsemestre_ids or [])}
|
||||
if request.method == "GET":
|
||||
# dresse la liste des semestres non verrouillés de la même formation
|
||||
@ -191,7 +191,7 @@ def do_formsemestres_associate_new_version(
|
||||
log(f"do_formsemestres_associate_new_version {formation_id} {formsemestre_ids}")
|
||||
|
||||
# Check: tous les semestres de la formation
|
||||
formsemestres = [FormSemestre.query.get_or_404(i) for i in formsemestre_ids]
|
||||
formsemestres = [FormSemestre.get_or_404(i) for i in formsemestre_ids]
|
||||
if not all(
|
||||
[formsemestre.formation_id == formation_id for formsemestre in formsemestres]
|
||||
):
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
from flask import abort, g
|
||||
import sqlalchemy
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.exc import NoResultFound
|
||||
import app
|
||||
from app import db
|
||||
|
||||
@ -164,6 +166,16 @@ class ScoDocModel(db.Model):
|
||||
return query.first()
|
||||
return query.first_or_404()
|
||||
|
||||
# Compatibilité avec SQLAlchemy 2.0
|
||||
@classmethod
|
||||
def get_or_404(cls, oid: int | str):
|
||||
"""Get instance or abort 404"""
|
||||
stmt = select(cls).where(cls.id == oid)
|
||||
try:
|
||||
return db.session.execute(stmt).scalar_one()
|
||||
except NoResultFound:
|
||||
abort(404)
|
||||
|
||||
|
||||
from app.models.absences import Absence, AbsenceNotification, BilletAbsence
|
||||
from app.models.departements import Departement
|
||||
|
@ -3,10 +3,10 @@
|
||||
"""Gestion des absences
|
||||
"""
|
||||
|
||||
from app import db
|
||||
from app import db, models
|
||||
|
||||
|
||||
class Absence(db.Model):
|
||||
class Absence(models.ScoDocModel):
|
||||
"""LEGACY
|
||||
Ce modèle n'est PLUS UTILISE depuis ScoDoc 9.6 et remplacé par assiduité.
|
||||
une absence (sur une demi-journée)
|
||||
@ -45,7 +45,7 @@ class Absence(db.Model):
|
||||
return data
|
||||
|
||||
|
||||
class AbsenceNotification(db.Model):
|
||||
class AbsenceNotification(models.ScoDocModel):
|
||||
"""Notification d'absence émise"""
|
||||
|
||||
__tablename__ = "absences_notifications"
|
||||
@ -67,7 +67,7 @@ class AbsenceNotification(db.Model):
|
||||
)
|
||||
|
||||
|
||||
class BilletAbsence(db.Model):
|
||||
class BilletAbsence(models.ScoDocModel):
|
||||
"""Billet d'absence (signalement par l'étudiant)"""
|
||||
|
||||
__tablename__ = "billet_absence"
|
||||
|
@ -752,7 +752,7 @@ def get_assiduites_justif(assiduite_id: int, long: bool) -> list[int | dict]:
|
||||
list[int | dict]: La liste des justificatifs (par défaut uniquement
|
||||
les identifiants, sinon les dict si long est vrai)
|
||||
"""
|
||||
assi: Assiduite = Assiduite.query.get_or_404(assiduite_id)
|
||||
assi: Assiduite = Assiduite.get_or_404(assiduite_id)
|
||||
return get_justifs_from_date(assi.etudid, assi.date_debut, assi.date_fin, long)
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ from flask_sqlalchemy.query import Query
|
||||
from sqlalchemy.orm import class_mapper
|
||||
import sqlalchemy
|
||||
|
||||
from app import db, log
|
||||
from app import db, log, models
|
||||
|
||||
from app.scodoc.sco_utils import ModuleType
|
||||
from app.scodoc.sco_exceptions import ScoNoReferentielCompetences, ScoValueError
|
||||
@ -56,7 +56,7 @@ class XMLModel:
|
||||
return f'<{self.__class__.__name__} {self.id} "{self.titre if hasattr(self, "titre") else ""}">'
|
||||
|
||||
|
||||
class ApcReferentielCompetences(db.Model, XMLModel):
|
||||
class ApcReferentielCompetences(models.ScoDocModel, XMLModel):
|
||||
"Référentiel de compétence d'une spécialité"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
dept_id = db.Column(
|
||||
@ -339,7 +339,7 @@ class ApcReferentielCompetences(db.Model, XMLModel):
|
||||
return doc.get(self.specialite, {})
|
||||
|
||||
|
||||
class ApcCompetence(db.Model, XMLModel):
|
||||
class ApcCompetence(models.ScoDocModel, XMLModel):
|
||||
"Compétence"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
referentiel_id = db.Column(
|
||||
@ -410,7 +410,7 @@ class ApcCompetence(db.Model, XMLModel):
|
||||
}
|
||||
|
||||
|
||||
class ApcSituationPro(db.Model, XMLModel):
|
||||
class ApcSituationPro(models.ScoDocModel, XMLModel):
|
||||
"Situation professionnelle"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
competence_id = db.Column(
|
||||
@ -425,7 +425,7 @@ class ApcSituationPro(db.Model, XMLModel):
|
||||
return {"libelle": self.libelle}
|
||||
|
||||
|
||||
class ApcComposanteEssentielle(db.Model, XMLModel):
|
||||
class ApcComposanteEssentielle(models.ScoDocModel, XMLModel):
|
||||
"Composante essentielle"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
competence_id = db.Column(
|
||||
@ -439,7 +439,7 @@ class ApcComposanteEssentielle(db.Model, XMLModel):
|
||||
return {"libelle": self.libelle}
|
||||
|
||||
|
||||
class ApcNiveau(db.Model, XMLModel):
|
||||
class ApcNiveau(models.ScoDocModel, XMLModel):
|
||||
"""Niveau de compétence
|
||||
Chaque niveau peut être associé à deux UE,
|
||||
des semestres impair et pair de la même année.
|
||||
@ -608,7 +608,7 @@ app_critiques_modules = db.Table(
|
||||
)
|
||||
|
||||
|
||||
class ApcAppCritique(db.Model, XMLModel):
|
||||
class ApcAppCritique(models.ScoDocModel, XMLModel):
|
||||
"Apprentissage Critique BUT"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
niveau_id = db.Column(
|
||||
@ -694,7 +694,7 @@ parcours_formsemestre = db.Table(
|
||||
"""Association parcours <-> formsemestre (many-to-many)"""
|
||||
|
||||
|
||||
class ApcParcours(db.Model, XMLModel):
|
||||
class ApcParcours(models.ScoDocModel, XMLModel):
|
||||
"Un parcours BUT"
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
referentiel_id = db.Column(
|
||||
@ -749,7 +749,7 @@ class ApcParcours(db.Model, XMLModel):
|
||||
)
|
||||
|
||||
|
||||
class ApcAnneeParcours(db.Model, XMLModel):
|
||||
class ApcAnneeParcours(models.ScoDocModel, XMLModel):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
parcours_id = db.Column(
|
||||
db.Integer, db.ForeignKey("apc_parcours.id", ondelete="CASCADE"), nullable=False
|
||||
@ -774,7 +774,7 @@ class ApcAnneeParcours(db.Model, XMLModel):
|
||||
}
|
||||
|
||||
|
||||
class ApcParcoursNiveauCompetence(db.Model):
|
||||
class ApcParcoursNiveauCompetence(models.ScoDocModel):
|
||||
"""Association entre année de parcours et compétence.
|
||||
Le "niveau" de la compétence est donné ici
|
||||
(convention Orébut)
|
||||
|
@ -8,7 +8,7 @@ import re
|
||||
import urllib.parse
|
||||
|
||||
from flask import flash
|
||||
from app import current_app, db, log
|
||||
from app import current_app, db, log, models
|
||||
from app.comp import bonus_spo
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.scodoc import sco_utils as scu
|
||||
@ -68,7 +68,7 @@ def code_scodoc_to_apo_default(code):
|
||||
return CODES_SCODOC_TO_APO.get(code, "DEF")
|
||||
|
||||
|
||||
class ScoDocSiteConfig(db.Model):
|
||||
class ScoDocSiteConfig(models.ScoDocModel):
|
||||
"""Config. d'un site
|
||||
Nouveau en ScoDoc 9: va regrouper les paramètres qui dans les versions
|
||||
antérieures étaient dans scodoc_config.py
|
||||
|
@ -4,7 +4,7 @@
|
||||
"""
|
||||
import re
|
||||
|
||||
from app import db
|
||||
from app import db, models
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models.preferences import ScoPreference
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
@ -12,7 +12,7 @@ from app.scodoc.sco_exceptions import ScoValueError
|
||||
VALID_DEPT_EXP = re.compile(r"^[\w@\\\-\.]+$")
|
||||
|
||||
|
||||
class Departement(db.Model):
|
||||
class Departement(models.ScoDocModel):
|
||||
"""Un département ScoDoc"""
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
@ -61,7 +61,7 @@ class Departement(db.Model):
|
||||
dept_id = None
|
||||
if dept_id is None:
|
||||
return cls.query.filter_by(acronym=dept_ident).first_or_404()
|
||||
return cls.query.get_or_404(dept_id)
|
||||
return cls.get_or_404(dept_id)
|
||||
|
||||
def to_dict(self, with_dept_name=True, with_dept_preferences=False):
|
||||
data = {
|
||||
|
@ -526,7 +526,7 @@ class Evaluation(models.ScoDocModel):
|
||||
)
|
||||
|
||||
|
||||
class EvaluationUEPoids(db.Model):
|
||||
class EvaluationUEPoids(models.ScoDocModel):
|
||||
"""Poids des évaluations (BUT)
|
||||
association many to many
|
||||
"""
|
||||
|
@ -62,7 +62,7 @@ class Scolog(ScoDocModel):
|
||||
}
|
||||
|
||||
|
||||
class ScolarNews(db.Model):
|
||||
class ScolarNews(ScoDocModel):
|
||||
"""Nouvelles pour page d'accueil"""
|
||||
|
||||
NEWS_ABS = "ABS" # saisie absence
|
||||
|
@ -1575,7 +1575,7 @@ class FormSemestreUECoef(models.ScoDocModel):
|
||||
coefficient = db.Column(db.Float, nullable=False)
|
||||
|
||||
|
||||
class FormSemestreUEComputationExpr(db.Model):
|
||||
class FormSemestreUEComputationExpr(models.ScoDocModel):
|
||||
"""Formules utilisateurs pour calcul moyenne UE (désactivées en 9.2+)."""
|
||||
|
||||
__tablename__ = "notes_formsemestre_ue_computation_expr"
|
||||
|
@ -372,11 +372,3 @@ group_membership = db.Table(
|
||||
db.Column("group_id", db.Integer, db.ForeignKey("group_descr.id")),
|
||||
db.UniqueConstraint("etudid", "group_id"),
|
||||
)
|
||||
# class GroupMembership(db.Model):
|
||||
# """Association groupe / étudiant"""
|
||||
|
||||
# __tablename__ = "group_membership"
|
||||
# __table_args__ = (db.UniqueConstraint("etudid", "group_id"),)
|
||||
# id = db.Column(db.Integer, primary_key=True)
|
||||
# etudid = db.Column(db.Integer, db.ForeignKey("identite.id", ondelete="CASCADE"))
|
||||
# group_id = db.Column(db.Integer, db.ForeignKey("group_descr.id"))
|
||||
|
@ -624,7 +624,7 @@ class Module(models.ScoDocModel):
|
||||
return "", http.HTTPStatus.NO_CONTENT
|
||||
|
||||
|
||||
class ModuleUECoef(db.Model):
|
||||
class ModuleUECoef(models.ScoDocModel):
|
||||
"""Coefficients des modules vers les UE (APC, BUT)
|
||||
En mode APC, ces coefs remplacent le coefficient "PPN" du module.
|
||||
"""
|
||||
|
@ -83,7 +83,7 @@ class NotesNotes(models.ScoDocModel):
|
||||
} {db.session.get(Evaluation, self.evaluation_id) if self.evaluation_id else "X" }>"""
|
||||
|
||||
|
||||
class NotesNotesLog(db.Model):
|
||||
class NotesNotesLog(models.ScoDocModel):
|
||||
"""Historique des modifs sur notes (anciennes entrees de notes_notes)"""
|
||||
|
||||
__tablename__ = "notes_notes_log"
|
||||
|
@ -1,10 +1,11 @@
|
||||
"""évènements scolaires dans la vie d'un étudiant(inscription, ...)
|
||||
"""
|
||||
from app import db
|
||||
|
||||
from app import db, models
|
||||
from app.models import SHORT_STR_LEN
|
||||
|
||||
|
||||
class ScolarEvent(db.Model):
|
||||
class ScolarEvent(models.ScoDocModel):
|
||||
"""Evenement dans le parcours scolaire d'un étudiant"""
|
||||
|
||||
__tablename__ = "scolar_events"
|
||||
|
@ -573,7 +573,7 @@ class UniteEns(models.ScoDocModel):
|
||||
return self.set_parcours(self.parcours + [parcour])
|
||||
|
||||
|
||||
class UEParcours(db.Model):
|
||||
class UEParcours(models.ScoDocModel):
|
||||
"""Association ue <-> parcours, indiquant les ECTS"""
|
||||
|
||||
__tablename__ = "ue_parcours"
|
||||
@ -593,7 +593,7 @@ class UEParcours(db.Model):
|
||||
return f"<UEParcours( ue_id={self.ue_id}, parcours_id={self.parcours_id}, ects={self.ects})>"
|
||||
|
||||
|
||||
class DispenseUE(db.Model):
|
||||
class DispenseUE(models.ScoDocModel):
|
||||
"""Dispense d'UE
|
||||
Utilisé en APC (BUT) pour indiquer
|
||||
- les étudiants redoublants avec une UE capitalisée qu'ils ne refont pas.
|
||||
|
@ -4,8 +4,7 @@
|
||||
"""
|
||||
from flask_sqlalchemy.query import Query
|
||||
|
||||
from app import db
|
||||
from app import log
|
||||
from app import db, log, models
|
||||
from app.models import SHORT_STR_LEN
|
||||
from app.models import CODE_STR_LEN
|
||||
from app.models.events import Scolog
|
||||
@ -16,7 +15,7 @@ from app.scodoc import sco_utils as scu
|
||||
from app.scodoc.codes_cursus import CODES_UE_VALIDES
|
||||
|
||||
|
||||
class ScolarFormSemestreValidation(db.Model):
|
||||
class ScolarFormSemestreValidation(models.ScoDocModel):
|
||||
"""Décisions de jury (sur semestre ou UEs)"""
|
||||
|
||||
__tablename__ = "scolar_formsemestre_validation"
|
||||
@ -158,7 +157,7 @@ class ScolarFormSemestreValidation(db.Model):
|
||||
)
|
||||
|
||||
|
||||
class ScolarAutorisationInscription(db.Model):
|
||||
class ScolarAutorisationInscription(models.ScoDocModel):
|
||||
"""Autorisation d'inscription dans un semestre"""
|
||||
|
||||
__tablename__ = "scolar_autorisation_inscription"
|
||||
|
@ -282,7 +282,7 @@ class ApoEtud(dict):
|
||||
):
|
||||
res = self.autre_res
|
||||
else:
|
||||
formsemestre = FormSemestre.query.get_or_404(sem["formsemestre_id"])
|
||||
formsemestre = FormSemestre.get_or_404(sem["formsemestre_id"])
|
||||
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
|
||||
if etudid not in res.identdict:
|
||||
@ -761,7 +761,7 @@ class ApoData:
|
||||
if not self.sems_etape:
|
||||
raise ScoValueError("aucun semestre trouvé !")
|
||||
self.formsemestres_etape = [
|
||||
FormSemestre.query.get_or_404(s["formsemestre_id"]) for s in self.sems_etape
|
||||
FormSemestre.get_or_404(s["formsemestre_id"]) for s in self.sems_etape
|
||||
]
|
||||
apcs = {
|
||||
formsemestre.formation.is_apc() for formsemestre in self.formsemestres_etape
|
||||
@ -903,9 +903,7 @@ class ApoData:
|
||||
"""
|
||||
codes_by_sem = {}
|
||||
for sem in self.sems_etape:
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(
|
||||
sem["formsemestre_id"]
|
||||
)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(sem["formsemestre_id"])
|
||||
# L'ensemble des codes apo associés aux éléments:
|
||||
codes_semestre = formsemestre.get_codes_apogee()
|
||||
codes_modules = set().union(
|
||||
|
@ -416,7 +416,7 @@ def formsemestre_get_archived_file(formsemestre_id, archive_name, filename):
|
||||
|
||||
def formsemestre_delete_archive(formsemestre_id, archive_name, dialog_confirmed=False):
|
||||
"""Delete an archive"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_pv():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
|
@ -159,7 +159,7 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"):
|
||||
|
||||
# Formation et parcours
|
||||
if I["sem"]["formation_id"]:
|
||||
formation_dict = Formation.query.get_or_404(I["sem"]["formation_id"]).to_dict()
|
||||
formation_dict = Formation.get_or_404(I["sem"]["formation_id"]).to_dict()
|
||||
else: # what's the fuck ?
|
||||
formation_dict = {
|
||||
"acronyme": "?",
|
||||
|
@ -225,7 +225,7 @@ def get_formsemestre_bulletins_pdf(
|
||||
from app.but import bulletin_but_court
|
||||
from app.scodoc import sco_bulletins
|
||||
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
versions = (
|
||||
scu.BULLETINS_VERSIONS_BUT
|
||||
if formsemestre.formation.is_apc()
|
||||
|
@ -313,7 +313,7 @@ class SituationEtudCursusClassic(SituationEtudCursus):
|
||||
sont validés. En sortie, sem_idx_set contient ceux qui n'ont pas été validés."""
|
||||
for sem in self.get_semestres():
|
||||
if sem["formation_code"] == self.formation.formation_code:
|
||||
formsemestre = FormSemestre.query.get_or_404(sem["formsemestre_id"])
|
||||
formsemestre = FormSemestre.get_or_404(sem["formsemestre_id"])
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
decision = nt.get_etud_decision_sem(self.etudid)
|
||||
if decision and code_semestre_validant(decision["code"]):
|
||||
@ -408,7 +408,7 @@ class SituationEtudCursusClassic(SituationEtudCursus):
|
||||
if not sem:
|
||||
code = "" # non inscrit à ce semestre
|
||||
else:
|
||||
formsemestre = FormSemestre.query.get_or_404(sem["formsemestre_id"])
|
||||
formsemestre = FormSemestre.get_or_404(sem["formsemestre_id"])
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
decision = nt.get_etud_decision_sem(self.etudid)
|
||||
if decision:
|
||||
@ -949,7 +949,7 @@ def do_formsemestre_validate_ue(
|
||||
):
|
||||
"""Ajoute ou change validation UE"""
|
||||
if semestre_id is None:
|
||||
ue = UniteEns.query.get_or_404(ue_id)
|
||||
ue = UniteEns.get_or_404(ue_id)
|
||||
semestre_id = ue.semestre_idx
|
||||
args = {
|
||||
"formsemestre_id": formsemestre_id,
|
||||
|
@ -347,7 +347,7 @@ def apo_semset_maq_status(
|
||||
if missing:
|
||||
formation_ids = {sem["formation_id"] for sem in semset.sems}
|
||||
formations = [
|
||||
Formation.query.get_or_404(formation_id) for formation_id in formation_ids
|
||||
Formation.get_or_404(formation_id) for formation_id in formation_ids
|
||||
]
|
||||
H.append(
|
||||
f"""<div class="apo_csv_status_missing_elems">
|
||||
|
@ -64,7 +64,7 @@ def _build_results_table(start_date=None, end_date=None, types_parcours=()):
|
||||
semlist = [dpv["formsemestre"] for dpv in dpv_by_sem.values() if dpv]
|
||||
semlist_parcours = []
|
||||
for sem in semlist:
|
||||
sem["formation"] = Formation.query.get_or_404(sem["formation_id"]).to_dict()
|
||||
sem["formation"] = Formation.get_or_404(sem["formation_id"]).to_dict()
|
||||
sem["parcours"] = codes_cursus.get_cursus_from_code(
|
||||
sem["formation"]["type_parcours"]
|
||||
)
|
||||
|
@ -148,7 +148,7 @@ def _formsemestre_enrich(sem):
|
||||
# imports ici pour eviter refs circulaires
|
||||
from app.scodoc import sco_formsemestre_edit
|
||||
|
||||
formation: Formation = Formation.query.get_or_404(sem["formation_id"])
|
||||
formation: Formation = Formation.get_or_404(sem["formation_id"])
|
||||
parcours = codes_cursus.get_cursus_from_code(formation.type_parcours)
|
||||
# 'S1', 'S2', ... ou '' pour les monosemestres
|
||||
if sem["semestre_id"] != NO_SEMESTRE_ID:
|
||||
|
@ -181,7 +181,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N
|
||||
formation = formsemestre.formation
|
||||
else:
|
||||
formation_id = int(vals["formation_id"])
|
||||
formation = Formation.query.get_or_404(formation_id)
|
||||
formation = Formation.get_or_404(formation_id)
|
||||
|
||||
is_apc = formation.is_apc()
|
||||
if not edit:
|
||||
@ -1076,10 +1076,10 @@ def _formsemestre_check_module_list(module_ids, semestre_idx):
|
||||
"""
|
||||
# vérification de la cohérence / modules / semestre
|
||||
mod_sems_idx = {
|
||||
Module.query.get_or_404(module_id).ue.semestre_idx for module_id in module_ids
|
||||
Module.get_or_404(module_id).ue.semestre_idx for module_id in module_ids
|
||||
}
|
||||
if mod_sems_idx and mod_sems_idx != {semestre_idx}:
|
||||
modules = [Module.query.get_or_404(module_id) for module_id in module_ids]
|
||||
modules = [Module.get_or_404(module_id) for module_id in module_ids]
|
||||
log(
|
||||
f"""_formsemestre_check_module_list:
|
||||
{chr(10).join( str(module) + " " + str(module.ue) for module in modules )}
|
||||
@ -1097,7 +1097,7 @@ def _formsemestre_check_module_list(module_ids, semestre_idx):
|
||||
|
||||
def _formsemestre_check_ue_bonus_unicity(module_ids):
|
||||
"""Vérifie qu'il n'y a qu'une seule UE bonus associée aux modules choisis"""
|
||||
ues = [Module.query.get_or_404(module_id).ue for module_id in module_ids]
|
||||
ues = [Module.get_or_404(module_id).ue for module_id in module_ids]
|
||||
ues_bonus = {ue.id for ue in ues if ue.type == codes_cursus.UE_SPORT}
|
||||
if len(ues_bonus) > 1:
|
||||
raise ScoValueError(
|
||||
@ -1294,9 +1294,7 @@ def do_formsemestre_clone(
|
||||
New dates, responsable_id
|
||||
"""
|
||||
log(f"do_formsemestre_clone: {orig_formsemestre_id}")
|
||||
formsemestre_orig: FormSemestre = FormSemestre.query.get_or_404(
|
||||
orig_formsemestre_id
|
||||
)
|
||||
formsemestre_orig: FormSemestre = FormSemestre.get_or_404(orig_formsemestre_id)
|
||||
# 1- create sem
|
||||
args = formsemestre_orig.to_dict()
|
||||
del args["formsemestre_id"]
|
||||
|
@ -61,7 +61,7 @@ def formsemestre_ext_create(etud: Identite | None, sem_params: dict) -> FormSeme
|
||||
sem_params: dict nécessaire à la création du formsemestre
|
||||
"""
|
||||
# Check args
|
||||
_ = Formation.query.get_or_404(sem_params["formation_id"])
|
||||
_ = Formation.get_or_404(sem_params["formation_id"])
|
||||
|
||||
# Create formsemestre
|
||||
sem_params["modalite"] = "EXT"
|
||||
@ -230,7 +230,7 @@ def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid):
|
||||
La moyenne générale indicative du semestre est calculée et affichée,
|
||||
mais pas enregistrée.
|
||||
"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
etud = Identite.get_etud(etudid)
|
||||
ues = formsemestre.formation.ues.filter(UniteEns.type != UE_SPORT).order_by(
|
||||
UniteEns.semestre_idx, UniteEns.numero
|
||||
|
@ -248,9 +248,7 @@ def do_formsemestre_inscription_with_modules(
|
||||
group_ids = [group_ids]
|
||||
# Check that all groups exist before creating the inscription
|
||||
groups = [
|
||||
GroupDescr.query.get_or_404(group_id)
|
||||
for group_id in group_ids
|
||||
if group_id != ""
|
||||
GroupDescr.get_or_404(group_id) for group_id in group_ids if group_id != ""
|
||||
]
|
||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id, dept_id=dept_id)
|
||||
# Inscription au semestre
|
||||
@ -377,7 +375,7 @@ def formsemestre_inscription_with_modules(
|
||||
)
|
||||
if multiple_ok:
|
||||
multiple_ok = int(multiple_ok)
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
etud = Identite.get_etud(etudid)
|
||||
if etud.dept_id != formsemestre.dept_id:
|
||||
raise ScoValueError("l'étudiant n'est pas dans ce département")
|
||||
|
@ -1079,7 +1079,7 @@ def formsemestre_status(formsemestre_id=None, check_parcours=True):
|
||||
raise ScoInvalidIdType(
|
||||
"formsemestre_bulletinetud: formsemestre_id must be an integer !"
|
||||
)
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
# S'assure que les groupes de parcours sont à jour:
|
||||
if int(check_parcours):
|
||||
formsemestre.setup_parcours_groups()
|
||||
|
@ -1383,7 +1383,7 @@ def do_formsemestre_validate_previous_ue(
|
||||
cette UE (utile seulement pour les semestres extérieurs).
|
||||
"""
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
ue: UniteEns = UniteEns.query.get_or_404(ue_id)
|
||||
ue: UniteEns = UniteEns.get_or_404(ue_id)
|
||||
|
||||
cnx = ndb.GetDBConnexion()
|
||||
if ue_coefficient is not None:
|
||||
|
@ -663,7 +663,7 @@ def change_etud_group_in_partition(etudid: int, group: GroupDescr) -> bool:
|
||||
(et le désinscrit d'autres groupes de cette partition)
|
||||
Return True si changement, False s'il était déjà dans ce groupe.
|
||||
"""
|
||||
etud: Identite = Identite.query.get_or_404(etudid)
|
||||
etud: Identite = Identite.get_or_404(etudid)
|
||||
if not group.partition.set_etud_group(etud, group):
|
||||
return # pas de changement
|
||||
|
||||
@ -742,7 +742,7 @@ groupsToDelete={groupsToDelete}
|
||||
except ValueError:
|
||||
log(f"setGroups: ignoring invalid group_id={group_id}")
|
||||
continue
|
||||
group: GroupDescr = GroupDescr.query.get_or_404(group_id)
|
||||
group: GroupDescr = GroupDescr.get_or_404(group_id)
|
||||
# Anciens membres du groupe:
|
||||
old_members_set = {etud.id for etud in group.etuds}
|
||||
# Place dans ce groupe les etudiants indiqués:
|
||||
@ -807,7 +807,7 @@ def create_group(partition_id, group_name="", default=False) -> GroupDescr:
|
||||
If default, create default partition (with no name)
|
||||
Obsolete: utiliser Partition.create_group
|
||||
"""
|
||||
partition = Partition.query.get_or_404(partition_id)
|
||||
partition = Partition.get_or_404(partition_id)
|
||||
if not partition.formsemestre.can_change_groups():
|
||||
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
||||
#
|
||||
@ -840,7 +840,7 @@ def delete_group(group_id, partition_id=None):
|
||||
est bien dans cette partition.
|
||||
S'il s'agit d'un groupe de parcours, affecte l'inscription des étudiants aux parcours.
|
||||
"""
|
||||
group = GroupDescr.query.get_or_404(group_id)
|
||||
group = GroupDescr.get_or_404(group_id)
|
||||
if partition_id:
|
||||
if partition_id != group.partition_id:
|
||||
raise ValueError("inconsistent partition/group")
|
||||
@ -1096,7 +1096,7 @@ def partition_set_attr(partition_id, attr, value):
|
||||
if attr not in {"bul_show_rank", "show_in_lists"}:
|
||||
raise ValueError(f"invalid partition attribute: {attr}")
|
||||
|
||||
partition = Partition.query.get_or_404(partition_id)
|
||||
partition = Partition.get_or_404(partition_id)
|
||||
if not partition.formsemestre.can_change_groups():
|
||||
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
||||
|
||||
|
@ -42,7 +42,7 @@ def affect_groups(partition_id):
|
||||
Permet aussi la creation et la suppression de groupes.
|
||||
"""
|
||||
# réécrit pour 9.0.47 avec un template
|
||||
partition = Partition.query.get_or_404(partition_id)
|
||||
partition = Partition.get_or_404(partition_id)
|
||||
formsemestre = partition.formsemestre
|
||||
if not formsemestre.can_change_groups():
|
||||
raise AccessDenied("vous n'avez pas la permission de modifier les groupes")
|
||||
@ -63,7 +63,7 @@ def affect_groups(partition_id):
|
||||
|
||||
def group_rename(group_id):
|
||||
"""Form to rename a group"""
|
||||
group: GroupDescr = GroupDescr.query.get_or_404(group_id)
|
||||
group: GroupDescr = GroupDescr.get_or_404(group_id)
|
||||
formsemestre_id = group.partition.formsemestre_id
|
||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
if not formsemestre.can_change_groups():
|
||||
|
@ -370,7 +370,7 @@ class DisplayedGroupsInfos:
|
||||
|
||||
if not group_ids: # appel sans groupe (eg page accueil)
|
||||
if not formsemestre_id:
|
||||
raise ValueError("missing parameter formsemestre_id or group_ids")
|
||||
raise ScoValueError("missing parameter formsemestre_id or group_ids")
|
||||
if empty_list_select_all:
|
||||
if select_all_when_unspecified:
|
||||
group_ids = [
|
||||
|
@ -399,7 +399,7 @@ def moduleimpl_inscriptions_stats(formsemestre_id):
|
||||
H.append(
|
||||
'<h3>Étudiants avec UEs capitalisées (ADM):</h3><ul class="ue_inscr_list">'
|
||||
)
|
||||
ues = [UniteEns.query.get_or_404(ue_id) for ue_id in ues_cap_info.keys()]
|
||||
ues = [UniteEns.get_or_404(ue_id) for ue_id in ues_cap_info.keys()]
|
||||
ues.sort(key=lambda u: u.numero)
|
||||
for ue in ues:
|
||||
H.append(
|
||||
|
@ -369,7 +369,7 @@ def copy_portal_photo_to_fs(etudid: int):
|
||||
"""Copy the photo from portal (distant website) to local fs.
|
||||
Returns rel. path or None if copy failed, with a diagnostic message
|
||||
"""
|
||||
etud: Identite = Identite.query.get_or_404(etudid)
|
||||
etud: Identite = Identite.get_or_404(etudid)
|
||||
url = photo_portal_url(etud.code_nip)
|
||||
if not url:
|
||||
return None, f"""{etud.nomprenom}: pas de code NIP"""
|
||||
|
@ -60,7 +60,7 @@ def etud_get_poursuite_info(sem: dict, etud: dict) -> dict:
|
||||
for s in etud["sems"]:
|
||||
if s["semestre_id"] == sem_id:
|
||||
etudid = etud["etudid"]
|
||||
formsemestre = FormSemestre.query.get_or_404(s["formsemestre_id"])
|
||||
formsemestre = FormSemestre.get_or_404(s["formsemestre_id"])
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
dec = nt.get_etud_decision_sem(etudid)
|
||||
# Moyennes et rangs des UE
|
||||
|
@ -91,7 +91,7 @@ def dict_pvjury(
|
||||
'decisions_dict' : { etudid : decision (comme ci-dessus) },
|
||||
}
|
||||
"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
if etudids is None:
|
||||
etudids = nt.get_etudids()
|
||||
@ -231,7 +231,7 @@ def dict_pvjury(
|
||||
"is_apc": nt.is_apc,
|
||||
"has_prev": has_prev,
|
||||
"semestre_non_terminal": semestre_non_terminal,
|
||||
"formation": Formation.query.get_or_404(sem["formation_id"]).to_dict(),
|
||||
"formation": Formation.get_or_404(sem["formation_id"]).to_dict(),
|
||||
"decisions": decisions,
|
||||
"decisions_dict": D,
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ def descrform_pvjury(formsemestre: FormSemestre):
|
||||
|
||||
def formsemestre_lettres_individuelles(formsemestre_id):
|
||||
"Lettres avis jury en PDF"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if request.method == "POST":
|
||||
group_ids = request.form.getlist("group_ids")
|
||||
else:
|
||||
|
@ -533,7 +533,7 @@ def table_suivi_cohorte(
|
||||
s["members"] = orig_set.intersection(inset)
|
||||
nb_dipl = 0 # combien de diplomes dans ce semestre ?
|
||||
if s["semestre_id"] == nt.parcours.NB_SEM:
|
||||
s_formsemestre = FormSemestre.query.get_or_404(s["formsemestre_id"])
|
||||
s_formsemestre = FormSemestre.get_or_404(s["formsemestre_id"])
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(s_formsemestre)
|
||||
for etudid in s["members"]:
|
||||
dec = nt.get_etud_decision_sem(etudid)
|
||||
@ -1114,7 +1114,7 @@ def get_code_cursus_etud(
|
||||
|
||||
if formsemestres is None:
|
||||
formsemestres = [
|
||||
FormSemestre.query.get_or_404(s["formsemestre_id"]) for s in (sems or [])
|
||||
FormSemestre.get_or_404(s["formsemestre_id"]) for s in (sems or [])
|
||||
]
|
||||
|
||||
# élimine les semestres spéciaux hors cursus (LP en 1 sem., ...)
|
||||
@ -1448,7 +1448,7 @@ def graph_cursus(
|
||||
nxt = {}
|
||||
etudid = etud["etudid"]
|
||||
for s in etud["sems"]: # du plus recent au plus ancien
|
||||
s_formsemestre = FormSemestre.query.get_or_404(s["formsemestre_id"])
|
||||
s_formsemestre = FormSemestre.get_or_404(s["formsemestre_id"])
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(s_formsemestre)
|
||||
dec = nt.get_etud_decision_sem(etudid)
|
||||
if nxt:
|
||||
|
@ -66,7 +66,7 @@ INDICATEUR_NAMES = {
|
||||
|
||||
def formsemestre_but_indicateurs(formsemestre_id: int, fmt="html"):
|
||||
"""Page avec tableau indicateurs enquête ADIUT BUT 2022"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
|
||||
indicateurs_by_bac = but_indicateurs_by_bac(formsemestre)
|
||||
# finalement on fait une table avec en ligne
|
||||
|
@ -326,7 +326,7 @@ def do_evaluation_set_missing(
|
||||
|
||||
def evaluation_suppress_alln(evaluation_id, dialog_confirmed=False):
|
||||
"suppress all notes in this eval"
|
||||
evaluation = Evaluation.query.get_or_404(evaluation_id)
|
||||
evaluation = Evaluation.get_or_404(evaluation_id)
|
||||
|
||||
if evaluation.moduleimpl.can_edit_notes(current_user, allow_ens=False):
|
||||
# On a le droit de modifier toutes les notes
|
||||
|
@ -157,7 +157,7 @@ class SemSet(dict):
|
||||
def add(self, formsemestre_id):
|
||||
"Ajoute ce semestre à l'ensemble"
|
||||
# check for valid formsemestre_id
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
# check
|
||||
if formsemestre_id in self.formsemestre_ids:
|
||||
return # already there
|
||||
@ -265,7 +265,7 @@ class SemSet(dict):
|
||||
self["jury_nb_missing"] = 0
|
||||
is_apc = None
|
||||
for sem in self.sems:
|
||||
formsemestre = FormSemestre.query.get_or_404(sem["formsemestre_id"])
|
||||
formsemestre = FormSemestre.get_or_404(sem["formsemestre_id"])
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
if is_apc is not None and is_apc != nt.is_apc:
|
||||
raise ScoValueError(
|
||||
|
@ -848,7 +848,7 @@ def formsemestre_import_etud_admission(
|
||||
|
||||
for i in ins:
|
||||
etudid = i["etudid"]
|
||||
etud: Identite = Identite.query.get_or_404(etudid)
|
||||
etud: Identite = Identite.get_or_404(etudid)
|
||||
code_nip = etud.code_nip
|
||||
if not code_nip:
|
||||
etuds_no_nip.append(etud)
|
||||
|
@ -182,7 +182,7 @@ def formsemestre_list_saisies_notes(formsemestre_id, fmt="html"):
|
||||
"""Table listant toutes les opérations de saisies de notes, dans toutes
|
||||
les évaluations du semestre.
|
||||
"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
rows = ndb.SimpleDictFetch(
|
||||
"""SELECT i.nom, i.prenom, code_nip, n.*, mod.titre, e.description, e.date_debut,
|
||||
u.user_name, e.id as evaluation_id
|
||||
|
@ -5,14 +5,14 @@ Gestion des listes d'assiduités et justificatifs
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from flask import url_for, request
|
||||
from flask import url_for
|
||||
from flask_login import current_user
|
||||
from flask_sqlalchemy.query import Query
|
||||
from sqlalchemy import desc, literal, union, asc
|
||||
|
||||
from app import db, g
|
||||
from app.auth.models import User
|
||||
from app.models import Assiduite, Identite, Justificatif, Module
|
||||
from app.models import Assiduite, Identite, Justificatif, Module, ScoDocModel
|
||||
import app.scodoc.sco_utils as scu
|
||||
|
||||
from app.scodoc.sco_utils import (
|
||||
@ -715,7 +715,7 @@ class AssiFiltre:
|
||||
if date_fin is not None:
|
||||
self.filtres["date_fin"]: tuple[int, datetime] = date_fin
|
||||
|
||||
def filtrage(self, query: Query, obj_class: db.Model) -> Query:
|
||||
def filtrage(self, query: Query, obj_class: ScoDocModel) -> Query:
|
||||
"""
|
||||
filtrage Filtre la query passée en paramètre et retourne l'objet filtré
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ def signal_assiduites_group():
|
||||
# --- Filtrage par formsemestre ---
|
||||
formsemestre_id = groups_infos.formsemestre_id
|
||||
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if formsemestre.dept_id != g.scodoc_dept_id:
|
||||
abort(404, "groupes inexistants dans ce département")
|
||||
|
||||
@ -1243,7 +1243,7 @@ def etat_abs_date():
|
||||
raise ScoValueError("date_fin invalide") from exc
|
||||
|
||||
# Les groupes:
|
||||
groups = [GroupDescr.query.get_or_404(group_id) for group_id in group_ids]
|
||||
groups = [GroupDescr.get_or_404(group_id) for group_id in group_ids]
|
||||
# Les étudiants de tous les groupes sélectionnés, flat list
|
||||
etuds = [
|
||||
etud for gr_etuds in [group.etuds for group in groups] for etud in gr_etuds
|
||||
@ -1534,11 +1534,11 @@ def recup_assiduites_plage():
|
||||
name: str = ""
|
||||
|
||||
if formsemestre_id is not None and formsemestre_id != "":
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
etuds = formsemestre.etuds
|
||||
name = formsemestre.session_id()
|
||||
else:
|
||||
dept: Departement = Departement.query.get_or_404(g.scodoc_dept_id)
|
||||
dept: Departement = Departement.get_or_404(g.scodoc_dept_id)
|
||||
etuds = dept.etudiants
|
||||
name = dept.acronym
|
||||
|
||||
@ -1603,11 +1603,11 @@ def tableau_assiduite_actions():
|
||||
objet_name = ""
|
||||
e = ""
|
||||
if obj_type == "assiduite":
|
||||
objet: Assiduite = Assiduite.query.get_or_404(obj_id)
|
||||
objet: Assiduite = Assiduite.get_or_404(obj_id)
|
||||
objet_name = scu.EtatAssiduite(objet.etat).version_lisible()
|
||||
e = scu.EtatAssiduite(objet.etat).e()
|
||||
else:
|
||||
objet: Justificatif = Justificatif.query.get_or_404(obj_id)
|
||||
objet: Justificatif = Justificatif.get_or_404(obj_id)
|
||||
objet_name = "Justificatif"
|
||||
|
||||
# Suppression : attention, POST ou GET !
|
||||
@ -1738,7 +1738,7 @@ def signale_evaluation_abs(etudid: int = None, evaluation_id: int = None):
|
||||
sinon l'utilisateur sera redirigé vers la page de saisie des absences de l'étudiant
|
||||
"""
|
||||
etud = Identite.get_etud(etudid)
|
||||
evaluation: Evaluation = Evaluation.query.get_or_404(evaluation_id)
|
||||
evaluation: Evaluation = Evaluation.get_or_404(evaluation_id)
|
||||
|
||||
delta: datetime.timedelta = evaluation.date_fin - evaluation.date_debut
|
||||
# Si l'évaluation dure plus qu'un jour alors on redirige vers la page de saisie etudiant
|
||||
|
@ -105,8 +105,8 @@ def validation_rcues(
|
||||
"""Visualisation des résultats UEs et RCUEs d'un étudiant
|
||||
et saisie des validation de RCUE antérieures.
|
||||
"""
|
||||
etud: Identite = Identite.query.get_or_404(etudid)
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
etud: Identite = Identite.get_or_404(etudid)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if edit: # check permission
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
|
@ -94,7 +94,7 @@ def formsemestre_validation_etud_form(
|
||||
sortcol=None,
|
||||
):
|
||||
"Formulaire choix jury pour un étudiant"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
read_only = not formsemestre.can_edit_jury()
|
||||
if formsemestre.formation.is_apc():
|
||||
return redirect(
|
||||
@ -128,7 +128,7 @@ def formsemestre_validation_etud(
|
||||
sortcol=None,
|
||||
):
|
||||
"Enregistre choix jury pour un étudiant"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
@ -162,7 +162,7 @@ def formsemestre_validation_etud_manu(
|
||||
sortcol=None,
|
||||
):
|
||||
"Enregistre choix jury pour un étudiant"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
@ -521,7 +521,7 @@ def formsemestre_validation_but(
|
||||
@permission_required(Permission.ScoView)
|
||||
def formsemestre_validation_auto_but(formsemestre_id: int = None):
|
||||
"Saisie automatique des décisions de jury BUT"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
@ -583,7 +583,7 @@ def formsemestre_validation_auto_but(formsemestre_id: int = None):
|
||||
@permission_required(Permission.ScoView)
|
||||
def formsemestre_validate_previous_ue(formsemestre_id, etudid=None):
|
||||
"Form. saisie UE validée hors ScoDoc"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
@ -610,7 +610,7 @@ def formsemestre_validate_previous_ue(formsemestre_id, etudid=None):
|
||||
@scodoc7func
|
||||
def formsemestre_ext_edit_ue_validations(formsemestre_id, etudid=None):
|
||||
"Form. edition UE semestre extérieur"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
@ -660,7 +660,7 @@ def formsemestre_validation_auto(formsemestre_id):
|
||||
@scodoc7func
|
||||
def do_formsemestre_validation_auto(formsemestre_id):
|
||||
"Formulaire saisie automatisee des decisions d'un semestre"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
@ -681,7 +681,7 @@ def formsemestre_validation_suppress_etud(
|
||||
formsemestre_id, etudid, dialog_confirmed=False
|
||||
):
|
||||
"""Suppression des décisions de jury pour un étudiant."""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not formsemestre.can_edit_jury():
|
||||
raise ScoPermissionDenied(
|
||||
dest_url=url_for(
|
||||
@ -884,7 +884,7 @@ def erase_decisions_annee_formation(etudid: int, formation_id: int, annee: int):
|
||||
validations = jury.erase_decisions_annee_formation(etud, formation, annee)
|
||||
formsemestre_origine_id = request.args.get("formsemestre_id")
|
||||
formsemestre_origine = (
|
||||
FormSemestre.query.get_or_404(formsemestre_origine_id)
|
||||
FormSemestre.get_or_404(formsemestre_origine_id)
|
||||
if formsemestre_origine_id
|
||||
else None
|
||||
)
|
||||
|
@ -456,8 +456,8 @@ def set_ue_niveau_competence():
|
||||
niveau_id = request.form.get("niveau_id")
|
||||
if niveau_id == "":
|
||||
niveau_id = None
|
||||
ue: UniteEns = UniteEns.query.get_or_404(ue_id)
|
||||
niveau = None if niveau_id is None else ApcNiveau.query.get_or_404(niveau_id)
|
||||
ue: UniteEns = UniteEns.get_or_404(ue_id)
|
||||
niveau = None if niveau_id is None else ApcNiveau.get_or_404(niveau_id)
|
||||
try:
|
||||
ue.set_niveau_competence(niveau)
|
||||
except ScoFormationConflict:
|
||||
@ -476,7 +476,7 @@ def get_ue_niveaux_options_html():
|
||||
if ue_id is None:
|
||||
log("WARNING: get_ue_niveaux_options_html missing ue_id arg")
|
||||
return "???"
|
||||
ue: UniteEns = UniteEns.query.get_or_404(ue_id)
|
||||
ue: UniteEns = UniteEns.get_or_404(ue_id)
|
||||
return apc_edit_ue.get_ue_niveaux_options_html(ue)
|
||||
|
||||
|
||||
@ -494,7 +494,7 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""):
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
def ue_infos(ue_id: int):
|
||||
ue = UniteEns.query.get_or_404(ue_id)
|
||||
ue = UniteEns.get_or_404(ue_id)
|
||||
return sco_edit_apc.html_ue_infos(ue)
|
||||
|
||||
|
||||
@ -901,7 +901,7 @@ sco_publish(
|
||||
@scodoc7func
|
||||
def formsemestre_flip_lock(formsemestre_id, dialog_confirmed=False):
|
||||
"Changement de l'état de verrouillage du semestre"
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
dest_url = url_for(
|
||||
"notes.formsemestre_status",
|
||||
scodoc_dept=g.scodoc_dept,
|
||||
@ -1097,7 +1097,7 @@ def edit_moduleimpl_resp(moduleimpl_id: int):
|
||||
"""Changement d'un enseignant responsable de module
|
||||
Accessible par Admin et dir des etud si flag resp_can_change_ens
|
||||
"""
|
||||
modimpl: ModuleImpl = ModuleImpl.query.get_or_404(moduleimpl_id)
|
||||
modimpl: ModuleImpl = ModuleImpl.get_or_404(moduleimpl_id)
|
||||
modimpl.can_change_responsable(current_user, raise_exc=True) # access control
|
||||
H = [
|
||||
f"""<h2 class="formsemestre">Modification du responsable du
|
||||
@ -1438,7 +1438,7 @@ def formsemestre_desinscription(etudid, formsemestre_id, dialog_confirmed=False)
|
||||
S'il s'agit d'un semestre extérieur et qu'il n'y a plus d'inscrit,
|
||||
le semestre sera supprimé.
|
||||
"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
sem = formsemestre.to_dict() # compat
|
||||
# -- check lock
|
||||
if not formsemestre.etat:
|
||||
@ -1531,7 +1531,7 @@ def etud_desinscrit_ue(etudid, formsemestre_id, ue_id):
|
||||
- En APC: dispense de l'UE indiquée.
|
||||
"""
|
||||
etud = Identite.get_etud(etudid)
|
||||
ue = UniteEns.query.get_or_404(ue_id)
|
||||
ue = UniteEns.get_or_404(ue_id)
|
||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
if ue.formation.is_apc():
|
||||
if (
|
||||
@ -1582,7 +1582,7 @@ def etud_inscrit_ue(etudid, formsemestre_id, ue_id):
|
||||
id=formsemestre_id, dept_id=g.scodoc_dept_id
|
||||
).first_or_404()
|
||||
etud = Identite.get_etud(etudid)
|
||||
ue = UniteEns.query.get_or_404(ue_id)
|
||||
ue = UniteEns.get_or_404(ue_id)
|
||||
if ue.formation.is_apc():
|
||||
for disp in DispenseUE.query.filter_by(
|
||||
formsemestre_id=formsemestre_id, etudid=etud.id, ue_id=ue_id
|
||||
@ -2268,7 +2268,7 @@ def appreciation_add_form(
|
||||
edit = 1
|
||||
else:
|
||||
edit = 0
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
# check custom access permission
|
||||
can_edit_app = formsemestre.est_responsable(current_user) or (
|
||||
current_user.has_permission(Permission.EtudInscrit)
|
||||
|
@ -59,13 +59,13 @@ def table_modules_ue_coefs(formation_id, semestre_idx=None, parcours_id: int = N
|
||||
Si le parcours est indiqué et que la formation a un référentiel de compétence,
|
||||
restreint l'affichage aux UE et modules de ce parcours.
|
||||
"""
|
||||
formation: Formation = models.Formation.query.get_or_404(formation_id) # check
|
||||
formation: Formation = models.Formation.get_or_404(formation_id) # check
|
||||
if semestre_idx == "":
|
||||
semestre_idx = None
|
||||
if parcours_id == "":
|
||||
parcours_id = None
|
||||
if parcours_id is not None and formation.referentiel_competence is not None:
|
||||
parcour: ApcParcours = ApcParcours.query.get_or_404(parcours_id)
|
||||
parcour: ApcParcours = ApcParcours.get_or_404(parcours_id)
|
||||
else:
|
||||
parcour = None
|
||||
df, ues, modules = moy_ue.df_load_module_coefs(formation_id, semestre_idx)
|
||||
|
@ -46,9 +46,7 @@ from app.views import ScoData
|
||||
@as_json
|
||||
def refcomp(refcomp_id):
|
||||
"""Le référentiel de compétences, en JSON."""
|
||||
ref: ApcReferentielCompetences = ApcReferentielCompetences.query.get_or_404(
|
||||
refcomp_id
|
||||
)
|
||||
ref: ApcReferentielCompetences = ApcReferentielCompetences.get_or_404(refcomp_id)
|
||||
return ref.to_dict()
|
||||
|
||||
|
||||
@ -58,7 +56,7 @@ def refcomp(refcomp_id):
|
||||
def refcomp_show(refcomp_id):
|
||||
"""Affichage du référentiel de compétences."""
|
||||
referentiel_competence: ApcReferentielCompetences = (
|
||||
ApcReferentielCompetences.query.get_or_404(refcomp_id)
|
||||
ApcReferentielCompetences.get_or_404(refcomp_id)
|
||||
)
|
||||
# Autres référentiels "équivalents" pour proposer de changer les formations:
|
||||
referentiels_equivalents = referentiel_competence.equivalents()
|
||||
@ -82,7 +80,7 @@ def refcomp_show(refcomp_id):
|
||||
@permission_required(Permission.EditFormation)
|
||||
def refcomp_delete(refcomp_id):
|
||||
"""Suppression du référentiel de la base. Le fichier source n'est pas affecté."""
|
||||
ref = ApcReferentielCompetences.query.get_or_404(refcomp_id)
|
||||
ref = ApcReferentielCompetences.get_or_404(refcomp_id)
|
||||
db.session.delete(ref)
|
||||
db.session.commit()
|
||||
flash("référentiel de compétences supprimé")
|
||||
@ -148,7 +146,7 @@ def refcomp_table():
|
||||
@permission_required(Permission.EditFormation)
|
||||
def refcomp_assoc_formation(formation_id: int):
|
||||
"""Formulaire association ref. compétence"""
|
||||
formation = Formation.query.get_or_404(formation_id)
|
||||
formation = Formation.get_or_404(formation_id)
|
||||
form = FormationRefCompForm()
|
||||
form.referentiel_competence.choices = [
|
||||
(r.id, f"{r.type_titre} {r.specialite_long} ({r.get_version()})")
|
||||
@ -193,7 +191,7 @@ def refcomp_assoc_formation(formation_id: int):
|
||||
@permission_required(Permission.EditFormation)
|
||||
def refcomp_desassoc_formation(formation_id: int):
|
||||
"""Désassocie la formation de son ref. de compétence"""
|
||||
formation: Formation = Formation.query.get_or_404(formation_id)
|
||||
formation: Formation = Formation.get_or_404(formation_id)
|
||||
formation.refcomp_desassoc()
|
||||
return redirect(
|
||||
url_for("notes.ue_table", scodoc_dept=g.scodoc_dept, formation_id=formation.id)
|
||||
|
@ -139,7 +139,7 @@ def create_dept():
|
||||
@admin_required
|
||||
def toggle_dept_vis(dept_id):
|
||||
"""Cache ou rend visible un dept"""
|
||||
dept = Departement.query.get_or_404(dept_id)
|
||||
dept = Departement.get_or_404(dept_id)
|
||||
dept.visible = not dept.visible
|
||||
db.session.add(dept)
|
||||
db.session.commit()
|
||||
@ -568,7 +568,7 @@ def get_etud_dept():
|
||||
# le choix a peu d'importance...
|
||||
last_etud = etuds[-1]
|
||||
|
||||
return Departement.query.get_or_404(last_etud.dept_id).acronym
|
||||
return Departement.get_or_404(last_etud.dept_id).acronym
|
||||
|
||||
|
||||
@bp.route("/ScoDoc/about")
|
||||
|
@ -879,7 +879,7 @@ sco_publish(
|
||||
@permission_required(Permission.ScoView)
|
||||
def groups_auto_repartition(partition_id: int):
|
||||
"Réparti les etudiants dans des groupes dans une partition"
|
||||
partition: Partition = Partition.query.get_or_404(partition_id)
|
||||
partition: Partition = Partition.get_or_404(partition_id)
|
||||
return sco_groups.groups_auto_repartition(partition)
|
||||
|
||||
|
||||
@ -942,7 +942,7 @@ def partition_editor(formsemestre_id: int, edit_partition=False):
|
||||
"""Page édition groupes et partitions
|
||||
Si edit_partition, se met en mode édition des partitions.
|
||||
"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
edit_partition = bool(int(edit_partition)) if edit_partition else False
|
||||
formsemestre.setup_parcours_groups()
|
||||
return render_template(
|
||||
@ -978,7 +978,7 @@ def students_groups_auto_assignment(formsemestre_id: int):
|
||||
def create_partition_parcours(formsemestre_id):
|
||||
"""Création d'une partitions nommée "Parcours" (PARTITION_PARCOURS)
|
||||
avec un groupe par parcours."""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
formsemestre.setup_parcours_groups()
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
@ -1830,7 +1830,7 @@ def etud_copy_in_other_dept(etudid: int):
|
||||
except ValueError:
|
||||
log("etud_copy_in_other_dept: invalid formsemestre_id")
|
||||
abort(404, description="formsemestre_id invalide")
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
if not current_user.has_permission(
|
||||
Permission.EtudInscrit, formsemestre.departement.acronym
|
||||
):
|
||||
|
@ -37,7 +37,7 @@ def test_notes_table(test_client): # XXX A REVOIR POUR TESTER RES TODO
|
||||
assert len(sems)
|
||||
sem = sems[0]
|
||||
formsemestre_id = sem["formsemestre_id"]
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
assert nt
|
||||
assert sco_cache.ResultatsSemestreCache.get(formsemestre_id)
|
||||
|
@ -339,7 +339,7 @@ def test_import_formation(test_client, filename="formation-exemple-1.xml"):
|
||||
module_id=mod.id,
|
||||
formsemestre_id=formsemestre_ids[mod.semestre_id - 1],
|
||||
)
|
||||
mi = db.session.query(ModuleImpl).get(moduleimpl_id)
|
||||
mi = db.session.get(ModuleImpl, moduleimpl_id)
|
||||
assert mi.module_id == mod.id
|
||||
|
||||
# --- Export formation en XML
|
||||
|
@ -33,7 +33,7 @@ def check_nt(
|
||||
(peut changer dans le futur, ne pas utiliser hors ScoDoc !)
|
||||
ne vérifie que les valeurs expected non False
|
||||
"""
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
mod_moy = nt.get_etud_mod_moy(moduleimpl_id, etudid)
|
||||
if expected_moy_ue is not False:
|
||||
@ -276,7 +276,7 @@ def test_notes_modules(test_client):
|
||||
module_id=module_id2,
|
||||
formsemestre_id=formsemestre_id,
|
||||
)
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
# Pour prendre en compte l'ajout au vol d'un moduleimpl:
|
||||
del formsemestre.modimpls_sorted
|
||||
|
||||
@ -302,7 +302,7 @@ def test_notes_modules(test_client):
|
||||
{"etudid": etuds[1]["etudid"], "moduleimpl_id": moduleimpl_id2},
|
||||
formsemestre_id=formsemestre_id,
|
||||
)
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
||||
|
||||
@ -314,7 +314,7 @@ def test_notes_modules(test_client):
|
||||
coefficient=1.0,
|
||||
)
|
||||
_ = G.create_note(evaluation_id=e_m2["evaluation_id"], etudid=etudid, note=19.5)
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
ue_status = nt.get_etud_ue_status(etudid, ue_id)
|
||||
|
||||
|
@ -227,7 +227,7 @@ def run_sco_basic(verbose=False, dept=None) -> FormSemestre:
|
||||
redirect=False,
|
||||
)
|
||||
# Vérifie que toutes les UE des étudiants notés ont été acquises:
|
||||
formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
|
||||
formsemestre: FormSemestre = FormSemestre.get_or_404(formsemestre_id)
|
||||
nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
for etud in etuds[:5]:
|
||||
dec_ues = nt.get_etud_decisions_ue(etud["etudid"])
|
||||
|
@ -311,7 +311,7 @@ def saisie_notes_evaluations(formsemestre: FormSemestre, user: User):
|
||||
for ue in list_ues:
|
||||
mods = ue.modules
|
||||
for mod in mods:
|
||||
moduleimpl = ModuleImpl.query.get_or_404(mod.id)
|
||||
moduleimpl = ModuleImpl.get_or_404(mod.id)
|
||||
for evaluation in moduleimpl.evaluations:
|
||||
condition_saisie_notes = random.randint(0, 2)
|
||||
saisir_notes(evaluation.id, condition_saisie_notes)
|
||||
|
Loading…
Reference in New Issue
Block a user