forked from ScoDoc/DocScoDoc
Emmanuel Viennet
89e7250f4a
- Refactoring. - Changement des noms des classes (modèles) des formations. - Début intégration calculs BUT. - Requiert numpy et pandas.
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""ScoDoc 9 models : Formation BUT 2021
|
|
"""
|
|
from enum import unique
|
|
from typing import Any
|
|
|
|
from app import db
|
|
|
|
from app.scodoc.sco_utils import ModuleType
|
|
|
|
Modules_ACs = db.Table(
|
|
"modules_acs",
|
|
db.Column("module_id", db.ForeignKey("notes_modules.id")),
|
|
db.Column("ac_id", db.ForeignKey("app_crit.id")),
|
|
)
|
|
|
|
|
|
class AppCrit(db.Model):
|
|
"Apprentissage Critique BUT"
|
|
__tablename__ = "app_crit"
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
code = db.Column(db.Text(), nullable=False, info={"label": "Code"})
|
|
titre = db.Column(db.Text(), info={"label": "Titre"})
|
|
|
|
modules = db.relationship(
|
|
"Module", secondary=Modules_ACs, lazy="dynamic", backref="acs"
|
|
)
|
|
|
|
def to_dict(self):
|
|
result = dict(self.__dict__)
|
|
result.pop("_sa_instance_state", None)
|
|
return result
|
|
|
|
def get_label(self):
|
|
return self.code + " - " + self.titre
|
|
|
|
def __repr__(self):
|
|
return "<AC {}>".format(self.code)
|
|
|
|
def get_saes(self):
|
|
"""Liste des SAE associées"""
|
|
return [m for m in self.modules if m.module_type == ModuleType.SAE]
|