ScoDoc/app/entreprises/models.py

139 lines
4.5 KiB
Python
Raw Normal View History

2021-12-23 19:28:25 +01:00
from app import db
2021-12-23 19:28:25 +01:00
class Entreprise(db.Model):
__tablename__ = "are_entreprises"
2021-12-23 19:28:25 +01:00
id = db.Column(db.Integer, primary_key=True)
siret = db.Column(db.Text)
nom = db.Column(db.Text)
adresse = db.Column(db.Text)
codepostal = db.Column(db.Text)
ville = db.Column(db.Text)
pays = db.Column(db.Text)
contacts = db.relationship(
"EntrepriseContact",
backref="entreprise",
lazy="dynamic",
cascade="all, delete-orphan",
)
offres = db.relationship(
"EntrepriseOffre",
backref="entreprise",
lazy="dynamic",
cascade="all, delete-orphan",
)
2021-12-23 19:28:25 +01:00
def to_dict(self):
2021-12-24 18:10:19 +01:00
return {
"siret": self.siret,
"nom": self.nom,
"adresse": self.adresse,
"codepostal": self.codepostal,
2021-12-27 11:48:58 +01:00
"ville": self.ville,
"pays": self.pays,
2021-12-24 18:10:19 +01:00
}
2021-12-23 19:28:25 +01:00
class EntrepriseContact(db.Model):
__tablename__ = "are_entreprise_contact"
2021-12-23 19:28:25 +01:00
id = db.Column(db.Integer, primary_key=True)
entreprise_id = db.Column(
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade")
)
2021-12-23 19:28:25 +01:00
nom = db.Column(db.Text)
prenom = db.Column(db.Text)
telephone = db.Column(db.Text)
mail = db.Column(db.Text)
2021-12-24 10:43:12 +01:00
poste = db.Column(db.Text)
service = db.Column(db.Text)
def to_dict(self):
2021-12-27 11:48:58 +01:00
return {
"nom": self.nom,
"prenom": self.prenom,
"telephone": self.telephone,
"mail": self.mail,
"poste": self.poste,
"service": self.service,
2021-12-27 11:48:58 +01:00
}
2021-12-23 19:28:25 +01:00
2021-12-29 19:40:57 +01:00
def to_dict_export(self):
entreprise = Entreprise.query.get(self.entreprise_id)
return {
"nom": self.nom,
"prenom": self.prenom,
"telephone": self.telephone,
"mail": self.mail,
"poste": self.poste,
"service": self.service,
"siret": entreprise.siret,
"nom_entreprise": entreprise.nom,
"adresse_entreprise": entreprise.adresse,
"codepostal": entreprise.codepostal,
"ville": entreprise.ville,
"pays": entreprise.pays,
}
2021-12-23 19:28:25 +01:00
class EntrepriseOffre(db.Model):
__tablename__ = "are_entreprise_offre"
2021-12-23 19:28:25 +01:00
id = db.Column(db.Integer, primary_key=True)
entreprise_id = db.Column(
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade")
)
2021-12-23 19:28:25 +01:00
date_ajout = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
intitule = db.Column(db.Text)
description = db.Column(db.Text)
type_offre = db.Column(db.Text)
missions = db.Column(db.Text)
duree = db.Column(db.Text)
2022-01-24 18:07:54 +01:00
expiration_date = db.Column(db.Date)
2021-12-30 19:37:46 +01:00
def to_dict(self):
return {
"intitule": self.intitule,
"description": self.description,
"type_offre": self.type_offre,
"missions": self.missions,
"duree": self.duree,
}
2021-12-23 19:28:25 +01:00
class EntrepriseLog(db.Model):
__tablename__ = "are_entreprise_log"
2021-12-23 19:28:25 +01:00
id = db.Column(db.Integer, primary_key=True)
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
authenticated_user = db.Column(db.Text)
object = db.Column(db.Integer)
text = db.Column(db.Text)
2021-12-24 10:43:12 +01:00
class EntrepriseEtudiant(db.Model):
__tablename__ = "are_entreprise_etudiant"
2021-12-23 19:28:25 +01:00
id = db.Column(db.Integer, primary_key=True)
entreprise_id = db.Column(db.Integer, db.ForeignKey("are_entreprises.id"))
2021-12-23 19:28:25 +01:00
etudid = db.Column(db.Integer)
type_offre = db.Column(db.Text)
date_debut = db.Column(db.Date)
date_fin = db.Column(db.Date)
formation_text = db.Column(db.Text)
formation_scodoc = db.Column(db.Integer)
2021-12-24 10:43:12 +01:00
2021-12-24 10:43:12 +01:00
class EntrepriseEnvoiOffre(db.Model):
__tablename__ = "are_entreprise_envoi_offre"
2021-12-24 10:43:12 +01:00
id = db.Column(db.Integer, primary_key=True)
sender_id = db.Column(db.Integer, db.ForeignKey("user.id"))
receiver_id = db.Column(db.Integer, db.ForeignKey("user.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id"))
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
2021-12-30 19:37:46 +01:00
class EntrepriseEnvoiOffreEtudiant(db.Model):
__tablename__ = "are_entreprise_envoi_offre_etudiant"
2021-12-30 19:37:46 +01:00
id = db.Column(db.Integer, primary_key=True)
sender_id = db.Column(db.Integer, db.ForeignKey("user.id"))
receiver_id = db.Column(db.Integer, db.ForeignKey("identite.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id"))
2021-12-30 19:37:46 +01:00
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())