class Category(db.Model): id=db.Column(db.Integer,primary_key=True) name=db.Column(db.String(80),nullable=False,unique=True) def __repr__(self): return f"Category('{self.id}','{self.name}')"
class Customer_order(db.Model): id=db.Column(db.Integer,primary_key=True) invoice=db.Column(db.String(20),unique=True,nullable=False) status=db.Column(db.String(20),default='Pending',nullable=False) customer_id=db.Column(db.Integer,unique=False,nullable=False) date_created=db.Column(db.DateTime,default=datetime.utcnow,nullable=False) orders=db.Column(JsonEcodedDict) def __repr__(self): return f"Customer_order('{self.customer_id}','{self.orders}'{self.invoice}')"
class Product(db.Model): id=db.Column(db.Integer,primary_key=True) name=db.Column(db.String(120),nullable=False) price= db.Column(db.Integer, nullable=False) discount=db.Column(db.Integer, nullable=False,default=0) stock= db.Column(db.Integer, nullable=False) desc= db.Column(db.Text, nullable=False) colors= db.Column(db.Text, nullable=False) pub_date = db.Column(db.DateTime, nullable=False,default=datetime.utcnow) brand_id=db.Column(db.Integer,db.ForeignKey('brand.id'),nullable=False) brand=db.relationship('Brand',backref=db.backref('brand',lazy=True)) category_id = db.Column(db.Integer, db.ForeignKey('category.id'),nullable=False) category = db.relationship('Category',backref=db.backref('category',lazy=True)) image_1=db.Column(db.String(120),nullable=False,default='default.jpg') image_2=db.Column(db.String(120),nullable=False,default='default.jpg') image_3=db.Column(db.String(120),nullable=False,default='default.jpg') def __repr__(self): return f"Product('{self.id}','{self.name}')"
class Customer(db.Model,UserMixin): id=db.Column(db.Integer,primary_key=True) name=db.Column(db.String(100),unique=False) # l_name=db.Column(db.String(100),unique=False) username=db.Column(db.String(100),unique=True) email=db.Column(db.String(120),unique=True) password=db.Column(db.String(200),unique=False) country=db.Column(db.String(100),unique=False) state=db.Column(db.String(100),unique=False) city=db.Column(db.String(100),unique=False) contact=db.Column(db.String(100),unique=False) address=db.Column(db.String(100),unique=False) zip_code=db.Column(db.String(100),unique=False) profile=db.Column(db.String(200),unique=False,default='default.jpg') created_date=db.Column(db.DateTime,nullable=False,default=datetime.utcnow) is_admin=db.Column(db.Boolean,default=False) def __repr__(self): return f"Customer('{self.id}','{self.username}','{self.email}')"