Ejemplo n.º 1
0
 def query_all(limit=50):
     '''
     Return some of the records. Not all.
     :param limit:
     :return:
     '''
     return TabMember.select().limit(limit)
Ejemplo n.º 2
0
 def check_user_by_name(user_id, u_pass):
     tt = TabMember.select().where(TabMember.user_name == user_id).count()
     if tt == 0:
         return -1
     a = TabMember.get(user_name=user_id)
     if a.user_pass == tools.md5(u_pass):
         return 1
     return 0
Ejemplo n.º 3
0
    def query_by_time(recent=90):
        '''
        Return some of the records. Not all.
        '''
        time_that = int(time.time()) - recent * 24 * 3600

        return TabMember.select().where(
            TabMember.time_create > time_that).order_by(
                TabMember.time_create.desc())
Ejemplo n.º 4
0
 def check_user(user_id, u_pass):
     '''
     Checking the password by user's ID.
     '''
     user_count = TabMember.select().where(TabMember.uid == user_id).count()
     if user_count == 0:
         return -1
     the_user = TabMember.get(uid=user_id)
     if the_user.user_pass == tools.md5(u_pass):
         return 1
     return 0
Ejemplo n.º 5
0
 def check_user_by_name(user_name, u_pass):
     '''
     Checking the password by user's name.
     '''
     tt = TabMember.select().where(TabMember.user_name == user_name).count()
     if tt == 0:
         return -1
     a = TabMember.get(user_name=user_name)
     if a.user_pass == tools.md5(u_pass):
         return 1
     return 0
Ejemplo n.º 6
0
    def check_user_by_name(user_name, u_pass):
        '''
        Checking the password by user's name.
        '''
        the_query = TabMember.select().where(TabMember.user_name == user_name)
        if the_query.count() == 0:
            return -1

        the_user = the_query.get()
        if the_user.user_pass == tools.md5(u_pass):
            return 1
        return 0
Ejemplo n.º 7
0
 def query_nologin():
     '''
     Query the users who do not login recently (90 days).
     and not send email (120 days).
     time_model: num * month * hours * minite * second
     time_login: 3 * 30 * 24 * 60 * 60
     time_email: 4 * 30 * 24 * 60 * 60
     '''
     time_now = tools.timestamp()
     return TabMember.select().where((
         (time_now - TabMember.time_login) > 7776000) & (
             (time_now - TabMember.time_email) > 10368000))
Ejemplo n.º 8
0
 def check_user(user_id, u_pass):
     '''
     Checking the password by user's ID.
     :param user_id: 
     :param u_pass: 
     :return: 
     '''
     tt = TabMember.select().where(TabMember.uid == user_id).count()
     if tt == 0:
         return -1
     a = TabMember.get(uid=user_id)
     if a.user_pass == tools.md5(u_pass):
         return 1
     return 0
Ejemplo n.º 9
0
 def get_by_keyword(par2):
     return TabMember.select().where(TabMember.user_name.contains(par2))
Ejemplo n.º 10
0
    def count_of_certain():
        recs = TabMember.select()

        return recs.count()
Ejemplo n.º 11
0
 def total_number():
     '''
     Return the number of certian slug.
     '''
     return TabMember.select().count()
Ejemplo n.º 12
0
 def count_of_certain():
     '''
     '''
     # adding ``None`` to hide ``No value for argument 'database' in method call``
     return TabMember.select().count(None)
Ejemplo n.º 13
0
 def query_pager_by_time(current_page_num=1):
     '''
     Query pager
     '''
     return TabMember.select().where(TabMember.time_create).paginate(
         current_page_num, CMS_CFG['list_num'])
Ejemplo n.º 14
0
 def total_number():
     '''
     Return the number of certian slug.
     '''
     # adding ``None`` to hide ``No value for argument 'database' in method call``
     return TabMember.select().count(None)
Ejemplo n.º 15
0
 def get_by_Email(par2):
     '''
     Get Member by keyword
     '''
     return TabMember.select().where(TabMember.user_email.contains(par2))
Ejemplo n.º 16
0
 def query_nologin():
     time_now = tools.timestamp()
     # num * month * hours * minite * second
     return TabMember.select().where((
         (time_now - TabMember.time_login) > 3 * 30 * 24 * 60 * 60) & (
             (time_now - TabMember.time_email) > 4 * 30 * 24 * 60 * 60))
Ejemplo n.º 17
0
 def query_pager_by_slug(current_page_num=1):
     '''
     Query pager
     '''
     return TabMember.select().paginate(current_page_num,
                                        CMS_CFG['list_num'])