Ejemplo n.º 1
0
class CinemaUser(BaseModel):
    username = db.Column(db.String(32), unique=True)
    _password = db.Column(db.String(256))
    phone = db.Column(db.String(32), unique=True)
    is_delete = db.Column(db.Boolean, default=False)
    is_verify = db.Column(db.Boolean, default=False)

    @property
    def password(self):
        raise Exception("can't access")

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

    def check_password(self, password_value):
        return check_password_hash(self._password, password_value)

    def check_permission(self, permission):

        if not self.is_verify:
            return False

        permissions = CinemaUserPermission.query.filter_by(c_user_id=self.id)
        for user_permission in permissions:
            if permission == Permissions.query.get(
                    user_permission.c_permission_id).p_name:
                return True
        return False
Ejemplo n.º 2
0
class Project(db.Model):
    """
    项目
    """
    __tablename__ = "project"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True)
    product_id = db.Column(db.Integer)
    # product_id = db.Column(db.Integer, db.ForeignKey('product.id'))
    category = db.Column(db.String(64), index=True)
    desc = db.Column(db.String(128), index=True)
    tags = db.Column(db.String(64), index=True)
    enable = db.Column(db.Boolean, default=False, index=True)
    version = db.Column(db.String(32), index=True)
    cron = db.Column(db.Text)
    setup = db.Column(db.Text)
    teardown = db.Column(db.Text)

    create_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    create_timestamp = db.Column(db.DateTime,
                                 index=True,
                                 default=datetime.now())
    update_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    update_timestamp = db.Column(db.DateTime,
                                 index=True,
                                 default=datetime.now())
Ejemplo n.º 3
0
class User(db.Model, UserMixin):
    __tablename__ = 'users'

    id = db.Column(db.Integer(), autoincrement=True, primary_key=True)
    name = db.Column(db.String(64))
    login = db.Column(db.String(64), unique=True)
    password = db.Column(db.String(255))

    is_active = db.Column(db.Boolean(), server_default=expression.text('True'), nullable=False)  # 这里使用 expression.true() 似乎不起作用

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

    def set_password(self, password):
        return pbkdf2_sha256.hash(password)

    def check_password(self, password):
        return pbkdf2_sha256.verify(password, self.password)

    def is_authenticated(self):
        return not isinstance(self, AnonymousUserMixin)

    def is_anonymous(self):
        return isinstance(self, AnonymousUserMixin)

    def get_id(self):
        return self.id

    def __repr__(self):
        return '<Model User {}>'.format(self.name)
Ejemplo n.º 4
0
class Task(db.Model):  # pylint: disable=too-few-public-methods
    """Task models"""
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    userId = db.Column(db.String(256), nullable=False)
    taskListId = db.Column(db.Integer)
    name = db.Column(db.String(256), nullable=False)
    status = db.Column(db.Integer)  # null = incomplete (0, 1)

    def toDict(self):
        """Transfer the model to dictionary"""
        task = {
            "id": self.id,
            "userId": self.userId,
            "taskListId": self.taskListId,
            "name": self.name,
            "status": self.status
        }
        return task

    def update(self, data):
        """Update tasks"""
        for key, value in data.items():
            if key == "userId":
                self.userId = value
            elif key == "taskListId":
                self.taskListId = value
            elif key == "name":
                self.name = value
            elif key == "status":
                self.status = value
Ejemplo n.º 5
0
class Area(db.Model):
    area_id = db.Column(db.Integer, primary_key=True, autoincrement=False)
    name = db.Column(db.String(100), index=True, unique=True, nullable=False)
    parent_id = db.Column(db.Integer, index=True)
    pingyin = db.Column(db.String(100), nullable=False)
    key = db.Column(db.String(10))
    is_hot = db.Column(db.Boolean, default=False)
Ejemplo n.º 6
0
class Movie(db.Model):
    __tablename__ = 'movies'
    # id
    id = db.Column(db.Integer, primary_key=True)
    # 电影中文名
    showname = db.Column(db.String(256))
    # 电影英文名
    shownameen = db.Column(db.String(256))
    # 导演
    director = db.Column(db.String(40))
    # 主演
    leadingRole = db.Column(db.String(256))
    # 类型
    type = db.Column(db.String(256))
    # 产地
    country = db.Column(db.String(40))
    # 语言
    language = db.Column(db.String(40))
    # 时长
    duration = db.Column(db.Integer)
    # 放映类型(2D/3D)
    screeningmodel = db.Column(db.String(40))
    # 上映时间
    openday = db.Column(db.Date)
    # 宣传图
    backgroundpicture = db.Column(db.String(256))
    # 标志位(0全部, 1热映, 2即将上映)
    flag = db.Column(db.String(4))
    # 是否删除
    isdelete = db.Column(db.Boolean)
Ejemplo n.º 7
0
class Cinema(db.Model):
    __tablename__ = 'cinemas'
    # id
    id = db.Column(db.Integer, primary_key=True)
    # 影院名
    name = db.Column(db.String(100))
    # 城市
    city = db.Column(db.String(100))
    # 地区
    district = db.Column(db.String(40))
    # 详细地址
    address = db.Column(db.String(256))
    # 座机
    phone = db.Column(db.String(200))
    # 评分
    score = db.Column(db.Float)
    # 放映厅数量
    hallnum = db.Column(db.Integer)
    # 服务评分
    servicecharge = db.Column(db.Float)
    # 限制
    astrict = db.Column(db.Integer)
    # 标志位
    flag = db.Column(db.Integer)
    # 是否删除
    isdelete = db.Column(db.Boolean)
Ejemplo n.º 8
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(30))
    password = db.Column(db.String(256))
    email = db.Column(db.String(256), unique=True)
    isdelete = db.Column(db.Boolean, default=False)
    isactivate = db.Column(db.Boolean, default=False)
Ejemplo n.º 9
0
class Shop(db.Model):
    sid = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True)
    price = db.Column(db.Numeric(10, 2))
    create_time = db.Column(db.DateTime, default=datetime.datetime.now())
    expiration_date = db.Column(db.String(64))
    status = db.Column(db.Integer)
Ejemplo n.º 10
0
class Message(Base):
    """
    短信表
    """
    __tablename__ = "messages"

    content = db.Column(
        db.String(255),
        nullable=False,
        comment="短信内容",
    )
    user_id = db.Column(db.Integer(), default=0, comment="短信发布者")
    username = db.Column(db.String(20), nullable=False, comment="短信发布者用户名")
    ip = db.Column(db.String(20), default="", comment="ip地址")
    published_at = db.Column(db.DateTime(), default="", comment="发布时间")
    pid = db.Column(db.Integer(), default=0, comment="所属短信id")
    label = db.Column(db.String(100), default="", comment="预留")

    @classmethod
    def _query_search(cls, query, _keyword):
        if _keyword is not None:
            keyword = '%' + str(_keyword) + '%'
            return query.filter(
                or_(
                    cls.content.like(keyword),
                    cls.username.like(keyword),
                ))
        return query
Ejemplo n.º 11
0
class Admin(db.Model):
    '''
    管理员表
    '''
    __tablename__ = 'admin'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True)  # 昵称
    pwd = db.Column(db.String(100))
    is_super = db.Column(db.SmallInteger)  #是否为超级管理员
    role_id = db.Column(db.Integer, db.ForeignKey('role.id'))  #所属角色
    add_time = db.Column(db.DateTime, index=True, default=datetime.now)
    adminlogs = db.relationship('Adminlog', backref='admin')
    oplogs = db.relationship('Oplog', backref='admin')

    def __repr__(self):
        return "<Model Admin {}>".format(self.name)

    @staticmethod
    def insert_init_admin():
        from werkzeug.security import generate_password_hash
        admin = Admin(name='admin',
                      pwd=generate_password_hash('admin'),
                      is_super=0,
                      role_id=1)
        db.session.add(admin)
        db.session.commit()
Ejemplo n.º 12
0
class Stream(db.Model):
    id = db.Column(db.Integer, auto_increment=True, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    stream_url = db.Column(db.String(255), nullable=True)
    stream_type = db.Column(db.String(255), nullable=False)
    stream_file = db.Column(db.LargeBinary, nullable=True)
    plates = db.relationship("Plate", backref="stream", lazy='dynamic')

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False, index=True)

    def __init__(self, name, stream_url, stream_type, stream_file, user_id):
        self.name = name
        self.stream_url = stream_url
        self.stream_type = stream_type
        self.stream_file = stream_file
        self.user_id = user_id
    
    def get_decoded_file(self):
        return cv2.imdecode(np.frombuffer(self.stream_file, np.uint8), -1)

    def to_json(self):
        # decoded_file = self.stream_file.decode("utf-8", "ignore") if self.stream_file != None else self.stream_file
        return {"id": self.id, "name": self.name, "stream_url": self.stream_url, "stream_type": self.stream_type, "owner": self.user_id}

    def __repr__(self):
        return '<Stream %r>' % self.id
Ejemplo n.º 13
0
class Object(db.Model):
    """
        对象库套件
    """
    __tablename__ = "object"
    id = db.Column(db.Integer, primary_key=True)
    project_id = db.Column(db.Integer)
    #project_id = db.Column(db.Integer, db.ForeignKey('project.id'))
    category = db.Column(db.String(64), index=True)
    prev = db.Column(db.Integer)  # 兄对象 id
    name = db.Column(db.String(64), index=True)
    desc = db.Column(db.String(128), index=True)
    tags = db.Column(db.String(64), index=True)
    enable = db.Column(db.Boolean, default=True, index=True)
    setup = db.Column(db.Text)
    teardown = db.Column(db.Text)

    create_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    create_timestamp = db.Column(db.DateTime,
                                 index=True,
                                 default=datetime.now())
    update_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    update_timestamp = db.Column(db.DateTime,
                                 index=True,
                                 default=datetime.now())
Ejemplo n.º 14
0
class User(db.Model):

    __tablename__ = 'user'
    id = db.Column(db.String(24), default=objectid, primary_key=True)
    disabled = db.Column(db.Boolean,
                         nullable=False,
                         default=False,
                         comment='是否停用   (1、禁用 0、正常)')
    contract_tel = db.Column(db.String(20), comment='用户电话')
    username = db.Column(db.String(20), index=True, comment='用户名)')
    password = db.Column(db.String(32), comment='密码')
    email = db.Column(db.String(60), comment='email')
    #salt = db.Column(db.String(50), comment='加密盐')
    createTime = db.Column(db.DateTime,
                           default=datetime.datetime.now,
                           comment='创建时间')
    #lastTime = db.Column(db.DateTime, comment='最后登陆时间')
    user_role = db.relationship('UserRole',
                                foreign_keys=[UserRole.user_id],
                                backref=db.backref('f_user_role',
                                                   lazy='joined'),
                                lazy='dynamic')
    #real_name = db.Column(db.String(50), comment='姓名')
    sensor_visable = db.Column(db.Boolean, default=True, comment='传感器是否可见')
    ins = db.relationship('Ins',
                          secondary=t_user_ins,
                          backref=db.backref('f_ins', lazy='dynamic'),
                          lazy='dynamic')
Ejemplo n.º 15
0
class Admin(db.Model):
    __tablename__ = "admin"
    id = db.Column(db.Integer, primary_key=True)  # 编号
    name = db.Column(db.String(100), unique=True)  # 管理员账号
    pwd = db.Column(db.String(100))  # 管理员密码
    is_super = db.Column(db.SmallInteger)  # 是否为超级管理员,0为超级管理员
    role_id = db.Column(db.Integer, db.ForeignKey('role.id'))  # 所属角色
    addtime = db.Column(db.DateTime, index=True, default=datetime.now)  # 添加时间
    adminlogs = db.relationship("Adminlog", backref='admin')  # 管理员登录日志外键关系关联
    oplogs = db.relationship("Oplog", backref='admin')  # 管理员操作日志外键关系关联

    def __repr__(self):
        return "<Admin %r>" % self.name

    @property
    def password(self):
        return self.pwd

    # 使用user.password='******'设置时存入生成的散列密码
    @password.setter
    def password(self, new_password):
        self.pwd = generate_password_hash(new_password)

    def check_pwd(self, try_password):
        return check_password_hash(self.pwd, try_password)
Ejemplo n.º 16
0
class BankCard(db.Model):
    __tablename__ = "bankcard"

    def __init__(self, name, card, user_id):
        self.name = name
        self.card = card
        self.user_id = user_id

    @classmethod
    def card_exist(cls, card, cardid=None):
        """验证卡号是否存在"""
        if cardid is None:
            return BankCard.query.filter_by(card=card).first()
        else:
            return BankCard.query.filter(BankCard.id != cardid,
                                         BankCard.card == card).first()

    @classmethod
    def id_exist(cls, id):
        """验证ID是否存在"""
        return BankCard.query.filter_by(id=id).first()

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32))  #开户行
    card = db.Column(db.String(25), unique=True)  #银行卡号
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    billflows = db.relationship('BillFlow', backref='bankcard')
    userp2ps = db.relationship('UserP2P', backref='bankcard')
Ejemplo n.º 17
0
class City(BaseModel):
    letter_id = db.Column(db.Integer, db.ForeignKey(Letter.id))
    c_id = db.Column(db.Integer, default=0)
    c_parent_id = db.Column(db.Integer, default=0)
    c_region_name = db.Column(db.String(16))
    c_city_code = db.Column(db.Integer, default=0)
    c_pinyin = db.Column(db.String(64))
Ejemplo n.º 18
0
class Cinemas(db.Model):
    # 主键
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    # 影院名称
    name = db.Column(db.String(256))
    # 城市
    city = db.Column(db.String(256))
    # 区域
    district = db.Column(db.String(256))
    # 详细地址
    address = db.Column(db.String(256))
    # 电话
    phone = db.Column(db.String(256))
    # 评分
    score = db.Column(db.Float)
    # 放映厅个数
    hallnum = db.Column(db.Integer)
    # 服务评分
    servicecharge = db.Column(db.Float)
    # 限制
    astrict = db.Column(db.Integer)
    # 标志位
    flag = db.Column(db.Integer, default=0)
    # 是否删除
    isdelete = db.Column(db.Boolean, default=False)
Ejemplo n.º 19
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(40))
    token = db.Column(db.String(256))
    # u_usergoods = db.relationship("UserGoods",backref="user",lazy=True)
    email = db.Column(db.String(100))
    passwd = db.Column(db.String(100))
    img = db.Column(db.String(256))
Ejemplo n.º 20
0
class User(db.Model, UserMixin):
    uid = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64),
                         index=True,
                         unique=True,
                         nullable=False)
    password = db.Column(db.String(64), nullable=False)
    email = db.Column(db.String(100), nullable=False)
Ejemplo n.º 21
0
class City(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    parentId = db.Column(db.Integer, default=0)
    regionName = db.Column(db.String(100))
    cityCode = db.Column(db.Integer)
    pinYin = db.Column(db.String(40))
    # 关系 【属于哪个字母下】
    c_letter = db.Column(db.Integer, db.ForeignKey(Letter.id))
Ejemplo n.º 22
0
Archivo: chart.py Proyecto: markblog/h5
class ChartComment(DictMixin, db.Model):
    __tablename__ = 'chart_comment'

    id = db.Column(db.Integer, primary_key=True)
    chart_id = db.Column(db.String(255))
    user_id = db.Column(db.Integer)
    comment = db.Column(db.String(255))
    create_time = db.Column(db.DateTime, default=datetime.datetime.utcnow())
Ejemplo n.º 23
0
Archivo: alert.py Proyecto: markblog/h5
class AlertType(db.Model, DictMixin):
    __tablename__ = 'alert_type'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    category = db.Column(db.String(64))
    subcategory = db.Column(db.String(64))
    template = db.Column(db.JSON)
    group_id = db.Column(db.Integer)
Ejemplo n.º 24
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(100), unique=True)
    password = db.Column(db.String(256))
    email = db.Column(db.String(20), unique=True)
    permissions = db.Column(db.Integer, default=1)
    icon = db.Column(db.String(256), default='atom.png')
    isactive = db.Column(db.Boolean, default=False)
    isdelte = db.Column(db.Boolean, default=False)
Ejemplo n.º 25
0
class City(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    parentId = db.Column(db.Integer)
    regionName = db.Column(db.String(40))
    cityCode = db.Column(db.Integer)
    pinYin = db.Column(db.String(40))

    # 声明关系
    letter_id = db.Column(db.Integer, db.ForeignKey(Letter.id))
Ejemplo n.º 26
0
class Role(db.Model):
    __tablename__ = 'roles'

    id = db.Column(db.Integer(), autoincrement=True, primary_key=True)
    name = db.Column(db.String(90), unique=True)
    description = db.Column(db.String(28))

    def __repr__(self):
        return '<Model Role {}>'.format(self.name)
Ejemplo n.º 27
0
class Preview(db.Model):
    __tablename__ = "preview"
    id = db.Column(db.Integer, primary_key=True)  # 编号
    title = db.Column(db.String(255), unique=True)  # 标题
    logo = db.Column(db.String(255), unique=True)  # 封面
    addtime = db.Column(db.DateTime, index=True, default=datetime.now)  # 添加时间

    def __repr__(self):
        return "<Preview %r>" % self.title
Ejemplo n.º 28
0
class User(db.Model):
    uid = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64),
                         index=True,
                         unique=True,
                         nullable=False)
    password = db.Column(db.String(100))
    email = db.Column(db.String(255), unique=True, nullable=False)
    is_active = db.Column(db.Boolean, default=False)
Ejemplo n.º 29
0
Archivo: models.py Proyecto: HTCssy/Tpp
class Hall(db.Model):
    hid = db.Column(db.Integer, primary_key=True)
    #影院的外键
    cid = db.Column(db.Integer, db.ForeignKey('cinemas.cid'))
    # 厅名
    name = db.Column(db.String(64), index=True, nullable=False, unique=True)
    # 座位
    seats = db.Column(db.String(256), default=0)
    is_delete = db.Column(db.Boolean, default=False)
Ejemplo n.º 30
0
class Auth(db.Model):
    __tablename__ = "auth"
    id = db.Column(db.Integer, primary_key=True)  # 编号
    name = db.Column(db.String(100), unique=True)  # 名称
    url = db.Column(db.String(255), unique=True)  # 地址
    addtime = db.Column(db.DateTime, index=True, default=datetime.now)  # 添加时间

    def __repr__(self):
        return "<Auth %r>" % self.name