Ejemplo n.º 1
0
class User(UserJsonSerializer, UserMixin, db.Model):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), unique=True, index=True)
    email = db.Column(db.String(255), unique=True)
    mobile = db.Column(db.String(32), unique=True)
    password_hash = db.Column(db.String(128))
    active = db.Column(db.Boolean())
    last_login_at = db.Column(db.DateTime())
    current_login_at = db.Column(db.DateTime())
    last_login_ip = db.Column(db.String(100))
    current_login_ip = db.Column(db.String(100))
    login_count = db.Column(db.Integer)
    registered_at = db.Column(db.DateTime())

    @property
    def password(self):
        raise AttributeError('password is not a readable attribute')

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

    def verify_password(self, password):
        return check_password_hash(self.password_hash, password)

    def __repr__(self):
        return '<User %r>' % self.username
class Target(db.Model):
    id = db.Column(db.Integer(), primary_key=True)

    target_from = db.Column(db.Float(), nullable=True)
    target_to = db.Column(db.Float(), nullable=True)

    indicator_id = db.Column(db.Integer(),
                             db.ForeignKey('indicator.id'),
                             nullable=False)
    objective_id = db.Column(db.Integer(),
                             db.ForeignKey('objective.id', ondelete='CASCADE'),
                             nullable=False)

    username = db.Column(db.String(120), default='')
    created = db.Column(db.DateTime(), default=datetime.utcnow)
    updated = db.Column(db.DateTime(),
                        onupdate=datetime.utcnow,
                        default=datetime.utcnow)

    __table_args__ = (db.UniqueConstraint(
        'indicator_id',
        'objective_id',
        name='target_indicator_id_objective_id_key'), )

    def get_owner(self):
        return self.objective.product.product_group.name

    def __repr__(self):
        return '<Target {} | {} - {}>'.format(self.objective.product.name,
                                              self.target_from, self.target_to)
Ejemplo n.º 3
0
class Tour(db.Model):
    __tablename__ = "tours"

    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    artist = db.Column(db.String(255), nullable=False)
    description = db.Column(db.Text(), nullable=False)
    genre = db.Column(db.String(255), nullable=False)
    start_date = db.Column(db.DateTime(), nullable=False)
    end_date = db.Column(db.DateTime(), nullable=False)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey("users.id"),
                        index=True,
                        nullable=False)
    slug = db.Column(db.String(255), nullable=False, unique=True)

    def __init__(self, title, artist, description, genre, start_date, end_date,
                 user_id):
        self.title = title
        self.artist = artist
        self.description = description
        self.genre = genre
        self.start_date = start_date
        self.end_date = end_date
        self.user_id = user_id
class Product(db.Model):
    id = db.Column(db.Integer(), primary_key=True)

    name = db.Column(db.String(120), unique=True, nullable=False, index=True)
    email = db.Column(db.String(120), nullable=True)
    slug = db.Column(db.String(120), unique=True, nullable=False, index=True)

    product_group_id = db.Column(db.Integer(),
                                 db.ForeignKey('product_group.id'),
                                 nullable=False)

    objectives = db.relationship('Objective',
                                 backref=db.backref('product', lazy='joined'),
                                 lazy='dynamic',
                                 passive_deletes=True)
    indicators = db.relationship('Indicator',
                                 backref=db.backref('product', lazy='joined'),
                                 lazy='dynamic',
                                 passive_deletes=True)

    username = db.Column(db.String(120), default='')
    created = db.Column(db.DateTime(), default=datetime.utcnow)
    updated = db.Column(db.DateTime(),
                        onupdate=datetime.utcnow,
                        default=datetime.utcnow)

    def get_owner(self):
        return self.product_group.name

    def __repr__(self):
        return '<Product {}>'.format(self.name)
Ejemplo n.º 5
0
class Objective(db.Model):
    id = db.Column(db.Integer(), primary_key=True)

    title = db.Column(db.Text(), nullable=False)
    description = db.Column(db.Text(), default='')

    product_id = db.Column(db.Integer(),
                           db.ForeignKey('product.id', ondelete='CASCADE'),
                           index=True)

    targets = db.relationship('Target',
                              backref=db.backref('objective', lazy='joined'),
                              passive_deletes=True)

    username = db.Column(db.String(120), default='')
    created = db.Column(db.DateTime(), default=datetime.utcnow)
    updated = db.Column(db.DateTime(),
                        onupdate=datetime.utcnow,
                        default=datetime.utcnow)

    def get_owner(self):
        return self.product.product_group.name

    def __repr__(self):
        return '<SLO {} | {}>'.format(self.product.name, self.title)
Ejemplo n.º 6
0
class USER(UserMixin, db.Model):
    # структура данных пользователей
    __tablename__ = 'USERS'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String, nullable=False, unique=True)
    username = db.Column(db.String(255))
    password = db.Column(db.String(255))

    last_login_at = db.Column(db.DateTime())
    current_login_at = db.Column(db.DateTime())
    last_login_ip = db.Column(db.String(100))
    current_login_ip = db.Column(db.String(100))
    login_count = db.Column(db.Integer)
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())

    login = db.Column(db.String, nullable=True, unique=True)
    password_hash = db.Column(db.String, nullable=True)

    date_user_made = db.Column(db.String, nullable=True)

    family = db.Column(db.String, nullable=True)
    name = db.Column(db.String, nullable=True)
    second_name = db.Column(db.String, nullable=True)

    individual_key = db.Column(db.String, nullable=True)
    information = db.Column(db.String, nullable=True)

    rank = db.Column(db.Integer, nullable=True)

    events = db.relationship('EVENTS', backref='author', lazy='dynamic')
    role_events = db.relationship('RoleEvents',
                                  backref='RoleEventsUser',
                                  lazy='dynamic')

    roles = db.relationship('Role',
                            secondary='roles_users',
                            backref=db.backref('users', lazy='dynamic'))

    # def __init__(self, login, email, password, date_user_made):
    #     self.login = login
    #     self.email = email
    #     self.password = password
    #     self.date_user_made = date_user_made

    def __repr__(self):
        return '%d, %s, %s, %s' % (self.id, self.login, self.email,
                                   self.password_hash)

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Ejemplo n.º 7
0
class User(CURDMixin, UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)

    username = db.Column(db.String(20), nullable=False, unique=True)
    nickname = db.Column(db.String(64), server_default='无名氏')
    mobile = db.Column(db.String(128), nullable=True, unique=True)
    pw_hash = db.Column(db.String(120), nullable=False)
    created_at = db.Column(
        db.DateTime(),
        server_default=db.func.current_timestamp(),
    )
    updated_at = db.Column(
        db.DateTime(),
        onupdate=db.func.current_timestamp(),
    )
    remote_addr = db.Column(db.String(20))
    is_active = db.Column(db.Boolean())
    is_admin = db.Column(db.Boolean())

    roles = db.relationship('Role',
                            secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))

    list_columns = [
        'id', 'username', 'nickname', 'mobile', 'created_at', 'updated_at',
        'roles'
    ]

    def __repr__(self):
        return '<User %s>' % self.username

    def set_password(self, password):
        self.pw_hash = bcrypt.generate_password_hash(password, 10)

    def check_password(self, password):
        return bcrypt.check_password_hash(self.pw_hash, password)

    @classmethod
    def stats(cls):
        active_users = cache.get('active_users')
        if not active_users:
            active_users = cls.query.filter_by(is_active=True).count()
            cache.set('active_users', active_users)

        inactive_users = cache.get('inactive_users')
        if not inactive_users:
            inactive_users = cls.query.filter_by(is_active=False).count()
            cache.set('inactive_users', inactive_users)

        return {
            'all': active_users + inactive_users,
            'active': active_users,
            'inactive': inactive_users
        }
Ejemplo n.º 8
0
class Subscribe(CRUD_Model, db.Model):
	__tablename__ = 'subInfo'

	id = db.Column(db.Integer, autoincrement=True, primary_key=True) 	#before
	sub_key = db.Column(db.String(50), nullable=False)					#before
	sub_start = db.Column(db.DateTime(), default=datetime.now())		#before
	sub_end = db.Column(db.DateTime())									#after

	subscriber_id = db.Column(db.Integer)
	#subscriber_id = db.Column(db.Integer, db.ForeignKey('user.id'))		#before
	#brief = db.relationship('Jobbrief', back_populates='sub_info', lazy='dynamic')
	#user = db.relationship('User', back_populates='sub_info')

	def __repr__(self):
		return '<object Subscribe, key_word: {}>'.format(self.sub_key)
Ejemplo n.º 9
0
class CDR(db.Model):
    __tablename__ = 'cdr'
    uniqueid = db.Column(db.String(32), primary_key=True)
    calldate = db.Column(db.DateTime())
    clid = db.Column(db.String(80))
    src = db.Column(db.String(80))
    dst = db.Column(db.String(80))
    dcontext = db.Column(db.String(80))
    channel = db.Column(db.String(80))
    dstchannel = db.Column(db.String(80))
    lastapp = db.Column(db.String(80))
    lastdata = db.Column(db.String(80))
    duration = db.Column(db.String(80))
    billsec = db.Column(db.String(80))
    disposition = db.Column(db.String(80))
    amaflags = db.Column(db.String(80))
    accountcode = db.Column(db.String(20))
    userfield = db.Column(db.String(255))
    did = db.Column(db.String(50))
    recordingfile = db.Column(db.String(255))
    cnum = db.Column(db.String(80))
    cnam = db.Column(db.String(80))
    outbound_cnum = db.Column(db.String(80))
    outbound_cnam = db.Column(db.String(80))
    dst_cnam = db.Column(db.String(80))
    linkedid = db.Column(db.String(32))
    peeraccount = db.Column(db.String(80))
    sequence = db.Column(db.Integer)
Ejemplo n.º 10
0
class Portfolio(db.Model):
    __tablename__ = 'portfolio'

    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime())
    travel_product = db.Column(db.String())
    sessions_ac = db.Column(db.Integer())
    bookings_ac = db.Column(db.Integer())
    revenue_ac = db.Column(db.Integer())
    spend_ac = db.Column(db.Float())
    day_month = db.Column(db.Integer())
    day_week = db.Column(db.Integer())
    week = db.Column(db.Integer())
    month = db.Column(db.Integer())
    quarter = db.Column(db.Integer())
    year = db.Column(db.Integer())
    sessions_aa = db.Column(db.Integer())
    bookings_aa = db.Column(db.Integer())
    revenue_aa = db.Column(db.Integer())
    spend_aa = db.Column(db.Float())
    category = db.Column(db.String())
    birst_category = db.Column(db.String())
    ga_category = db.Column(db.String())

    @staticmethod
    def get_all_blogposts():
        return Portfolio.query.all()

    @staticmethod
    def get_one_blogpost(date):
        return Portfolio.query.get(date)
Ejemplo n.º 11
0
class Album(db.Model):
    __tablename__ = "albums"

    id = db.Column(db.Integer(), primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    artist = db.Column(db.String(255), nullable=False)
    description = db.Column(db.Text(), nullable=False)
    genre = db.Column(db.String(255), nullable=False)
    image = db.Column(db.Text(), nullable=False)
    release_date = db.Column(db.DateTime(), nullable=False)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey("users.id"),
                        index=True,
                        nullable=False)
    slug = db.Column(db.String(255), nullable=False, unique=True)

    def __init__(self, title, artist, description, genre, image, release_date,
                 user_id):
        self.title = title
        self.artist = artist
        self.description = description
        self.genre = genre
        self.image = image
        self.release_date = release_date
        self.user_id = user_id
Ejemplo n.º 12
0
class UserModel(db.Model, UserMixin):
    """ User Model for storing user related details """
    __tablename__ = "user"
    __repr_attrs__ = ['username']

    id = db.Column(db.Integer, primary_key=True)

    # User authentication information
    username = db.Column(db.String(50), nullable=False, unique=True)
    password = db.Column(db.String(255), nullable=False, server_default='')

    # User email information
    email = db.Column(db.String(255), nullable=False, unique=True)
    confirmed_at = db.Column(db.DateTime())

    # User information
    active = db.Column('is_active', db.Boolean(), nullable=False, default=1)
    first_name = db.Column(db.String(100), nullable=False, server_default='')
    last_name = db.Column(db.String(100), nullable=False, server_default='')

    roles = db.relationship(
        RolesModel,
        secondary=users_roles_association,
        backref="users",
        lazy="dynamic"
    )

    @classmethod
    def get(cls, uid):
        return cls.query.filter(cls.id == uid).first()

    def __str__(self):
        return "{last}, {first}".format(
            last=self.last_name, first=self.first_name
        )
Ejemplo n.º 13
0
    class User(db.Model, UserMixin):
        __tablename__ = 'user'
        id = db.Column(db.Integer, primary_key=True)
        active = db.Column('is_active',
                           db.Boolean(),
                           nullable=False,
                           server_default='1')

        # User authentication information. The collation='NOCASE' is required
        # to search case insensitively when USER_IFIND_MODE is 'nocase_collation'.
        username = db.Column(db.String(100, collation='NOCASE'),
                             nullable=False,
                             unique=True)
        password = db.Column(db.String(255), nullable=False, server_default='')
        password_hash = db.Column(db.String(255),
                                  nullable=False,
                                  server_default='')
        email_confirmed_at = db.Column(db.DateTime())

        # User information
        first_name = db.Column(db.String(100, collation='NOCASE'),
                               nullable=False,
                               server_default='')
        last_name = db.Column(db.String(100, collation='NOCASE'),
                              nullable=False,
                              server_default='')
Ejemplo n.º 14
0
class Jobbrief(CRUD_Model, db.Model):
	__tablename__ = 'brief'

	id = db.Column(db.Integer, autoincrement=True, primary_key=True)
	key_word = db.Column(db.String(50))
	job_name = db.Column(db.String(50))
	job_location = db.Column(db.String(20))
	job_salary_low = db.Column(db.Integer)
	job_salary_high= db.Column(db.Integer)
	job_exp = db.Column(db.Integer)
	job_edu = db.Column(db.String(20))
	job_quantity = db.Column(db.String(20))
	job_time = db.Column(db.DateTime())
	job_other_require = db.Column(db.String(50))
	job_labels = db.Column(db.Text())
	#company = db.Column(db.String(50))

	company_id = db.Column(db.Integer)#######################
	subscribe_id = db.Column(db.Integer)#################
	'''
	company_id = db.Column(db.Integer, db.ForeignKey('company.id'))
	#下面这一个,在实际存储中,应当注意,在订阅中需要,非订阅中不需要, 每次对结果的存贮都需要判断
	subscribe_id = db.Column(db.Integer, db.ForeignKey('subInfo.id')) 
	
	job_link = db.relationship('Jobsite', back_populates='brief', lazy='dynamic')
	company = db.relationship('Company', back_populates='job', lazy=True)
	detail = db.relationship('Jobdetail', back_populates='abstract', lazy='dynamic')
	sub_info = db.relationship('Subscribe', back_populates='brief')
	'''
	def __repr__(self):
		return '<object Jobbrief, id: {}, key_word: {}>'.format(self.id, self.key_word)
Ejemplo n.º 15
0
class IndicatorValue(db.Model):
    __tablename__ = 'indicatorvalue'

    timestamp = db.Column(db.DateTime(), nullable=False)
    value = db.Column(db.Numeric(), nullable=False)

    indicator_id = db.Column(db.Integer(),
                             db.ForeignKey('indicator.id', ondelete='CASCADE'),
                             nullable=False,
                             index=True)

    __table_args__ = (db.PrimaryKeyConstraint(
        'timestamp',
        'indicator_id',
        name='indicatorvalue_timestamp_indicator_id_pkey'), )

    def as_dict(self):
        return {
            'timestamp': self.timestamp,
            'value': self.value,
            'indicator_id': self.indicator_id
        }

    def update_dict(self):
        return {'value': self.value}

    def __repr__(self):
        return '<SLI value {} | {}: {}>'.format(self.indicator.name,
                                                self.timestamp, self.value)
Ejemplo n.º 16
0
class Post(PaginatedAPIMixin, db.Model):
    """文章模型类"""
    __tablename__ = 'posts'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(255))
    summary = db.Column(db.Text)
    body = db.Column(db.Text)
    timestamp = db.Column(db.DateTime(), index=True, default=datetime.utcnow)
    views = db.Column(db.Integer, default=0)
    author_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    comments = db.relationship('Comment',
                               backref='post',
                               lazy='dynamic',
                               cascade='all,delete-orphan')
    # 喜欢博客的人和被喜欢的文章是多对多的关系,一个人可以喜欢多个文章,一个文章可以被多个人喜欢
    likers = db.relationship('User',
                             secondary=posts_likes,
                             backref=db.backref('liked_posts', lazy='dynamic'),
                             lazy="dynamic")

    def __repr__(self):
        return "<POST{}>".format(self.title)

    def from_dict(self, data: dict):
        """接收表单数据构建post对象并返回"""
        for filed in ["title", "body", "summary"]:
            if filed in data:
                setattr(self, filed, data[filed])

    def to_dict(self):

        data = {
            'id': self.id,
            'title': self.title,
            'body': self.body,
            'summary': self.summary,
            'author_id': self.author_id,
            '_links': {
                'self': url_for('api.get_post', id=self.id),
                'author_url': url_for('api.get_users', id=self.author_id)
            }
        }

        return data

    def is_liked_by(self, user):
        """是否收藏过文章"""
        return user in self.likers

    def liked_by(self, user):
        """收藏文章"""
        if not self.is_liked_by(user):
            self.likers.append(user)

    def unliked_by(self, user):
        """取消收藏文章"""
        if self.is_liked_by(user):
            self.likers.remove(user)
Ejemplo n.º 17
0
class Indicator(db.Model):
    id = db.Column(db.Integer(), primary_key=True)

    name = db.Column(db.String(120), nullable=False, index=True)
    source = db.Column(db.JSON(), nullable=False)
    unit = db.Column(db.String(20), nullable=False, default='')
    aggregation = db.Column(db.String(80), default='average')
    is_deleted = db.Column(db.Boolean(),
                           default=False,
                           index=True,
                           server_default=false())

    product_id = db.Column(db.Integer(),
                           db.ForeignKey('product.id'),
                           nullable=False,
                           index=True)

    slug = db.Column(db.String(120), nullable=False, index=True)

    targets = db.relationship('Target',
                              backref=db.backref('indicator', lazy='joined'),
                              lazy='dynamic')
    values = db.relationship('IndicatorValue',
                             backref='indicator',
                             lazy='dynamic',
                             passive_deletes=True)

    username = db.Column(db.String(120), default='')
    created = db.Column(db.DateTime(), default=datetime.utcnow)
    updated = db.Column(db.DateTime(),
                        onupdate=datetime.utcnow,
                        default=datetime.utcnow)

    __table_args__ = (db.UniqueConstraint(
        'name',
        'product_id',
        'is_deleted',
        name='indicator_name_product_id_key'), )

    def get_owner(self):
        return self.product.product_group.name

    def __repr__(self):
        return '<SLI {} | {} | {}>'.format(self.product.name, self.name,
                                           self.source)
Ejemplo n.º 18
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())
    roles = db.relationship('Role',
                            secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))
Ejemplo n.º 19
0
class Basket(db.Model):
    "A basket of foos."

    __tablename__ = 'basket'

    id = db.Column('id', db.Integer(), primary_key=True)
    name = db.Column('name', db.Text(), nullable=False)
    created_ts = db.Column(db.DateTime(timezone=True),
                           server_default=text('NOW()'))
    foos = db.relationship('Foo', backref='basket', lazy='dynamic')
Ejemplo n.º 20
0
class Comment(db.Model):
    __tablename__ = "comments"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    text = db.Column(db.Text())
    date = db.Column(db.DateTime())
    post_id = db.Column(db.Integer, db.ForeignKey('posts.id'))

    def __repr__(self):
        return "<Model Comment {}>".format(self.name)
Ejemplo n.º 21
0
class User(db.Model, UserMixin):
    __tablename__ = 's_user'
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(50), unique=True)
    username = db.Column(db.String(50))
    password = db.Column(db.String(255))
    last_login_at = db.Column(db.DateTime())
    current_login_at = db.Column(db.DateTime())
    last_login_ip = db.Column(db.String(100))
    current_login_ip = db.Column(db.String(100))
    login_count = db.Column(db.Integer)
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())
    roles = db.relationship('Role',
                            secondary='s_roles_users',
                            backref=db.backref('users', lazy='dynamic'))

    def __repr__(self):
        return self.username
Ejemplo n.º 22
0
class Suggestions(db.Model):
    id = db.Column(db.Integer,primary_key=True)
    edit_triplet = db.Column(db.String(256),index=True,unique=True)
    date = db.Column(db.DateTime(timezone=True),default=func.now())
    votes = db.Column(db.Integer,default=1)

    def __repr__(self):
        return "Suggestion : %r" % self.edit_triplet
    def __init__(self,edit_triplet):
        self.edit_triplet = edit_triplet
Ejemplo n.º 23
0
class Ip_pool(CRUD_Model, db.Model):
	__tablename__ = 'ips'

	id = db.Column(db.Integer, autoincrement=True, primary_key=True)
	ip = db.Column(db.String(20), nullable=False, unique=True)
	port = db.Column(db.String(10), nullable=False)	
	scheme = db.Column(db.String(10), nullable=False)
	#available = db.Column(db.Boolean, default=True)
	qc_status = db.Column(db.Boolean, default=True)
	lg_status = db.Column(db.Boolean, default=True)
	lp_status = db.Column(db.Boolean, default=True)
	security = db.Column(db.String(20), nullable=False)
	store_time = db.Column(db.DateTime(), default=datetime.now())
	qc_expire_time = db.Column(db.DateTime())
	lg_expire_time = db.Column(db.DateTime())
	lp_expire_time = db.Column(db.DateTime())

	def __repr__(self):
		return '<object Ip_pool, id: {}>'.format(self.id)
Ejemplo n.º 24
0
class Event(db.Model):

    __tablename__ = 'events'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(60))
    description = db.Column(db.String(200))
    event_date = db.Column(db.String(20))
    date = db.Column(db.DateTime())
    
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    def __repr__(self):

        return '<Event: {0}>'.format(self.name)
    
    @staticmethod
    def read_event(_id):
        
        event = Event.query.filter_by(id=_id).first()
        
        return event

    @staticmethod
    def create(name, description, event_date, date):
        
        event = Event(name=name, description=description, event_date=event_date, date=date)
        
        db.session.add(event)
        db.session.commit()
        
        return event
        
    @staticmethod
    def update(_id, values):

        values["date"] = datetime.datetime.now()
    
        event = Event.query.filter_by(id=_id).update(values)
        db.session.commit()
    
    @staticmethod
    def delete(self, _id):
    
        todo = ToDo.query.filter_by(id=_id).first()
        db.session.delete(todo)
        db.session.commit()

    def to_dict(self):

        result = self.__dict__
        result["date"] = result["date"].isoformat()
        del result['_sa_instance_state']

        return result
Ejemplo n.º 25
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer(), primary_key=True)
    username = db.Column(db.String(50), unique=True)
    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())
    roles = db.relationship('Role', secondary=roles_users,
                            backref=db.backref('users', lazy='dynamic'))
    # 如果你配置了SECURITY_CONFIRMABLE=True,那么你的User模型需要添加以下字段:
    confirmed_at = db.Column(db.DateTime())
    # 如果你配置了SECURITY_TRACKABLE=True,那么你的User模型需要添加以下字段:
    last_login_at = db.Column(db.DateTime())
    current_login_at = db.Column(db.DateTime())
    last_login_ip = db.Column(db.String(50))
    current_login_ip = db.Column(db.String(50))
    login_count = db.Column(db.BigInteger())

    def __repr__(self):
        return "<User %s--%s>" % self.name
Ejemplo n.º 26
0
class Movie(db.Model):
    __tablename__ = 'movie'
    id = db.Column(db.Integer, primary_key=True)
    img = db.Column(db.Text())
    name = db.Column(db.String(64))
    actor = db.Column(db.Text())
    up_time = db.Column(db.DateTime())
    score = db.Column(db.Float())

    def __repr__(self):
        return '<User %r>' % self.name
Ejemplo n.º 27
0
class Assessment(CRUD_Model, db.Model):
	__tablename__ = 'assess'

	id = db.Column(db.Integer, autoincrement=True, primary_key=True)
	key_word = db.Column(db.String(50))
	count = db.Column(db.Integer)
	average_salary = db.Column(db.Integer)
	updated_time = db.Column(db.DateTime())

	def __repr__(self):
		return '<object Assessment, key_word: {}>'.format(self.key_word)
Ejemplo n.º 28
0
class Foo(db.Model):
    "A foo."

    __tablename__ = 'foo'

    id = db.Column('id', db.Integer(), primary_key=True)
    bar = db.Column('bar', db.Integer(), nullable=False)
    baz = db.Column('baz', db.Text(), nullable=False)
    created_ts = db.Column(db.DateTime(timezone=True),
                           server_default=text('NOW()'))
    basket_id = db.Column(db.Integer, db.ForeignKey('basket.id'))
Ejemplo n.º 29
0
class GoogleTrends(db.Model):
    __tablename__ = "GoogleTrends"

    id = db.Column(db.Integer,
                   unique=True,
                   primary_key=True,
                   autoincrement=True)
    timestamp = db.Column(db.DateTime(timezone=True))
    search_term = db.Column(db.String(64))
    week_start_date = db.Column(db.Date)
    trend_index = db.Column(db.Numeric)
Ejemplo n.º 30
0
class MessageModel(BaseModel):
    __tablename__ = 'messages'   
    sender_id = db.Column(db.Integer, ForeignKey(UserModel.id), primary_key=True)  # type:int
    receiver_id = db.Column(db.Integer, ForeignKey(UserModel.id), primary_key=True)  # type:int
    message_ciphertext = db.Column(db.String()) # type:str
    timestamp = db.Column(db.DateTime(), primary_key=True) # type:datetime.datetime

    def to_dict(self):
        return {'sender_id': self.sender_id,
                'receiver_id': self.receiver_id,
                'message_ciphertext': self.message_ciphertext,
                'timestamp': str_from_date_time(self.timestamp)}