class Labels(db.Model): label_id = db.Column(db.Integer, autoincrement='auto', primary_key=True) label = db.Column(db.String(45), nullable=False) label_user_id = db.Column(db.Integer, db.ForeignKey('users.user_id'), nullable=False) def __repr__(self): return '<Label %r>' % self.label
class UserRoles(db.Model): user_role_id = db.Column(db.Integer, autoincrement='auto', primary_key=True) user_role = db.Column(db.String(45), unique=True, nullable=False) def __repr__(self): return '<User role %r>' % self.user_role
class Items(db.Model): item_id = db.Column(db.Integer, autoincrement='auto', primary_key=True) item_prod_id = db.Column(db.Integer, db.ForeignKey('products.prod_id'), nullable=False) item_user_id = db.Column(db.Integer, db.ForeignKey('users.user_id'), nullable=False) item_date_acquisition = db.Column(db.DateTime(3) , nullable=False) item_date_expiracy = db.Column(db.DateTime(3) , nullable=False) item_quantity = db.Column(db.Integer, nullable=False) item_percent_left = db.Column(db.Integer) def __repr__(self): return '<Item %r>' % self.item_id
class Products(db.Model): prod_id = db.Column(db.Integer, autoincrement='auto', primary_key=True) prod_name = db.Column(db.String(45), nullable=False) prod_info = db.Column(db.String(300)) prod_brand = db.Column(db.String(45)) prod_image_id = db.Column(db.Integer, db.ForeignKey('images.image_id')) prod_barcode_id = db.Column(db.Integer, db.ForeignKey('barcodes.barcode_id')) def __repr__(self): return '<Product %r>' % self.prod_name
class Languages(db.Model): language_id = db.Column(db.Integer, primary_key=True) language_lang = db.Column(db.String(5), unique=True, nullable=False) def __repr__(self): return '<Language %r>' % self.lang
class Users(db.Model): user_id = db.Column(db.Integer, autoincrement='auto', primary_key=True) user_email = db.Column(db.String(255), unique=True, nullable=False) user_password = db.Column(db.String(128)) user_create_datetime = db.Column(db.DateTime(3), nullable=False) user_first_name = db.Column(db.String(45)) user_last_name = db.Column(db.String(45)) user_address = db.Column(db.String(255)) user_country = db.Column(db.String(45)) user_city = db.Column(db.String(45)) user_language_id = db.Column(db.Integer, db.ForeignKey('languages.language_id'), nullable=False) user_role_id = db.Column(db.Integer, db.ForeignKey('user_roles.user_role_id')) def __repr__(self): return '<User %r>' % self.user_email def hash_password(self, password): self.user_password = pwd_context.encrypt(password) def verify_password(self, password): return pwd_context.verify(password, self.user_password)
class Barcodes(db.Model): barcode_id = db.Column(db.Integer, autoincrement='auto', primary_key=True) barcode_code = db.Column(db.String(45)) def __repr__(self): return '<Barcode %r>' % self.barcode_code
class Images(db.Model): image_id = db.Column(db.Integer, autoincrement='auto', primary_key=True) image_path = db.Column(db.String(45)) def __repr__(self): return '<Image %r>' % self.image_path