示例#1
0
class DailyRankV3(Model):
    """仅用于读取计算日营收评级相关数据"""
    __table__ = "daily_rank_v3"
    id = IntegerField(ddl='int(11)', comment=u'id', primary_key=True)

    statistic_date = DateField(comment=u'哪一日的营收', key=True)
    user_id = IntegerField(default=None, nullable=False, ddl='int(11)', comment=u'风先生id', key=True)
    org_num = StringField(default=None, nullable=False, ddl='varchar(65)', comment=u'所属中队架构编号')
    number_of_middle_teammates = IntegerField(ddl='smallint(6)', comment=u'该日所属中队成员数')
示例#2
0
class Movie(Model):
    __table__ = 'movies'

    id = StringField(primary_key=True, default=next_id, ddl='varchar(50)')
    name = StringField(ddl='varchar(50)')
    summary = TextField()
    score = FloatField()
    num_review = IntegerField()
    duration = IntegerField()
    style = StringField(ddl='varchar(50)')
    date = StringField(ddl='varchar(50)')
    director = StringField(ddl='varchar(50)')
    writer = StringField(ddl='varchar(50)')
    star = StringField(ddl='varchar(200)')
    created_at = FloatField(updatable=False, default=time.time)
示例#3
0
文件: data.py 项目: hazelor/COO_new
class Data_Table_Map(Model):
    id = StringField(primary_key=True, ddl='varchar(32)', default=next_id)
    start_time = FloatField(ddl='double', default=time.time)
    end_time = FloatField(ddl='double')
    index = IntegerField()

    @classmethod
    def get_last_table_index(cls):
        if cls.count_all() == 0:
            return 0
        else:
            data_table = cls.find_first('order by start_time desc')
            if data_table:
                return data_table.index
            else:
                return 0

    @classmethod
    def add_table(cls, index):
        r = redis.Redis()
        dt = Data()
        dt.create_table(sub_name=str(index))
        r.set("last_data_table_index", index)
        new_table = Data_Table_Map()
        new_table.end_time = time.time()
        new_table.index = index
        new_table.insert()

    @classmethod
    def get_tables(cls, start_time, end_time):
        return cls.find_by('where start_time<? and end_time>?', end_time,
                           start_time)
示例#4
0
class Comment(Model):
    __table__ = 'comments'

    id = IntegerField(primary_key=True, auto_increment=True)
    blog_id = StringField(updatable=False, size=50)
    user_id = StringField(updatable=False, size=50)
    user_name = StringField(50)
    user_image = StringField(500)
    content = TextField()
    created_at = TimestampField(updatable=False, default=time.time)
示例#5
0
class question(Model):
    """
    """
    __table__ = 'question'

    questionID = IntegerField(primary_key=True, ddl='integer', updatable=False)
    title = TextField()
    option = TextField()
    type = IntegerField(default=0, ddl='integer')
    createtime = TimeField(updatable=False,
                           default=time.strftime("%Y-%m-%d %H:%M:%S",
                                                 time.localtime()))
    altertime = TimeField(updatable=False,
                          default=time.strftime("%Y-%m-%d %H:%M:%S",
                                                time.localtime()))
    score = IntegerField(ddl='integer')
    right_ans = StringField(ddl='varchar(100)')
    difficult = IntegerField(ddl='integer')
    part = IntegerField(ddl='integer')
示例#6
0
class students(Model):
    """docstring for students"""
    __table__ = 'students'

    studentID = StringField(primary_key=True,
                            ddl='varchar(10)',
                            updatable=False)
    studentName = StringField(ddl='varchar(40)', default='张三')
    studentDepartment = StringField(ddl='varchar(50)', default='0048')
    home = StringField(ddl='varchar(50)', default='中国')
    # grade = IntegerField(ddl='bit', default=1)
    # classes = IntegerField(ddl='bit', default=1)
    sex = IntegerField(ddl='integer', default=0)
    score_part2 = IntegerField(ddl='integer', default=0)
    score_part3 = IntegerField(ddl='integer', default=0)
    finished = BooleanField(default=False)
    logintime = TimeField(updatable=False,
                          default=time.strftime("%Y-%m-%d %H:%M:%S",
                                                time.localtime()))
示例#7
0
class Review(Model):
    __table__ = 'reviews'

    id = StringField(primary_key=True, default=next_id, ddl='varchar(50)')
    movie_id = StringField(updatable=False, ddl='varchar(50)')
    user_id = StringField(updatable=False, ddl='varchar(50)')
    user_name = StringField(ddl='varchar(50)')
    score = IntegerField()
    content = TextField()
    created_at = FloatField(default=time.time)
示例#8
0
class User(Model):
    __table__ = 'users'

    id = IntegerField(primary_key=True, auto_increment=True)
    name = StringField(size=50)
    email = StringField(updatable=False, size=50)
    password = StringField(50, default='123456')
    admin = BooleanField(default=False)
    image = StringField(500, default='')
    created_at = TimestampField(updatable=False, default=time.time)
示例#9
0
class Attachment(Model):
    u'附件'
    __table__ = 'attachments'

    id = StringField(primary_key=True, default=next_id, ddl='varchar(50)')
    user_id = StringField(updatable=False, ddl='varchar(50)')
    local_name = StringField(ddl='varchar(50)')
    file_name = StringField(ddl='varchar(500)')
    file_type = StringField(ddl='varchar(200)')
    file_size = IntegerField()
    created_at = FloatField(updatable=False, default=time.time)
示例#10
0
class log(Model):
    """"""
    __table__ = 'log'

    id = IntegerField(ddl='integer',
                      primary_key=True,
                      auto_incre=True,
                      updatable=False)
    time = TimeField(updatable=False,
                     default=time.strftime("%Y-%m-%d %H:%M:%S",
                                           time.localtime()))
    details = TextField()
示例#11
0
class Url(Model):
    __table__='activeurl'

    id = StringField(updatable=False,primary_key=True, default=next_id, ddl='varchar(50)')
    user_id = StringField(updatable=False, ddl='varchar(50)')
    url = StringField(ddl='varchar(255)')
    frequent = IntegerField(updatable=False, default=30)
    top_num = IntegerField(updatable=False, default=1)
    send_mail_num = IntegerField(updatable=True, default=0)
    total_record_num = IntegerField(updatable=True, default=0)
    get_page_num = IntegerField(updatable=True, default=0)
    parse_page_num = IntegerField(updatable=True, default=0)
    new_record_num = IntegerField(updatable=True, default=0)
    record_contents = TextField()
    last_send_time = StringField()
    create_time= StringField(default =now_datetime)
    status = IntegerField(updatable=True, default=1)
    fun_index = IntegerField(updatable=True, default=0)
    summary = StringField(ddl='varchar(255)')
    reason = StringField(ddl='varchar(1024)',default = r'一切正常')
    last_time = IntegerField(updatable=True, default=0)
示例#12
0
class Device(Model):
    __table__ = 'device'

    id = StringField(primary_key=True, ddl='varchar(32)', default=next_id)
    location = StringField(ddl='varchar(50)')
    mac = StringField(ddl='varchar(50)')
    dev_type = StringField(ddl='varchar(50)')
    lat = FloatField(ddl='double')
    lon = FloatField(ddl='double')
    status = IntegerField()  #0 good; 1 inactive; 2 warning; 3 error
    created_at = FloatField(updatable=False, default=time.time)

    def create(self):
        #print self.location,self.mac
        try:
            if self.location and self.mac:
                self.insert()
                return self.id
            else:
                return None
        except Exception as e:
            return None

    def creator(self, device_id):
        return self.find_first('where id = ?', device_id)

    def update_info(self):
        try:
            if self.location and self.mac:
                dev_info = self.find_first('where mac = ?', self.mac)
                dev_info.location = self.location
                dev_info.update()
                return dev_info.id
            else:
                return None
        except:
            return None

    def get_device_by_mac(self, mac):
        #mac_wrapped = get_md5(mac)

        device = self.find_first('where mac = ?', mac)
        if device:
            return device
        return None
示例#13
0
class Unactiveurl(Model):
    __table__='unactiveurl'

    id = StringField(updatable=False,primary_key=True, default=next_id, ddl='varchar(50)')
    user_id = StringField(updatable=False, ddl='varchar(50)')
    url = StringField(ddl='varchar(255)')
    frequent = IntegerField(updatable=False, default=30)
    top_num = IntegerField(updatable=False, default=1)
    send_mail_num = IntegerField(updatable=True, default=0)
    total_record_num = IntegerField(updatable=True, default=0)
    get_page_num = IntegerField(updatable=True, default=0)
    parse_page_num = IntegerField(updatable=True, default=0)
    new_record_num = IntegerField(updatable=True, default=0)
    record_contents = TextField()
    last_send_time = StringField(default =now_datetime)
    create_time= StringField(default =now_datetime)
示例#14
0
class Position_Image(Model):
    __table__ = "position_image"

    id = StringField(primary_key=True, ddl='varchar(32)', default=next_id)
    device_id = StringField(ddl='varchar(32)')
    position = IntegerField()
    object_name = StringField(ddl='varchar(50)')
    duration = StringField(ddl='varchar(50)')

    def validate(self):
        dev = Device()
        if not dev.creator(self.device_id):
            return False
        if self.duration <= 0:
            return False
        return True

    def create(self):
        if not self.validate():
            return
        pos = self.find_first('where device_id = ? and position = ?',
                              self.device_id, self.position)

        if pos:
            self.id = pos.id
            self.update()
        else:
            self.insert()
        return self.id

    def get_position_id(self, device_id, position):
        pos = self.find_first('where device_id = ? and position = ?',
                              device_id, position)
        if not pos:
            return None
        return pos.id

    def get_position_by_device_id(self, device_id):
        pos = self.find_by('where device_id = ?', device_id)

        if pos:
            return pos
        return []
示例#15
0
class student_ques(Model):
    """"""
    __table__ = 'student_ques'

    # studentID = StringField(ddl='varchar(10)',
    #     foreign_key=True,
    #     reference=('students', 'studentID'))
    # questionID = IntegerField(ddl='integer', foreign_key=True, reference=('question', 'questionID'))
    # answer = StringField(ddl='varchar(500)')
    # anstime = TimeField(ddl='DateTime', updatable=False,
    #     default=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
    # primary_key = ('studentID', 'questionID')
    studentID = StringField(ddl='varchar(10)',
                            primary_key=True,
                            updatable=False)
    questionID = IntegerField(ddl='integer', updatable=False)
    answer = StringField(ddl='varchar(500)')
    anstime = TimeField(ddl='DateTime',
                        updatable=False,
                        default=time.strftime("%Y-%m-%d %H:%M:%S",
                                              time.localtime()))
示例#16
0
class PayrollGrade(Model):
    """存储薪资等级Model,存储配送员日营收评级(可能需要实时),用于薪资结算,历史数据查询"""
    __table__ = "payroll_grade"
    id = IntegerField(ddl='int(11)', comment=u'日营收等级id', primary_key=True)

    statistic_date = DateField(comment=u'哪一日的营收', key=True)
    deliveryman_id = IntegerField(default=None, nullable=False, ddl='int(11)', comment=u'风先生id', key=True)
    grade = IntegerField(default=None, nullable=False, ddl='int(3)', comment=u'风先生当日营收评级[10,90,step=10]')

    middle_team_org_num = StringField(default=None, nullable=False, ddl='varchar(32)', comment=u'所属中队架构编号')
    delivery_fee = IntegerField(default=None, nullable=False, ddl='int(11)', comment=u'配送费(日营收), 单位为分')
    delivery_fee_goal = IntegerField(default=None, nullable=False, ddl='int(11)', comment=u'配送费(日营收)目标值, 单位为分')
    delivery_fee_rank = IntegerField(default=None, nullable=True, ddl='int(3)', comment=u'配送费(日营收)在所属中队中的排名')

    create_time = DateTimeField(key=True, auto_now_add=True)
    update_time = DateTimeField(auto_now=True)
示例#17
0
class User(Model):
    __table__ = 'users'
    id = IntegerField(primary_key=True)
    name = StringField()
示例#18
0
class User(Model):
    __table__ = 'user'

    id = StringField(primary_key=True, ddl='varchar(32)', default=next_id)
    email = StringField(updatable=False, ddl='varchar(50)')
    password = StringField(ddl='varchar(50)')
    permission = IntegerField()
    name = StringField(ddl='varchar(50)')
    created_at = FloatField(updatable=False, default=time.time)

    vali_email = validators.Email(not_empty=True,
                                  strip=True,
                                  messages={
                                      'noAt': u'这可不是一个正常的邮箱',
                                      'empty': u'邮箱不能爲空'
                                  })
    vali_name = formencode.All(
        validators.String(not_empty=True,
                          strip=True,
                          min=4,
                          max=24,
                          messages={
                              'empty': u'用户名不能为空',
                              'tooLong': u'这么长的用户名没有必要吧',
                              'tooShort': u'用户名长度不能少于4'
                          }),
        validators.PlainText(messages={'invalid': u'用户名只能包含数字,字母和下划线'}))
    vali_password = validators.String(not_empty=True,
                                      messages={'empty': u'忘记设置密码了'})
    vali_items = {
        'email': vali_email,
        'name': vali_name,
        'password': vali_password
    }

    def validate(self):
        self.errors = {}
        for k, vali in self.vali_items.items():
            try:
                vali.to_python(self[k])
            except formencode.Invalid as e:
                self.errors[k] = e

        if self.errors:
            return False
        return True

    def create(self):
        self.created_at = time.time()
        if not self.validate():
            return
        if User.find_first('where email = ?', self.email):
            self.errors = {'email': u'此email已被占用'}
            return
        if User.find_first('where name = ?', self.name):
            self.errors = {'name': u'此用戶名已被注冊'}
            return
        if not self.password_confirm:
            self.errors = {'password_confirm': u'确认密码不能为空'}
            return
        if self.password != self.password_confirm:
            self.errors = {'password': u'兩次密碼輸入不一致'}
            return
        self.password = hash_password(self.password)
        self.insert()
        return self.id

    def change_password(self, origin_password, password, password_confirm):
        if not origin_password:
            self.errors['origin_password'] = u'当前密码不能为空'

        if not password:
            self.errors['password'] = u'密码不能为空'

        if not password_confirm:
            self.errors['password_confirm'] = u'确认密码不能为空'

        if password != password_confirm:
            self.errors['password_confirm'] = u'两次密码不一致'

        if self.errors:
            return False

        self.password = hash_password(self.password)

        self.update()