class RecetteCarburant(db.Model): __tablename__ = 'recettecarburant' idRecetteCarburant = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) idPompe = db.Column(db.ForeignKey('pompe.idPompe'), nullable=False) idCiterne = db.Column(db.ForeignKey('citerne.idCiterne'), nullable=False) idVoie = db.Column(db.ForeignKey('voie.idVoie'), nullable=False) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) idGroupe = db.Column(db.ForeignKey('groupe.idGroupe'), nullable=False) DateCarb = db.Column(db.DATE, nullable=False, default=currentDate) indiceDeb = db.Column(db.Float, nullable=False) indiceFin = db.Column(db.Float, nullable=False) prixLitre = db.Column(db.Float, nullable=False) Pompe = db.relationship("Pompe", backref='Pmp', lazy=True) Citerne = db.relationship("Citerne", backref='Cit', lazy=True) Voie = db.relationship("Voie", backref='voie', lazy=True) Station = db.relationship("Station", backref='St', lazy=True) Groupe = db.relationship("Groupe", backref='Grpp', lazy=True) def __repr__(self): return f"RecetteCarburant('{self.idRecetteCarburant}', '{self.idPompe}', '{self.idCiterne}','{self.idVoie}'," \ f"'{self.idStation}', '{self.idGroupe}', '{self.DateCarb}', '{self.indiceDeb}', '{self.indiceFin}') "
class PompeCiterne(db.Model): __tablename__ = 'citerne_has_pompe' id_citerne_has_pompe = db.Column(db.Integer, primary_key=True, nullable=False,autoincrement=True) idCiterne = db.Column(db.ForeignKey('citerne.idCiterne'), nullable=False) idPompe = db.Column(db.ForeignKey('pompe.idPompe'), nullable=False) Citerne = db.relationship("Citerne", backref='Citerne', lazy=True) Pompe = db.relationship("Pompe", backref='Pompe', lazy=True) def __repr__(self): return f"PompeCiterne('{self.id_citerne_has_pompe}',{self.idCiterne}', '{self.idPompe}') "
class Absence(db.Model): __tablename__ = 'absence' idAbsence = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) idEmp = db.Column(db.ForeignKey('employee.idEmp'), nullable=False) idGroupe = db.Column(db.ForeignKey('groupe.idGroupe'), nullable=False) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) DateAbsence = db.Column(db.Date, nullable=False, default=currentDate) DescAbsence = db.Column(db.String(255), nullable=False) Employee = db.relationship("Employee", backref='Employee', lazy=True) Station = db.relationship("Station", backref='Stationns', lazy=True) Groupe = db.relationship("Groupe", backref='Gp', lazy=True) def __repr__(self): return f"Absence('{self.idAbsence}','{self.DateAbsence}','{self.DescAbsence}','{self.idStation}','{self.idEmp}','{self.idGroupe}')"
class Citerne(db.Model): __tablename__ = 'citerne' idCiterne = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) NomCiterne = db.Column(db.String(255), nullable=False) VolumeCiterne = db.Column(db.Float, nullable=False) Val_Act_Citerne = db.Column(db.Float, nullable=False) Min_Val_Citerne = db.Column(db.String(255), nullable=False) EtatCiterne = db.Column(db.String(10), nullable=False, default="1") idCarburant = db.Column(db.ForeignKey('carburant.idCarburant'), nullable=False) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) Carburant = db.relationship("Carburant", backref='Carburant', lazy=True) Station = db.relationship("Station", backref='station', lazy=True) def __repr__(self): return f"Citerne('{self.idCiterne}', '{self.NomCiterne}', '{self.VolumeCiterne}','{self.Val_Act_Citerne}'," \ f"'{self.Min_Val_Citerne}', '{self.EtatCiterne}', '{self.idCarburant}', '{self.idStation}') "
class Delegation(db.Model): __tablename__ = 'delegation' idDelegation = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) nomDelegation = db.Column(db.String(255), nullable=False) idVille = db.Column(db.ForeignKey('ville.idVille'), nullable=False) Ville = db.relationship("Ville", backref='Ville', lazy=True) def __repr__(self): return f"Delegation('{self.idDelegation}', '{self.nomDelegation}', '{self.idVille}')"
class Conge(db.Model): __tablename__ = 'conge' idConge = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) idEmp = db.Column(db.ForeignKey('employee.idEmp'), nullable=False) idGroupe = db.Column(db.ForeignKey('groupe.idGroupe'), nullable=False) idTypeConge = db.Column(db.ForeignKey('typeconge.idTypeConge'), nullable=False) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) DateDebConge = db.Column(db.Date, nullable=False, default=currentDate) DateFinConge = db.Column(db.Date, nullable=False) DescConge = db.Column(db.String(255), nullable=False) Employee = db.relationship("Employee", backref='Empe', lazy=True) Station = db.relationship("Station", backref='Sts', lazy=True) TypeConge = db.relationship("TypeConge", backref='TpConge', lazy=True) Groupe = db.relationship("Groupe", backref='Grp', lazy=True) def __repr__(self): return f"Conge('{self.idConge}','{self.DateDebConge}','{self.DateFinConge}','{self.DescConge}','{self.idStation}','{self.idTypeConge}','{self.idEmp}','{self.idGroupe}')"
class Pompe(db.Model): __tablename__ = 'pompe' idPompe = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) NomPompe = db.Column(db.String(255), nullable=False) EtatPompe = db.Column(db.String(10), nullable=False, default="1") idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) Station = db.relationship("Station", backref='Stations', lazy=True) def __repr__(self): return f"Pompe('{self.idPompe}', '{self.NomPompe}', '{self.EtatPompe}','{self.idStation}') "
class User(db.Model, UserMixin): def defaultPass(self): return f'$2b$12$VILP2t3.JdQzbSx4qZ7jn.8dzueDJYjx12pJMoj/4ORyFRzPHkFY6' # Current Date def currentDate(self): import datetime return datetime.datetime.now().strftime("%Y-%m-%d") __tablename__ = 'user' idUser = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) codeUser = db.Column(db.String(255), nullable=False, unique=True) roleUser = db.Column(TINYINT, nullable=False, default=0) cinUser = db.Column(db.String(255), nullable=False, unique=True) emailUser = db.Column(db.String(255), nullable=False, unique=True) nomUser = db.Column(db.String(255), nullable=False) prenomUser = db.Column(db.String(255), nullable=False) dateUser = db.Column(db.DATE, nullable=False) telUser = db.Column(db.String(255), nullable=False, unique=True) passUser = db.Column(db.String(255), nullable=False, default=defaultPass) resetTokenUser = db.Column(db.String(255), nullable=False, default='0') createCompte = db.Column(db.DATE, nullable=False, default=currentDate) expiryCompte = db.Column(db.DATE, nullable=False) nbrAttempts = db.Column(db.Integer, nullable=False, default=3) etatCompte = db.Column(TINYINT, nullable=False, default=1) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) Station = db.relationship("Station", backref='Stat', lazy=True) def get_id(self): return self.idUser @property def is_authenticated(self): return True @property def is_active(self): return True @property def is_anonymous(self): return False def __repr__(self): return f"User('{self.idUser}', '{self.codeUser}' ,'{self.roleUser}', '{self.cinUser}','{self.emailUser}'," \ f"'{self.nomUser}','{self.prenomUser}','{self.dateUser}','{self.telUser}','{self.passUser}'," \ f"'{self.resetTokenUser}','{self.createCompte}','{self.expiryCompte}','{self.nbrAttempts}','{self.etatCompte}','{self.idStation}')"
class Employee(db.Model): __tablename__ = 'employee' idEmp = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) codeEmp = db.Column(db.String(255), nullable=False, unique=True) cinEmp = db.Column(db.String(255), nullable=False) nomEmp = db.Column(db.String(255), nullable=False) prenomEmp = db.Column(db.String(255), nullable=False) dateEmp = db.Column(db.DATE, nullable=False) telEmp = db.Column(db.String(255), nullable=False) salEmp = db.Column(db.Float, nullable=False) idGroupe = db.Column(db.ForeignKey('groupe.idGroupe'), nullable=False) idRole = db.Column(db.ForeignKey('role.idRole'), nullable=False) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) Role = db.relationship("Role", backref='Role', lazy=True) Station = db.relationship("Station", backref='Statn', lazy=True) Groupe = db.relationship("Groupe", backref='Group', lazy=True) def __repr__(self): return f"Employee('{self.idEmp}', '{self.codeEmp}' ,'{self.cinEmp}', '{self.nomEmp}', '{self.prenomEmp}', " \ f"'{self.dateEmp}','{self.telEmp}','{self.salEmp}','{self.idRole}','{self.idStation}')"
class Station(db.Model): __tablename__ = 'station' idStation = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) NomStation = db.Column(db.String(255), nullable=False) AdrStation = db.Column(db.String(255), nullable=False) idDelegation = db.Column(db.ForeignKey('delegation.idDelegation'), nullable=False) Delegation = db.relationship("Delegation", backref='Delegation', lazy=True) def __repr__(self): return f"Station('{self.idStation}','{self.NomStation}', '{self.AdrStation}', '{self.idDelegation}')"
class RecetteLavage(db.Model): __tablename__ = 'recettelavage' idRecetteLavage = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) MatriculeVoiture = db.Column(db.String(255), nullable=False) Kilometrage = db.Column(db.String(255), nullable=False) HeureDebut = db.Column(db.String(255), nullable=False) HeureFin = db.Column(db.String(255), nullable=False) DateLavage = db.Column(db.DATE, nullable=False, default=currentDate) PrixLavage = db.Column(db.Float, nullable=False) idLavage = db.Column(db.ForeignKey('lavage.idLavage'), nullable=False) idGroupe = db.Column(db.ForeignKey('groupe.idGroupe'), nullable=False) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) Lavage = db.relationship("Lavage", backref='Lavage', lazy=True) Groupe = db.relationship("Groupe", backref='Groupe', lazy=True) Station = db.relationship("Station", backref='Station', lazy=True) def __repr__(self): return f"RecetteLavage('{self.idRecetteLavage}', '{self.MatriculeVoiture}', " \ f"'{self.Kilometrage}', '{self.HeureDebut}', '{self.HeureFin}', '{self.DateLavage}'," \ f"'{self.idLavage}','{self.idGroupe}','{self.idStation}') "
class Expenses(db.Model): __tablename__ = 'expenses' idExpenses = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) dateExpenses = db.Column(db.DATE, nullable=False, default=currentDate) catExpenses = db.Column(db.String(255), nullable=False) descExpenses = db.Column(db.String(255), nullable=False) amExpenses = db.Column(db.Float, nullable=False) idStation = db.Column(db.ForeignKey('station.idStation'), nullable=False) Station = db.relationship("Station", backref='Stattion', lazy=True) def __repr__(self): return f"Expenses('{self.idExpenses}', '{self.dateExpenses}','{self.catExpenses}', '{self.descExpenses}', '{self.amExpenses}', '{self.idStation}')"
class ToDo(db.Model): __tablename__ = 'listuser' idListUser = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) objListUser = db.Column(db.String(255), nullable=False, unique=True) dateListUser = db.Column(db.Date, nullable=False, default=currentDate) stateListUser = db.Column(TINYINT, nullable=False, default=1) delListUser = db.Column(TINYINT, nullable=False, default=1) idUser = db.Column(db.ForeignKey('user.idUser'), nullable=False) User = db.relationship("User", backref='UserList', lazy=True) def __repr__(self): return f"ToDo('{self.idListUser}', '{self.objListUser}' ,'{self.dateListUser}', '{self.stateListUser}'," \ f" '{self.delListUser}','{self.idUser}')"
class LogUser(db.Model): __tablename__ = 'loguser' idLoginHist = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) srcIp = db.Column(db.String(255), nullable=False) dateAttempt = db.Column(db.String(255), nullable=False, default=currentDateTime) statusAttempt = db.Column(TINYINT, nullable=False) descAttempt = db.Column(db.String(255), nullable=False) idUser = db.Column(db.ForeignKey('user.idUser'), nullable=False) User = db.relationship("User", backref='User', lazy=True) def __repr__(self): return f"LogIn('{self.idLoginHist}', '{self.srcIp}' , '{self.dateAttempt}','{self.statusAttempt}','{self.descAttempt}','{self.idUser}')"
class Comment(db.Model): def currentDateTime(self): import datetime now = datetime.datetime.now() return now.strftime("%Y-%m-%d %H:%M:%S") __tablename__ = 'comments' comment_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) comment_subject = db.Column(db.String(255), nullable=False) comment_date = db.Column(db.String(255), nullable=False, default=currentDateTime) comment_text = db.Column(db.String(255), nullable=False) comment_status = db.Column(TINYINT, nullable=False, default=1) idUser = db.Column(db.ForeignKey('user.idUser'), nullable=False) User = db.relationship("User", backref='Users', lazy=True) def __repr__(self): return f"Comment('{self.comment_id}', '{self.comment_subject}', '{self.comment_date}', '{self.comment_text}','{self.comment_status}','{self.idUser}')"