EditionPN/app/models.py

126 lines
5.6 KiB
Python
Raw Normal View History

2021-05-06 10:26:28 +02:00
from app import db
2021-06-01 19:31:24 +02:00
from sqlalchemy_utils import ChoiceType
Semestres_Competences = db.Table("Semestres_Competences",
db.Column("Semestre_num", db.String(1), db.ForeignKey("semestre.num")),
db.Column("Competence_code", db.String(3), db.ForeignKey("competence.code"))
)
ACs_Competences = db.Table("ACs_Competences",
db.Column("AC_code", db.String(6), db.ForeignKey("AC.code")),
db.Column("Competence_code", db.String(3), db.ForeignKey("competence.code"))
)
SAEs_Competences = db.Table("SAEs_Competences",
db.Column("SAE_code", db.String(6), db.ForeignKey("SAE.code")),
db.Column("Competence_code", db.String(3), db.ForeignKey("competence.code"))
)
Ressources_Competences = db.Table("Ressources_Competences",
db.Column("Ressource_code", db.String(6), db.ForeignKey("ressource.code")),
db.Column("Competence_code", db.String(3), db.ForeignKey("competence.code"))
)
2021-05-06 10:26:28 +02:00
2021-05-07 14:27:06 +02:00
Ressources_ACs = db.Table("Ressources_ACs",
db.Column("Ressource_code", db.String(4), db.ForeignKey("ressource.code")),
db.Column("AC_code", db.String(6), db.ForeignKey("AC.code"))
)
Ressources_SAEs = db.Table("Ressources_SAEs",
db.Column("Ressource_code", db.String(4), db.ForeignKey("ressource.code")),
db.Column("SAE_code", db.String(5), db.ForeignKey("SAE.code"))
)
SAEs_ACs = db.Table("SAEs_ACs",
db.Column("SAE_code", db.String(5), db.ForeignKey("SAE.code")),
db.Column("AC_code", db.String(6), db.ForeignKey("AC.code"))
)
2021-06-01 19:31:24 +02:00
class Semestre(db.Model):
num = db.Column(db.String(1), primary_key = True)
ues = db.relationship("Competence", order_by="Competence.code", secondary=Semestres_Competences, lazy=False, backref=db.backref("semestres", lazy=False))
2021-05-06 10:26:28 +02:00
def __repr__(self):
2021-06-01 19:31:24 +02:00
return "<Semestre {}>".format(self.num)
class Competence(db.Model):
code = db.Column(db.String(3), primary_key = True, info={'label': 'Code'})
nom = db.Column(db.String(255), info={'label': 'Nom'})
diminutif = db.Column(db.String(30), info={'label': 'Diminutif'})
description = db.Column(db.Text(), info={'label': 'Description'})
composantes = db.Column(db.Text(), info={'label': 'Composantes'})
situations = db.Column(db.Text(), info={'label': 'Situations'})
niveaux = db.Column(db.Text(), info={'label': 'Niveaux'})
acs = db.relationship("AC", order_by="AC.code", secondary=ACs_Competences, lazy=False, backref=db.backref("competences", lazy=False))
#objets de formation
saes = db.relationship("SAE", secondary=SAEs_Competences, lazy=False, backref=db.backref("competences", lazy=False))
ressources = db.relationship("Ressource", secondary=Ressources_Competences, lazy=False, backref=db.backref("competences", lazy=False))
def getLabel(self):
return self.code + " - " + self.nom
def __repr__(self):
return "<Competence {}>".format(self.code)
class AC(db.Model):
2021-06-01 19:31:24 +02:00
code = db.Column(db.String(6), primary_key = True, info={'label': 'Code'})
titre = db.Column(db.String(255), info={'label': 'Titre'})
saes = db.relationship("SAE", secondary=SAEs_ACs, lazy=False, backref=db.backref("acs", lazy=False))
ressources = db.relationship("Ressource", order_by="Ressource.code", secondary=Ressources_ACs, lazy=False, backref=db.backref("acs", lazy=False))
def getLabel(self):
return self.code + " - " + self.titre
def __repr__(self):
return "<AC {}>".format(self.code)
2021-06-01 19:31:24 +02:00
class PN(db.Model):
code = db.Column(db.String(3), primary_key = True, info={'label': 'Code'})
nom = db.Column(db.String(255), info={'label': 'Nom'})
diminutif = db.Column(db.String(30), info={'label': 'Diminutif'})
description = db.Column(db.Text(), info={'label': 'Description'})
TYPES = [("1","1"),("2","2"),("3","3")]
type = db.Column(ChoiceType(TYPES))
def __repr__(self):
return "<PN {}>".format(self.code)
class SAE(db.Model):
2021-06-01 19:31:24 +02:00
code = db.Column(db.String(5), primary_key = True, info={'label': 'Code'})
titre = db.Column(db.String(255), info={'label': 'Titre'})
semestre = db.Column(db.String(255), info={'label': 'Semestre'})
heures_encadrees = db.Column(db.String(3), info={'label': 'Heures Encadrées'})
heures_tp = db.Column(db.String(3), info={'label': 'Heures TP'})
projet = db.Column(db.String(3), info={'label': 'Projet'})
description = db.Column(db.Text(), info={'label': 'Description'})
coef = db.Column(db.String(255), info={'label': 'Coef.'})
ressources = db.relationship("Ressource", order_by="Ressource.code", secondary=Ressources_SAEs, lazy=False, backref=db.backref("saes", lazy=False))
livrables = db.Column(db.Text(), info={'label': 'Livrables'})
motscles = db.Column(db.String(255), info={'label': 'Mots Clés'})
def getLabel(self):
return self.code + " - " + self.titre
def __repr__(self):
return "<SAE {}>".format(self.code)
class Ressource(db.Model):
2021-06-01 19:31:24 +02:00
code = db.Column(db.String(4), primary_key = True, info={'label': 'Code'})
nom = db.Column(db.String(255), info={'label': 'Nom'})
semestre = db.Column(db.String(255), info={'label': 'Semestre'})
heures_formation = db.Column(db.String(3), info={'label': 'Heures Formation'})
heures_tp = db.Column(db.String(3), info={'label': 'Heures TP'})
coef = db.Column(db.String(255), info={'label': 'Coef.'})
prerequis = db.Column(db.String(255), info={'label': 'Prerequis'})
contexte = db.Column(db.Text(), info={'label': 'Contexte'})
contenu = db.Column(db.Text(), info={'label': 'Contenu'})
motscles = db.Column(db.String(255), info={'label': 'Mots Clés'})
def getLabel(self):
return self.code + " - " + self.nom
def __repr__(self):
return "<Ressource {}>".format(self.code)