2021-08-07 15:20:30 +02:00
|
|
|
# -*- coding: UTF-8 -*
|
|
|
|
|
|
|
|
"""Gestion des absences
|
|
|
|
"""
|
|
|
|
|
|
|
|
from app import db
|
|
|
|
|
|
|
|
|
|
|
|
class Absence(db.Model):
|
|
|
|
"""une absence (sur une demi-journée)"""
|
|
|
|
|
|
|
|
__tablename__ = "absences"
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
etudid = db.Column(db.Integer, db.ForeignKey("identite.id"), index=True)
|
|
|
|
jour = db.Column(db.Date)
|
|
|
|
estabs = db.Column(db.Boolean())
|
|
|
|
estjust = db.Column(db.Boolean())
|
|
|
|
matin = db.Column(db.Boolean())
|
|
|
|
# motif de l'absence:
|
|
|
|
description = db.Column(db.Text())
|
|
|
|
entry_date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
|
|
|
# moduleimpid concerne (optionnel):
|
|
|
|
moduleimpl_id = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("notes_moduleimpl.id"),
|
|
|
|
)
|
|
|
|
# XXX TODO: contrainte ajoutée: vérifier suppression du module
|
|
|
|
# (mettre à NULL sans supprimer)
|
|
|
|
|
2022-04-25 15:25:45 +02:00
|
|
|
def to_dict(self):
|
|
|
|
data = {
|
|
|
|
"id": self.id,
|
|
|
|
"etudid": self.etudid,
|
|
|
|
"jour": self.jour,
|
|
|
|
"estabs": self.estabs,
|
|
|
|
"estjust": self.estjust,
|
|
|
|
"matin": self.matin,
|
|
|
|
"description": self.description,
|
|
|
|
"entry_date": self.entry_date,
|
|
|
|
"moduleimpl_id": self.moduleimpl_id,
|
|
|
|
}
|
|
|
|
return data
|
|
|
|
|
2021-08-07 15:20:30 +02:00
|
|
|
|
|
|
|
class AbsenceNotification(db.Model):
|
|
|
|
"""Notification d'absence émise"""
|
|
|
|
|
|
|
|
__tablename__ = "absences_notifications"
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
etudid = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("identite.id"),
|
|
|
|
)
|
|
|
|
notification_date = db.Column(
|
|
|
|
db.DateTime(timezone=True), server_default=db.func.now()
|
|
|
|
)
|
|
|
|
email = db.Column(db.Text())
|
|
|
|
nbabs = db.Column(db.Integer)
|
|
|
|
nbabsjust = db.Column(db.Integer)
|
|
|
|
formsemestre_id = db.Column(
|
|
|
|
db.Integer,
|
2021-11-09 11:52:41 +01:00
|
|
|
db.ForeignKey("notes_formsemestre.id", ondelete="CASCADE"),
|
2021-08-07 15:20:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class BilletAbsence(db.Model):
|
|
|
|
"""Billet d'absence (signalement par l'étudiant)"""
|
|
|
|
|
|
|
|
__tablename__ = "billet_absence"
|
|
|
|
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
etudid = db.Column(
|
|
|
|
db.Integer,
|
|
|
|
db.ForeignKey("identite.id"),
|
|
|
|
index=True,
|
|
|
|
)
|
|
|
|
abs_begin = db.Column(db.DateTime(timezone=True))
|
|
|
|
abs_end = db.Column(db.DateTime(timezone=True))
|
|
|
|
# raison de l'absence:
|
|
|
|
description = db.Column(db.Text())
|
|
|
|
# False: new, True: processed
|
2021-08-10 00:23:30 +02:00
|
|
|
etat = db.Column(db.Boolean(), default=False, server_default="false")
|
2021-08-07 15:20:30 +02:00
|
|
|
entry_date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
|
|
|
|
# true si l'absence _pourrait_ etre justifiée
|
2021-08-10 00:23:30 +02:00
|
|
|
justified = db.Column(db.Boolean(), default=False, server_default="false")
|
2021-09-28 09:59:50 +02:00
|
|
|
|
|
|
|
def to_dict(self):
|
|
|
|
data = {
|
|
|
|
"id": self.id,
|
|
|
|
"billet_id": self.id,
|
|
|
|
"etudid": self.etudid,
|
|
|
|
"abs_begin": self.abs_begin,
|
|
|
|
"abs_end": self.abs_begin,
|
|
|
|
"description": self.description,
|
|
|
|
"etat": self.etat,
|
|
|
|
"entry_date": self.entry_date,
|
|
|
|
"justified": self.justified,
|
|
|
|
}
|
|
|
|
return data
|