from app import db class Entreprise(db.Model): __tablename__ = "are_entreprises" 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) visible = db.Column(db.Boolean, default=False) contacts = db.relationship( "EntrepriseContact", backref="entreprise", lazy="dynamic", cascade="all, delete-orphan", ) offres = db.relationship( "EntrepriseOffre", backref="entreprise", lazy="dynamic", cascade="all, delete-orphan", ) def to_dict(self): return { "siret": self.siret, "nom_entreprise": self.nom, "adresse": self.adresse, "code_postal": self.codepostal, "ville": self.ville, "pays": self.pays, } class EntrepriseContact(db.Model): __tablename__ = "are_entreprise_contact" id = db.Column(db.Integer, primary_key=True) entreprise_id = db.Column( db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") ) nom = db.Column(db.Text) prenom = db.Column(db.Text) telephone = db.Column(db.Text) mail = db.Column(db.Text) poste = db.Column(db.Text) service = db.Column(db.Text) def to_dict(self): entreprise = Entreprise.query.filter_by(id=self.entreprise_id).first() return { "nom": self.nom, "prenom": self.prenom, "telephone": self.telephone, "mail": self.mail, "poste": self.poste, "service": self.service, "entreprise_siret": entreprise.siret, } class EntrepriseOffre(db.Model): __tablename__ = "are_entreprise_offre" id = db.Column(db.Integer, primary_key=True) entreprise_id = db.Column( db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") ) 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) expiration_date = db.Column(db.Date) def to_dict(self): return { "intitule": self.intitule, "description": self.description, "type_offre": self.type_offre, "missions": self.missions, "duree": self.duree, } class EntrepriseLog(db.Model): __tablename__ = "are_entreprise_log" 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) class EntrepriseEtudiant(db.Model): __tablename__ = "are_entreprise_etudiant" id = db.Column(db.Integer, primary_key=True) entreprise_id = db.Column( db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade") ) 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) class EntrepriseEnvoiOffre(db.Model): __tablename__ = "are_entreprise_envoi_offre" id = db.Column(db.Integer, primary_key=True) sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade")) receiver_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade")) offre_id = db.Column( db.Integer, db.ForeignKey("are_entreprise_offre.id", ondelete="cascade") ) date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) class EntrepriseEnvoiOffreEtudiant(db.Model): __tablename__ = "are_entreprise_envoi_offre_etudiant" id = db.Column(db.Integer, primary_key=True) sender_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="cascade")) receiver_id = db.Column( db.Integer, db.ForeignKey("identite.id", ondelete="cascade") ) offre_id = db.Column( db.Integer, db.ForeignKey("are_entreprise_offre.id", ondelete="cascade") ) date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) class EntrepriseOffreDepartement(db.Model): __tablename__ = "are_entreprise_offre_departement" id = db.Column(db.Integer, primary_key=True) offre_id = db.Column( db.Integer, db.ForeignKey("are_entreprise_offre.id", ondelete="cascade") ) dept_id = db.Column(db.Integer, db.ForeignKey("departement.id", ondelete="cascade")) class EntreprisePreferences(db.Model): __tablename__ = "are_preferences" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text) value = db.Column(db.Text)