class License(db.Model): __tablename__ = 'license' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64)) license_str = db.Column(db.String(128)) project_name = db.Column(db.String(128)) time = db.Column(db.String(28))
class Severity(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(255), nullable=False, unique=True) weight = db.Column(db.Integer, nullable=False) def __init__(self, name, weight): self.name = name self.weight = weight
class Reminder(db.Model): id = db.Column(db.Integer, primary_key=True) user = db.Column(db.String(255), nullable=False) notified = db.Column(db.Boolean, default=0) date_added = db.Column(db.DateTime, default=datetime.now) def __init__(self, user, notified): self.user = user self.notified = notified
class Category(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column( db.String(255), nullable=True, ) def __init__(self, name): self.name = name
class Comment(db.Model): __tablename__ = 'comment' id = db.Column(db.INTEGER, primary_key=True, autoincrement=True) content = db.Column(db.Text, nullable=False) user_id = db.Column(db.INTEGER, db.ForeignKey('user.id')) user = db.relationship('User', backref=db.backref('comments')) question_id = db.Column(db.INTEGER, db.ForeignKey('question.id')) question = db.relationship('Question', backref=db.backref('comments'))
class Question(db.Model): __tablename__ = 'question' id = db.Column(db.INTEGER, primary_key=True, autoincrement=True) title = db.Column(db.String(100), nullable=False) content = db.Column(db.Text, nullable=False) create_time = db.Column(db.DATETIME, default=datetime.now) author_id = db.Column(db.INTEGER, db.ForeignKey('user.id')) author = db.relationship('User', backref=db.backref('questions'))
class User(db.Model): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(255), nullable=False, unique=True) name = db.Column(db.String(255), nullable=False) branch = db.Column(db.ForeignKey("branch.id"), nullable=False) def __init__(self, email, name, branch): self.email = email self.name = name self.branch = branch
class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64)) passwd = db.Column(db.String(64)) email = db.Column(db.String(64)) time = db.Column(db.String(32)) # def __init__(self,username,passwd,email,time): # self.username = username # self.passwd = passwd # self.email = email # self.time = time # def __repr__(self): # return "{},{},{}".format(self.username,self.passwd,self.email) def hash_password(self, password): self.passwd = pwd_context.encrypt(password) def verify_password(self, password): return pwd_context.verify(password, self.passwd)
class Rootpw(db.Model): __tablename__ = 'rootpw' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64)) encode_pw = db.Column(db.String(32)) decode_pw = db.Column(db.String(32)) project_name = db.Column(db.String(128)) time = db.Column(db.String(28)) # def __init__(self,username,project_name,time): # self.username = username # self.project_name = project_name # self.time = time # # def __repr__(self): # return self.encode_pw #db.create_all() # # from sqlalchemy.orm import sessionmaker # from sqlalchemy.ext.declarative import declarative_base # Base = declarative_base() # class User(Base): # __tablename__='user' # id = Column(INTEGER(16),primary_key=True) # name = Column(String(16)) # passwd = Column(String(16)) # email = Column(String(32)) # # def hash # # engine = create_engine(db_name) # DB_Session = sessionmaker(bind=engine)
class Bike(db.Model): id = db.Column(db.Integer, primary_key=True) plate_number = db.Column(db.String(100), nullable=False, unique=True) email = db.Column(db.String(255), nullable=False) branch = db.Column(db.Integer, nullable=False) serial_number = db.Column(db.String(100), nullable=False, unique=True) date_added = db.Column(db.DateTime, default=datetime.now) def __init__(self, plate_number, email, branch, serial_number): self.plate_number = plate_number self.email = email self.branch = branch self.serial_number = serial_number
class BranchReports(db.Model): """we need to refactor db to add each branch for each of the categrory""" id = db.Column(db.Integer, primary_key=True) branch = db.Column(db.ForeignKey("branch.id"), nullable=False) severity = db.Column(db.ForeignKey('severity.id'), nullable=True) category = db.Column(db.ForeignKey("category.id"), nullable=True) comments = db.Column(db.Text) date_added = db.Column(db.DateTime, default=datetime.now) def __init__(self, branch, severity, category, comments): self.branch = branch self.severity = severity self.category = category self.comments = comments
class Branch(db.Model): id = db.Column(db.Integer, primary_key=True, unique=True) name = db.Column(db.String(255), nullable=False, unique=True) def __init__(self, name): self.name = name
class User(db.Model): __tablename__ = 'user' id = db.Column(db.INTEGER, primary_key=True, autoincrement=True) username = db.Column(db.String(50), nullable=False) password = db.Column(db.String(100), nullable=False) telephone = db.Column(db.String(11), nullable=False)