class CartModel(db.Model): __tablename__ = "carts" id = db.Column(db.Integer, primary_key=True, autoincrement=True) total_harga = db.Column(db.Integer, default=0) total_kuantitas = db.Column(db.Integer, default=0) ongkir = db.Column(db.Integer, default=0) status_checkout = db.Column(db.Boolean, default=False) seller_id = db.Column(db.Integer, db.ForeignKey('sellers.id')) buyer_id = db.Column(db.Integer, db.ForeignKey('buyers.id')) products = db.relationship('TransactionDetails', backref='carts', lazy=True, uselist=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'total_harga': fields.Integer, 'total_kuantitas': fields.Integer, 'ongkir': fields.Integer, 'seller_id': fields.Integer, 'buyer_id': fields.Integer, 'status_checkout': fields.Boolean, 'updated_at': fields.DateTime, 'created_at': fields.DateTime, } def __init__(self, seller_id, buyer_id): self.seller_id = seller_id self.buyer_id = buyer_id def __repr__(self): return '<Products %r>' % self.id
class Users(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(30), unique=True, nullable=False) age = db.Column(db.Integer, nullable=True, default=20) sex = db.Column(db.String(10), nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=db.func.now()) deleted_at = db.Column(db.DateTime) client_id = db.Column(db.Integer, db.ForeignKey('client.id')) response_field = { 'created_at':fields.DateTime, 'updated_at':fields.DateTime, 'deleted_at':fields.DateTime, 'id':fields.Integer, 'name': fields.String, 'age': fields.Integer, 'sex': fields.String, "client_id": fields.Integer, } def __init__(self, name, age, sex,client_id): self.name = name self.age = age self.sex = sex self.client_id = client_id def __repr__(self): return '<User %r>' % self.id
class Shipping(db.Model): __tablename__ = "shipping" id = db.Column(db.Integer, primary_key=True, autoincrement=True) transaction_id = db.Column(db.Integer, ForeignKey(Transaction.id, ondelete='CASCADE'), nullable=False) origin = db.Column(db.Integer, nullable=False) destination = db.Column(db.Integer, nullable=False) weight = db.Column(db.Integer, nullable=False) fee = db.Column(db.Numeric(12,2), nullable=False) shipping_number = db.Column(db.String(100), nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id' : fields.Integer, 'transaction_id' : fields.Integer, 'origin' : fields.String, 'destination' :fields.String, 'weight' :fields.Integer, 'fee' : fields.Integer, 'shipping_number' : fields.String, 'created_at' : fields.String, 'updated_at' : fields.String } def __init__(self, transaction_id, origin, destination, weight, fee, shipping_number): self.transaction_id = transaction_id self.origin = origin self.destination = destination self.weight = weight self.fee = fee self.shipping_number = shipping_number def __repr__(self): return '<Shipping %r>' % self.id
class Questions(db.Model): __tablename__ = "questions" id = db.Column(db.Integer, primary_key=True, autoincrement=True) quiz_id = db.Column(db.Integer, db.ForeignKey(Quizs.id, ondelete="CASCADE"), nullable=False) question = db.Column(db.String(2000), nullable=False) choice = db.relationship("Choices", cascade="all, delete-orphan", passive_deletes=True) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { "id": fields.Integer, "quiz_id": fields.Integer, "question": fields.String, "created_at": fields.DateTime, "update_at": fields.DateTime, } def __init__(self, quiz_id, question): self.quiz_id = quiz_id self.question = question def __rpr__(self): return "<Questions %r>" % self.id
class Clients(db.Model): __tablename__ = "client" id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(100), nullable=False, unique=True) password = db.Column(db.String(255)) salt = db.Column(db.String(255)) status = db.Column(db.Boolean, nullable=True, default=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'username': fields.String, 'password': fields.String, 'status': fields.Boolean, 'created_at': fields.DateTime, 'updated_at': fields.DateTime } jwt_claims_fields = { 'id': fields.Integer, 'username': fields.String, 'status': fields.Boolean } def __init__(self, username, password, status, salt): self.username = username self.password = password self.status = status self.salt = salt def __repr__(self): return '<Client %r>' % self.id
class ProductLike(db.Model): __tablename__ = "product_like" id = db.Column(db.Integer, primary_key=True, autoincrement=True) user_id = db.Column(db.Integer, ForeignKey(Users.id, ondelete='CASCADE'), unique=True, nullable=False) product_id = db.Column(db.Integer, ForeignKey(Product.id, ondelete='CASCADE'), nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'user_id': fields.Integer, 'product_id': fields.Integer, 'created_at': fields.String, 'updated_at': fields.String } def __init__(self, user_id, product_id): self.user_id = user_id self.product_id = product_id def __repr__(self): return '<ProductLike %r>' % self.id
class Conversations(db.Model): __tablename__ = "conversations" id = db.Column(db.Integer, primary_key=True, autoincrement=True) user1_id = db.Column(db.Integer, db.ForeignKey('users.id')) user2_id = db.Column(db.Integer, db.ForeignKey('users.id')) # status_deleted = db.Column(db.Boolean, nullable=False) personal_message = db.relationship('PersonalMessages', backref='conversations', lazy=True, uselist=False) created_at = db.Column(db.DateTime(timezone=True),server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id':fields.Integer, 'user1_id':fields.Integer, 'user2_id':fields.Integer, # 'status_deleted':fields.Boolean 'created_at':fields.DateTime } def __init__(self, user1_id, user2_id): self.user1_id = user1_id self.user2_id = user2_id # self.status_deleted = status_deleted def __repr__(self): return '<Conversation %r>' % self.id
class Lokasi(db.Model): __tablename__ = "table_lokasi" id = db.Column(db.Integer, primary_key=True, autoincrement=True) lokasi_restoran = db.Column(db.String(2000), unique=True, nullable=False) table_restoran = db.relationship('Restoran', backref="table_lokasi", lazy=True) lat = db.Column(db.Float) lon = db.Column(db.Float) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'lokasi_restoran': fields.String, 'lat': fields.Float, 'lon': fields.Float, 'created_at': fields.DateTime, 'updated_at': fields.DateTime } def __init__(self, lokasi_restoran, lat, lon): self.lokasi_restoran = lokasi_restoran self.lat = lat self.lon = lon def __repr__(self): return '<Lokasi %r>' % self.id
class Transaksis(db.Model): __tablename__ = "transaksi" id = db.Column(db.Integer, primary_key=True, autoincrement=True) pembeli = db.Column(db.String(1000), nullable=False) produk = db.Column(db.String(1000), nullable=False) total_harga = db.Column(db.Integer) total_barang = db.Column(db.Integer) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'pembeli': fields.String, 'produk': fields.String, 'total_harga': fields.Integer, 'total_barang': fields.Integer, 'created_at': fields.DateTime, 'updated_at': fields.DateTime } def __init__(self, pembeli, produk, total_harga, total_barang): self.pembeli = pembeli self.produk = produk self.total_harga = total_harga self.total_barang = total_barang def __repr__(self): return '<Transaksi %r>' % self.id
class TransactionDetails(db.Model): __tablename__ = 'transaction_detail' id = db.Column(db.Integer, primary_key=True, autoincrement=True) transaction_id = db.Column(db.Integer, db.ForeignKey('transaction.id')) product_id = db.Column(db.Integer, db.ForeignKey('product.id')) price = db.Column(db.Integer, nullable=False) qty = db.Column(db.Integer, nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) product_review = db.relationship('ProductReviews', backref='transaction_detail', lazy=True) response_field = { 'id':fields.Integer, 'transaction_id':fields.Integer, 'product_id':fields.Integer, 'price':fields.Integer, 'qty':fields.Integer, 'created_at': fields.DateTime, 'updated_at': fields.DateTime } def __init__(self, transaction_id, product_id, price, qty): self.transaction_id = transaction_id self.product_id = product_id self.price = price self.qty = qty def __repr__(self): return '<TransactionDetail %r>' % self.id
class Weeks(db.Model): __tablename__ = "weeks" id = db.Column(db.Integer, primary_key=True, autoincrement=True) course_id = db.Column( db.Integer, db.ForeignKey(Courses.id, ondelete="CASCADE"), nullable=False ) name_week = db.Column(db.String(200), nullable=False) duration_week = db.Column(db.Integer, default=7) moduls = db.relationship( "Moduls", cascade="all, delete-orphan", passive_deletes=True ) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { "id": fields.Integer, "course_id": fields.Integer, "name_week": fields.String, "duration_week": fields.Integer, "created_at": fields.DateTime, "update_at": fields.DateTime, } def __init__(self, course_id, name_week): self.course_id = course_id self.name_week = name_week def __rpr__(self): return "<Weeks %r>" % self.id
class Menu(db.Model): __tablename__ = "table_menu" id = db.Column(db.Integer, primary_key=True, autoincrement=True) nama_menu = db.Column(db.String(100), nullable=False, unique=True) gambar_menu = db.Column(db.String(255)) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) table_restoran = db.relationship('Restoran', backref="table_menu", lazy=True) response_fields = { 'id': fields.Integer, 'nama_menu': fields.String, 'gambar_menu': fields.String, 'created_at': fields.DateTime, 'updated_at': fields.DateTime } def __init__(self, nama_menu, gambar_menu): self.nama_menu = nama_menu self.gambar_menu = gambar_menu def __repr__(self): return '<Menu %r>' % self.id
class QuestionsAltatest(db.Model): __tablename__ = "questions_altatest" id = db.Column(db.Integer, primary_key=True, autoincrement=True) admin_id = db.Column(db.Integer, db.ForeignKey(Admins.id, ondelete="CASCADE"), nullable=False) question = db.Column(db.Text, nullable=False) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) choice_altatest = db.relationship("ChoicesAltatest", cascade="all, delete-orphan", passive_deletes=True) response_fields = { "id": fields.Integer, "admin_id": fields.Integer, "question": fields.String, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime, } def __init__(self, admin_id, question, status): self.admin_id = admin_id self.question = question self.status = status def __rpr__(self): return "<Questions %r>" % self.id
class TransactionDetailModel(db.Model): __tablename__ = "transaction_details" id = db.Column(db.Integer, primary_key=True, autoincrement=True) harga = db.Column(db.Integer, default=0) kuantitas = db.Column(db.Integer, default=0) cart_id = db.Column(db.Integer, db.ForeignKey('carts.id')) product_id = db.Column(db.Integer, db.ForeignKey('products.id')) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'harga': fields.Integer, 'kuantitas': fields.Integer, 'cart_id': fields.Integer, 'product_id': fields.Integer, } def __init__(self, harga, kuantitas, cart_id, product_id): self.harga = harga self.kuantitas = kuantitas self.cart_id = cart_id self.product_id = product_id def __repr__(self): return '<TransactionDetails %r>' % self.id
class ChoicesQuiz(db.Model): __tablename__ = "choices_quiz" id = db.Column(db.Integer, primary_key=True, autoincrement=True) question_id = db.Column(db.Integer, db.ForeignKey(QuestionsQuiz.id, ondelete="CASCADE"), nullable=False) choice = db.Column(db.Text, nullable=False) is_correct = db.Column(db.Boolean) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { "id": fields.Integer, "question_id": fields.Integer, "choice": fields.String, "is_correct": fields.Boolean, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime, } def __init__(self, question_id, choice, is_correct, status): self.question_id = question_id self.choice = choice self.is_correct = is_correct self.status = status def __rpr__(self): return "<Questions %r>" % self.id
class Quizs(db.Model): __tablename__ = "quizs" id = db.Column(db.Integer, primary_key=True, autoincrement=True) exam_id = db.Column(db.Integer, db.ForeignKey(Exams.id, ondelete="CASCADE"), nullable=False) name = db.Column(db.String(250)) description = db.Column(db.Text) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) questions_quiz = db.relationship("QuestionsQuiz", cascade="all, delete-orphan", passive_deletes=True) response_fields = { "id": fields.Integer, "exam_id": fields.Integer, "name": fields.String, "description": fields.String, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime, } def __init__(self, exam_id, name, description, status): self.exam_id = exam_id self.name = name self.description = description self.status = status def __rpr__(self): return "<Questions %r>" % self.id
class CustomerMember(db.Model): __tablename__ = "customer_member" id = db.Column(db.Integer, primary_key=True, autoincrement=True) customer_id = db.Column(db.Integer, db.ForeignKey(Customer.id, ondelete="CASCADE")) group_id = db.Column(db.Integer, db.ForeignKey('customer_group.id')) created_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=db.func.now()) response_fields = { 'id': fields.Integer, 'customer_id': fields.Integer, 'group_id': fields.Integer, 'created_at': fields.DateTime, 'updated_at': fields.DateTime, } def __init__(self, customer_id, group_id): self.customer_id = customer_id self.group_id = group_id def __repr__(self): return '<CustomerMember %r>' % self.id
class Komens(db.Model): __tablename__ = "komen" id = db.Column(db.Integer, primary_key=True, autoincrement=True) komen = db.Column(db.String(255), nullable=True, default='Title Image') user_id = db.Column(db.Integer, db.ForeignKey('user.id')) image_id = db.Column(db.Integer, db.ForeignKey('image.id')) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'komen': fields.String, 'created_at': fields.DateTime, 'updated_at': fields.DateTime, 'user_id': fields.Integer, 'image_id': fields.Integer } def __init__(self, komen, user_id, image_id): self.komen = komen self.user_id = user_id self.image_id = image_id def __repr__(self): return '<Komen %r>' % self.id
class ReviewsModule(db.Model): __tablename__ = "reviews_module" id = db.Column(db.Integer, primary_key=True, autoincrement=True) mentee_id = db.Column(db.Integer, db.ForeignKey(Mentees.id, ondelete="CASCADE"), nullable=False) module_id = db.Column(db.Integer, db.ForeignKey(Modules.id, ondelete="CASCADE"), nullable=False) content = db.Column(db.Text) score = db.Column(db.Integer) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { "id": fields.Integer, "mentee_id": fields.Integer, "module_id": fields.Integer, "content": fields.String, "score": fields.Integer, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime } def __init__ (self, mentee_id, module_id, content, score, status): self.mentee_id = mentee_id self.module_id = module_id self.content = content self.score = score self.status = status def __rpr__(self): return "<Users %r>" % self.id
class BuyerModel(db.Model): __tablename__ = "buyers" id = db.Column(db.Integer, primary_key=True, autoincrement=True) nama = db.Column(db.String(50), nullable=False) email = db.Column(db.String(50), nullable=False) alamat = db.Column(db.String(255)) no_hp = db.Column(db.String(15)) user_id = db.Column(db.Integer, db.ForeignKey('users.id')) cart = db.relationship('Carts', backref='buyers', lazy=True, uselist=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'nama': fields.String, 'email': fields.String, 'alamat': fields.String, 'no_hp': fields.String, 'user_id':fields.Integer } def __init__(self, nama, email, alamat, no_hp, user_id): self.nama = nama self.email = email self.alamat = alamat self.no_hp = no_hp self.user_id = user_id def __repr__(self): return '<Buyer %r>' % self.id
class HistoriesExam(db.Model): __tablename__ = "histories_exam" id = db.Column(db.Integer, primary_key=True, autoincrement=True) exam_id = db.Column(db.Integer, db.ForeignKey(Exams.id, ondelete="CASCADE"), nullable=False) mentee_id = db.Column(db.Integer, db.ForeignKey(Mentees.id, ondelete="CASCADE"), nullable=False) score = db.Column(db.Integer) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { "id": fields.Integer, "exam_id": fields.Integer, "mentee_id": fields.Integer, "score": fields.Integer, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime } def __init__(self, exam_id, mentee_id, score, status): self.exam_id = exam_id self.mentee_id = mentee_id self.score = score self.status = status def __rpr__(self): return "<Users %r>" % self.id
class ReviewProduk(db.Model): __tablename__ = "table_review_produk" id = db.Column(db.Integer, primary_key=True, autoincrement=True) gambar = db.Column(db.String(255)) review = db.Column(db.String(255), nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) transaction_detail_id = db.Column(db.Integer, db.ForeignKey('transaction_detail.id')) response_fields = { 'id': fields.Integer, 'gambar': fields.String, 'review': fields.String, 'created_at': fields.DateTime, 'updated_at': fields.DateTime, 'transaction_detail_id': fields.Integer } def __init__(self, gambar, review): self.gambar = gambar self.review = review def __repr__(self): return '<ReviewProduk %r>' % self.id
class Exams(db.Model): __tablename__ = "exams" id = db.Column(db.Integer, primary_key=True, autoincrement=True) subject_id = db.Column(db.Integer, db.ForeignKey(Subjects.id, ondelete="CASCADE"), nullable=False) type_exam = db.Column(db.String(250), nullable=False) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) livecode = db.relationship("Livecodes", cascade="all, delete-orphan", passive_deletes=True) quiz = db.relationship("Quizs", cascade="all, delete-orphan", passive_deletes=True) history_exam = db.relationship("HistoriesExam", cascade="all, delete-orphan", passive_deletes=True) response_fields = { "id": fields.Integer, "subject_id": fields.Integer, "type_exam": fields.String, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime } def __init__ (self, subject_id, type_exam, status): self.subject_id = subject_id self.type_exam = type_exam self.status = status def __rpr__(self): return "<Users %r>" % self.id
class Bios(db.Model): __tablename__ = "bio" id = db.Column(db.Integer, primary_key=True, autoincrement=True) fullname = db.Column(db.String(100), nullable=False) address = db.Column(db.Text, nullable=False) contact = db.Column(db.String(15), nullable=False) sex = db.Column(db.String(1), nullable=True) user_id = db.Column(db.Integer, ForeignKey(Users.id, ondelete='CASCADE'), unique=True, nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id' : fields.Integer, 'fullname' : fields.String, 'address' : fields.String, 'contact' : fields.String, 'sex' : fields.String, 'user_id' : fields.Integer, 'created_at' : fields.String, 'updated_at' : fields.String } def __init__(self, fullname, address, contact, sex, user_id): self.fullname = fullname self.address = address self.contact = contact self.sex = sex self.user_id = user_id def __repr__(self): return '<Bio %r>' % self.id
class Altatests(db.Model): __tablename__ = "altatests" id = db.Column(db.Integer, primary_key=True, autoincrement=True) question_sum = db.Column(db.Integer) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) altatest_history = db.relationship("HistoriesAltatest", cascade="all, delete-orphan", passive_deletes=True) response_fields = { "id": fields.Integer, "question_sum": fields.Integer, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime } def __init__(self, question_sum, status): self.question_sum = question_sum self.status = status def __rpr__(self): return "<Users %r>" % self.id
class TransaksiDetail(db.Model): __tablename__ = 'transaction_detail' id = db.Column(db.Integer, primary_key=True, autoincrement=True) transaction_id = db.Column(db.Integer, db.ForeignKey('table_transaksi.id')) produk_id = db.Column(db.Integer, db.ForeignKey('table_produk.id')) harga = db.Column(db.Integer, nullable=False) qty = db.Column(db.Integer, nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) product_reviews = db.relationship( 'ReviewProduk', backref='transaction_detail', lazy=True) response_field = { 'id': fields.Integer, "pembeli_id": fields.Integer, "produk_id": fields.Integer, "harga": fields.Integer, "qty": fields.Integer, 'created_at': fields.DateTime, 'updated_at': fields.DateTime } def __init__(self, transaction_id, produk_id, harga, qty): self.transaction_id = transaction_id self.produk_id = produk_id self.harga = harga self.qty = qty def __repr__(self): return '<TransactionDetail %r>' % self.id
class ProductImg(db.Model): __tablename__ = "product_img" id = db.Column(db.Integer, primary_key=True, autoincrement=True) img_path = db.Column(db.Text, nullable=False) img_desc = db.Column(db.Text, nullable=False) product_id = db.Column(db.Integer, ForeignKey(Product.id, ondelete='CASCADE'), nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { 'id': fields.Integer, 'img_path': fields.String, 'img_desc': fields.String, 'product_id': fields.Integer, 'created_at': fields.String, 'updated_at': fields.String } def __init__(self, img_path, img_desc, product_id): self.img_path = img_path self.img_desc = img_desc self.product_id = product_id def __repr__(self): return '<ProductImg %r>' % self.id
class DetailsAltatest(db.Model): __tablename__ = "details_altatest" id = db.Column(db.Integer, primary_key=True, autoincrement=True) altatest_id = db.Column(db.Integer, db.ForeignKey(Altatests.id, ondelete="CASCADE"), nullable=False) question_id = db.Column(db.Integer, db.ForeignKey(QuestionsAltatest.id, ondelete="CASCADE"), nullable=False) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { "id": fields.Integer, "altatest_id": fields.Integer, "question_id": fields.Integer, "status": fields.Boolean, "created_at": fields.DateTime, "updated_at": fields.DateTime } def __init__ (self, altatest_id, question_id,status): self.altatest_id = altatest_id self.question_id = question_id self.status = status def __rpr__(self): return "<Users %r>" % self.id
class Livecodes(db.Model): __tablename__ = "livecodes" id = db.Column(db.Integer, primary_key=True, autoincrement=True) exam_id = db.Column(db.Integer, db.ForeignKey(Exams.id, ondelete="CASCADE"), nullable=False) name = db.Column(db.String(250)) description = db.Column(db.Text) link = db.Column(db.String(250)) status = db.Column(db.Boolean) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) response_fields = { "id": fields.Integer, "exam_id": fields.Integer, "name": fields.String, "description": fields.String, "link": fields.String, "status": fields.Boolean, "created_at": fields.DateTime, "update_at": fields.DateTime, } def __init__(self, exam_id, name, description, link, status): self.exam_id = exam_id self.name = name self.description = description self.link = link self.status = status def __rpr__(self): return "<Questions %r>" % self.id
class SubCategories(db.Model): __tablename__ = "subcategory" id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(100), nullable=False, unique=True) category_id = db.Column(db.Integer, ForeignKey(Categories.id, ondelete='CASCADE'), nullable=False) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) product = db.relationship("Products", cascade="all, delete-orphan", passive_deletes=True) response_fields = { 'id': fields.Integer, 'name': fields.String, 'category_id': fields.Integer, 'created_at': fields.DateTime, 'updated_at': fields.DateTime } def __init__(self, name, category_id): self.name = name self.category_id = category_id def __repr__(self): return '<SubCategories %r>' % self.id