class project_vote(SurrogatePK, Model): __tablename__ = 'project_vote' u_id = Column(db.Integer,nullable=False) score = Column(db.Integer,nullable=False) comment = Column(db.String(128),nullable=True) created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow) def __init__(self, **kwargs): db.Model.__init__(self, **kwargs)
class project_iteration(SurrogatePK, Model): __tablename__ = 'project_iteration' p_id = Column(db.Integer,nullable=False) v_id = Column(db.Integer,nullable=False) week = Column(db.Integer,nullable=False) created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow) def __init__(self, **kwargs): db.Model.__init__(self, **kwargs)
class Comment(SurrogatePK, Model): __tablename__ = 'Comments' comment = Column(db.String(80), unique=False, nullable=False) post_date = Column(db.DateTime, nullable=False) def __init__(self, name, **kwargs): db.Model.__init__.(self, comment=comment, **kwargs) def __repr__(self): return '<Comment({comment})>'.format(comment=self.comment) # class Role(SurrogatePK, Model): # __tablename__ = 'roles' # name = Column(db.String(80), unique=True, nullable=False) # user_id = ReferenceCol('users', nullable=True) # user = relationship('User', backref='roles') # def __init__(self, name, **kwargs): # db.Model.__init__(self, name=name, **kwargs) # def __repr__(self): # return '<Role({name})>'.format(name=self.name) # class User(UserMixin, SurrogatePK, Model): # __tablename__ = 'users' # username = Column(db.String(80), unique=True, nullable=False) # email = Column(db.String(80), unique=True, nullable=False) # #: The hashed password # password = Column(db.String(128), nullable=True) # created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow) # first_name = Column(db.String(30), nullable=True) # last_name = Column(db.String(30), nullable=True) # active = Column(db.Boolean(), default=False) # is_admin = Column(db.Boolean(), default=False) # def __init__(self, username, email, password=None, **kwargs): # db.Model.__init__(self, username=username, email=email, **kwargs) # if password: # self.set_password(password) # else: # self.password = None # def set_password(self, password): # self.password = bcrypt.generate_password_hash(password) # def check_password(self, value): # return bcrypt.check_password_hash(self.password, value) # @property # def full_name(self): # return "{0} {1}".format(self.first_name, self.last_name) # def __repr__(self): # return '<User({username!r})>'.format(username=self.username)
class project_summary(SurrogatePK, Model): __tablename__ = 'project_summary' p_id = Column(db.Integer,nullable=False) summary_type = Column(db.Integer,nullable=False) score = Column(db.Float,nullable=True,default='0.0') created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow) def __init__(self, **kwargs): db.Model.__init__(self, **kwargs)
class User_project(SurrogatePK, Model): __tablename__ = 'user_project' # TODO : next plan # u_id = Column(db.Integer, db.ForeignKey('users.id')) # p_id = Column(db.Integer, db.ForeignKey('projects.id')) u_id = Column(db.Integer, nullable=False) p_id = Column(db.Integer, nullable=False) created_at = Column(db.DateTime, nullable=True) display_yn = Column(db.Boolean, default=True) # projects = db.relationship('Project',backref='user_project',lazy='dynamic') def __init__(self, **kwargs): db.Model.__init__(self, **kwargs) def __repr__(self): return 'todo'
class Role(SurrogatePK, Model): __tablename__ = 'roles' name = Column(db.String(80), unique=True, nullable=False) user_id = ReferenceCol('users', nullable=True) user = relationship('User', backref='roles') def __init__(self, name, **kwargs): db.Model.__init__(self, name=name, **kwargs) def __repr__(self): return '<Role({name})>'.format(name=self.name)
class Project(SurrogatePK, Model): __tablename__ = 'projects' name = Column(db.String(80), unique=False, nullable=False) start_date = Column(db.DateTime, nullable=True) end_date = Column(db.DateTime, nullable=True) description = Column(db.Text, nullable=True) created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow) created_user_id = Column(db.Integer,nullable=True) modified_at = Column(db.DateTime, nullable=True) modified_user_id = Column(db.Integer,nullable=True) display_yn = Column(db.Boolean, default=True) def __init__(self, name, **kwargs): db.Model.__init__(self, name=name, **kwargs) def __repr__(self): return '<Project({name})>'.format(name=self.name) def datetimeformat(value, format='%d-%m-%Y'): return value.strftime(format,vlaue.gmtime())
class User(UserMixin, SurrogatePK, Model): __tablename__ = 'users' username = Column(db.String(80), unique=True, nullable=False) firstname = Column(db.String(30), nullable=True) lastname = Column(db.String(30), nullable=True) email = Column(db.String(80), unique=True, nullable=False) #: The hashed password password = Column(db.String(128), nullable=True) created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow) active = Column(db.Boolean(), default=False) is_admin = Column(db.Boolean(), default=False) user_type = Column(db.Integer, default=0) # TODO : next plan # user_projects = db.relationship('User_project', backref='users',lazy='dynamic') def __init__(self, username, email, password=None, **kwargs): db.Model.__init__(self, username=username, email=email, **kwargs) if password: self.set_password(password) else: self.password = None def set_password(self, password): self.password = bcrypt.generate_password_hash(password) def check_password(self, value): return bcrypt.check_password_hash(self.password, value) def get_id(self): return unicode(self.id) def __repr__(self): return '<User({username!r})>'.format(username=self.username)