class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) def get_reset_token(self, expires_sec=1800): s = Serializer(app.config['SECRET_KEY'], expires_sec) return s.dumps({'user_id': self.id}).decode('utf-8') @staticmethod def verify_reset_token(token): s = Serializer(app.config['SECRET_KEY']) try: user_id = s.loads(token)['user_id'] except: return None return User.query.get(user_id) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Classe(db.Model): id = db.Column(db.Integer, primary_key=True) nom_classe = db.Column(db.String(100), nullable=False) serie = db.Column(db.String(100), nullable=False) students = db.relationship('Student', backref='classezer', lazy=True) def __repr__(self): return f"Classe('{self.nom_classe}', '{self.serie}' )"
class Salary(db.Model): __tablename__ = 'salary' id = db.Column(db.Integer(), primary_key=True) type_oparation = db.Column( db.String()) #прихід - зароблено викладачем, розхід - виплата зп amount = db.Column(db.Integer()) #беремо з таблички rate teacher_id = db.Column(db.String(), db.ForeignKey('teachers.id'))
class Lessons(db.Model): __tablename__ = 'lessons' id = db.Column(db.Integer, primary_key=True) plan_date = db.Column(db.Date()) teacher_id = db.Column(db.String(), db.ForeignKey('teachers.id')) student_id = db.Column(db.String(), db.ForeignKey('students.id')) lessons_price = db.Column(db.Integer()) status = db.Column( db.String()) #заплановано, відхилено, проведено, оплачено
class Student(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) Prenom = db.Column(db.String(20), unique=False, nullable=False) Nom = db.Column(db.String(20), unique=False, nullable=False) Date_Naissance = db.Column(db.String(100), nullable=False) classe_id = db.Column(db.Integer, db.ForeignKey('classe.id'), nullable=False) def __repr__(self): return f"Student('{self.Prenom}', '{self.Nom}', '{self.Date_Naissance}')"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Post('{self.title}', '{self.date_posted}')"
class Students(db.Model): __tablename__ = 'students' id = db.Column(db.Integer(), primary_key=True) first_name = db.Column(db.String()) second_name = db.Column(db.String()) sex = db.Column(db.String()) # 'F' or 'M' email = db.Column(db.String(), unique=True, nullable=False) birthday = db.Column(db.Date()) city = db.Column(db.String()) postal_code = db.Column(db.String()) instagram = db.Column(db.String()) status = db.Column( db.String()) # активий, потенційний, випускник, встрачений
class Teachers(db.Model): __tablename__ = 'teachers' id = db.Column(db.Integer(), primary_key=True) first_name = db.Column(db.String(), nullable=False) second_name = db.Column(db.String(), nullable=False) email = db.Column(db.String(), unique=True, nullable=False) birthday = db.Column(db.Date()) city = db.Column(db.String()) postal_code = db.Column(db.String()) instagram = db.Column(db.String()) status = db.Column(db.String()) # активий, звільнений, відпустка
class Rate(db.Model): __tablename__ = 'rate' id = db.Column(db.Integer, primary_key=True) date = db.Column(db.Date()) rate = db.Column(db.Integer(), nullable=False) teacher_id = db.Column(db.String(), db.ForeignKey('teachers.id'))