class Seller(db.Model): __tablename__ = 'sellers' id = db.Column(db.Integer, primary_key=True, autoincrement=True) full_name = db.Column(db.String(255)) email = db.Column(db.String(255), unique=True) password = db.Column(db.String(255)) password_hash = db.Column(db.String(255)) gender = db.Column(db.String(255)) phone_number = db.Column(db.String(255)) status_seller = db.Column(db.Boolean(), default=True) created_at = db.Column(db.DateTime, default=TIME) updated_at = db.Column(db.DateTime, default=TIME) deleted_at = db.Column(db.DateTime, default=TIME) item = db.relationship('Item', backref='sellers', lazy=True) def generate_password_hash(self, password): self.password_hash = generate_password_hash(password) def check_password_hash(self, password) : return check_password_hash(self.password_hash, password) def set_status_seller(self, status): self.status_seller = status def __repr__(self): return '< This seller is {} >'.format(self.full_name)
class Tutor(db.Model): __tablename__ = "tutors" id = db.Column(db.Integer, unique=True, primary_key=True, autoincrement=True) tutor_uuid = db.Column(UUID(as_uuid=True), unique=True, primary_key=True, default=uid()) full_name = db.Column(db.String(255)) email = db.Column(db.String(255), unique=True) phone_number = db.Column(db.String(255)) password = db.Column(db.String(255)) password_hash = db.Column(db.String(255)) address = db.Column(db.String(255)) education = db.Column(db.String(255)) experience = db.Column(db.Text) gender = db.Column(db.String(100)) status_login = db.Column(db.Boolean, default=False) is_working = db.Column(db.Boolean, default=True) activation = db.Column(db.Boolean, default=False) number_like = db.Column(db.Integer, default=0) number_dislike = db.Column(db.Integer, default=0) current_income = db.Column(db.Integer, default=0) total_income = db.Column(db.Integer, default=0) created_at = db.Column(db.DateTime, default=TIME) updated_at = db.Column(db.DateTime) deleted_at = db.Column(db.DateTime) # time activated, time_reactivated, time_login = db.Column(db.DateTime) time_logout = db.Column(db.DateTime) time_tutor_on = db.Column(db.DateTime) time_tutor_off = db.Column(db.DateTime) time_unactivated = db.Column(db.DateTime) time_reactivated = db.Column(db.DateTime) subject = db.relationship('Subject', backref='owner', lazy=True) history = db.relationship('HistoryTutor', backref='history', lazy=True) def generate_password_hash(self, password): self.password_hash = generate_password_hash(password) def check_password_hash(self, password): return check_password_hash(self.password_hash, password) def __repr__(self): return '<this is {}>'.format(self.full_name)
class Student(db.Model): __tablename__ = "students" id = db.Column(db.Integer, unique=True, primary_key=True, autoincrement=True) student_uuid = db.Column(UUID(as_uuid=True), unique=True, primary_key=True, default=uid()) full_name = db.Column(db.String(255)) email = db.Column(db.String(255)) password = db.Column(db.String(255)) password_hash = db.Column(db.String(255)) gender = db.Column(db.String(255)) grade = db.Column(db.String(255)) phone_number = db.Column(db.String(255)) school = db.Column(db.String(255)) address = db.Column(db.String(255)) status_login = db.Column(db.Boolean, default=False) activation = db.Column(db.Boolean, default=True) created_at = db.Column(db.DateTime, default=TIME) updated_at = db.Column(db.DateTime) # time activated, time_reactivated, deleted_at = db.Column(db.DateTime) time_login = db.Column(db.DateTime, default=TIME) time_logout = db.Column(db.DateTime) subscriptions = db.relationship('Subject', secondary=tutoring, lazy='subquery', backref=db.backref('subscribers', lazy="dynamic")) history = db.relationship('HistoryStudent', backref='history', lazy=True) def generate_password_hash(self, password): self.password_hash = generate_password_hash(password) def check_password_hash(self, password): return check_password_hash(self.password_hash, password) def __repr__(self): return '<this is {}>'.format(self.full_name)
class Item(db.Model): __tablename__ = 'items' id = db.Column(db.Integer, primary_key=True) item_title = db.Column(db.String(255)) status_item = db.Column(db.Boolean(), default=True) description = db.Column(db.Text) price = db.Column(db.String(255)) number_like = db.Column(db.Integer, default=0) number_dislike = db.Column(db.Integer, default=0) created_at = db.Column(db.DateTime, default=TIME) updated_at = db.Column(db.DateTime, default=TIME) deleted_at = db.Column(db.DateTime, default=TIME) seller = db.Column(db.Integer, db.ForeignKey('sellers.id'), nullable=True) file_seller = db.relationship('FileSeller', backref='items', lazy=True) def __repr__(self): return '< This item with title {} belongs to {} >'.format(self.item_title, self.owner)
class Subject(db.Model): __tablename__ = "subjects" id = db.Column(db.Integer, unique=True, primary_key=True, autoincrement=True) subject_uuid = db.Column(UUID(as_uuid=True), unique=True, primary_key=True, default=uid()) subject_name = db.Column(db.String(255)) price = db.Column(db.Integer, default=0) description = db.Column(db.Text) created_at = db.Column(db.DateTime, default=TIME) updated_at = db.Column(db.DateTime) deleted_at = db.Column(db.DateTime) status = db.Column(db.Boolean, default=True) tutor = db.Column(UUID(as_uuid=True), db.ForeignKey('tutors.tutor_uuid')) summary = db.relationship('Summary', backref='owner', lazy=True) def __repr__(self): return '< {} this subject belongs to {}>'.format( self.subject_name, self.tutor)