class TwitterUser(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, unique = False, nullable = False) username = db.Column(db.String(120), unique=False) name = db.Column(db.String(120), unique=False, nullable=False) def __repr__(self): return f"TwitterUser('{self.user_id}', '{self.username}')"
class UserQuery(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"UserQuery('{self.title}', '{self.date_posted}')"
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) userquerys = db.relationship('UserQuery', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class Parent(db.Model): id = db.Column(db.String(32), primary_key=True) type = db.Column(db.String(32)) name = db.Column(db.String(250)) phone = db.Column(db.String(100)) email = db.Column(db.String(100)) ic_no = db.Column(db.String(100)) password = db.Column(db.String(100)) date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) student_id = db.Column( db.ForeignKey('student.id', ondelete="CASCADE", onupdate="CASCADE")) is_deleted = db.Column(db.Boolean, default=1) def __init__(self, name): self.id = uuid.uuid4().hex self.name = name
class Tweet(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, unique = False, nullable = False) tweet = db.Column(db.String(120), unique=False, nullable=False) likes_count = db.Column(db.Integer, unique = False) replies_count = db.Column(db.Integer, unique = False) retweets_count = db.Column(db.Integer, unique = False) def __repr__(self): return f"Tweet('{self.user_id}', '{self.tweet}')"
class PaymentDetail(db.Model): id = db.Column(db.String(32), primary_key=True) type = db.Column(db.String(32)) desc = db.Column(db.TEXT) price = db.Column(db.String(32)) payment_id = db.Column( db.ForeignKey('payment.id', ondelete="CASCADE", onupdate="CASCADE")) date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) is_deleted = db.Column(db.Boolean, default=1) def __init__(self, price, desc): self.id = uuid.uuid4().hex self.price = price self.desc = desc
class Academy(db.Model): id = db.Column(db.String(32), primary_key=True) year = db.Column(db.String(10)) sem = db.Column(db.String(32)) desc = db.Column(db.TEXT) date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) student_id = db.Column( db.ForeignKey('student.id', ondelete="CASCADE", onupdate="CASCADE")) is_deleted = db.Column(db.Boolean, default=1) def __init__(self, year, sem, desc): self.id = uuid.uuid4().hex self.year = year self.sem = sem self.desc = desc
class User(db.Model): id = db.Column(db.String(32), primary_key=True) name = db.Column(db.String(250)) phone = db.Column(db.String(100), unique=True) email = db.Column(db.String(100), unique=True) password = db.Column(db.String(100)) date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) is_deleted = db.Column(db.Boolean, default=1) def __init__(self, name, email, role, password): self.id = uuid.uuid4().hex self.name = name self.email = email self.role = role self.password = password
class AcademyDetail(db.Model): id = db.Column(db.String(32), primary_key=True) name = db.Column(db.String(250)) grade = db.Column(db.String(25)) desc = db.Column(db.TEXT) date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) is_deleted = db.Column(db.Boolean, default=1) def __init__(self, name, grade): self.id = uuid.uuid4().hex self.name = name self.grade = grade
class Student(db.Model): id = db.Column(db.String(32), primary_key=True) intake = db.Column(db.String(32)) student_no = db.Column(db.String(32)) ic_no = db.Column(db.String(32)) name = db.Column(db.String(300)) password = db.Column(db.String(100)) date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) parent_detail = db.relationship("Parent", backref="student", cascade="all, delete-orphan") academy_detail = db.relationship("Academy", backref="student", cascade="all, delete-orphan") is_deleted = db.Column(db.Boolean, default=1) def __init__( self, name, ): self.id = uuid.uuid4().hex self.name = name
class Payment(db.Model): id = db.Column(db.String(32), primary_key=True) receipt_no = db.Column(db.String(32)) desc = db.Column(db.TEXT) payment_detail = db.relationship("PaymentDetail", backref="payment", cascade="all, delete-orphan") date_created = db.Column(db.DateTime, default=db.func.current_timestamp()) is_pay = db.Column(db.Boolean, default=1) is_deleted = db.Column(db.Boolean, default=1) def __init__(self, receipt_no, desc): self.id = uuid.uuid4().hex self.receipt_no = receipt_no self.desc = desc