1
0
forked from ScoDoc/ScoDoc
ScoDoc/app/models/departements.py

45 lines
1.5 KiB
Python
Raw Normal View History

2021-08-13 00:34:58 +02:00
# -*- coding: UTF-8 -*
2021-08-25 23:51:07 +02:00
"""ScoDoc models : departements
2021-08-13 00:34:58 +02:00
"""
from typing import Any
from app import db
from app.models import SHORT_STR_LEN
class Departement(db.Model):
"""Un département ScoDoc"""
id = db.Column(db.Integer, primary_key=True)
acronym = db.Column(db.String(SHORT_STR_LEN), nullable=False, index=True)
description = db.Column(db.Text())
date_creation = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
visible = db.Column(
db.Boolean(), nullable=False, default=True, server_default="true"
) # sur page d'accueil
entreprises = db.relationship("Entreprise", lazy="dynamic", backref="departement")
etudiants = db.relationship("Identite", lazy="dynamic", backref="departement")
formations = db.relationship("Formation", lazy="dynamic", backref="departement")
2021-08-13 00:34:58 +02:00
formsemestres = db.relationship(
"FormSemestre", lazy="dynamic", backref="departement"
)
preferences = db.relationship(
"ScoPreference", lazy="dynamic", backref="departement"
)
semsets = db.relationship("NotesSemSet", lazy="dynamic", backref="departement")
def __repr__(self):
2021-09-27 13:43:11 +02:00
return f"<{self.__class__.__name__}(id={self.id}, acronym='{self.acronym}')>"
2021-09-09 12:49:23 +02:00
def to_dict(self):
data = {
"id": self.id,
"acronym": self.acronym,
"description": self.description,
"visible": self.visible,
"date_creation": self.date_creation,
}
return data