Ejemplo n.º 1
0
    def create_entity2user(enti_uid, user_id, user_ip):
        '''
        create entity2user record in the database.
        '''

        TabEntity2User.create(uid=tools.get_uuid(),
                              entity_id=enti_uid,
                              user_id=user_id,
                              user_ip=user_ip,
                              timestamp=time.time())
Ejemplo n.º 2
0
    def create_entity2user(enti_uid, user_id):
        '''
        create entity2user record in the database.
        '''
        record = TabEntity2User.select().where(
            (TabEntity2User.entity_id == enti_uid)
            & (TabEntity2User.user_id == user_id))

        if record.count() > 0:
            record = record.get()
            MEntity2User.count_increate(record.uid, record.count)
        else:
            TabEntity2User.create(uid=tools.get_uuid(),
                                  entity_id=enti_uid,
                                  user_id=user_id,
                                  count=1,
                                  timestamp=time.time())
Ejemplo n.º 3
0
 def get_by_path(path):
     recs = TabEntity2User.select(
         TabEntity2User,
         TabEntity.path.alias('entity_path'),
         TabEntity.kind.alias('entity_kind'),
     ).join(TabEntity,
            on=(TabEntity2User.entity_id == TabEntity.uid)).where(
                TabEntity.path == path)
     return recs
Ejemplo n.º 4
0
    def get_all_pager(current_page_num=1):

        recs = TabEntity2User.select(
            TabEntity2User,
            TabEntity.path.alias('entity_path'),
        ).join(TabEntity, on=(TabEntity2User.entity_id == TabEntity.uid)).join(
            TabMember, on=(TabEntity2User.user_id == TabMember.uid)).order_by(
                TabEntity2User.timestamp.desc()).paginate(
                    current_page_num, CMS_CFG['list_num'])
        return recs
Ejemplo n.º 5
0
    def get_all_pager_by_username(userid, current_page_num=1):

        recs = TabEntity2User.select(
            TabEntity2User,
            TabEntity.path.alias('entity_path'),
            TabEntity.kind.alias('entity_kind'),
        ).join(TabEntity, on=(TabEntity2User.entity_id == TabEntity.uid)).join(
            TabMember, on=(TabEntity2User.user_id == TabMember.uid)).where(
                TabEntity2User.user_id == userid).order_by(
                    TabEntity2User.entity_id).paginate(current_page_num,
                                                       CMS_CFG['list_num'])
        return recs
Ejemplo n.º 6
0
 def delete_by_uid(entity_uid):
     delete = TabEntity2User.delete().where(
         TabEntity2User.entity_id == entity_uid)
     delete.execute()
Ejemplo n.º 7
0
 def total_number_by_user(userid):
     return TabEntity2User.select().where(
         TabEntity2User.user_id == userid).count()
Ejemplo n.º 8
0
 def total_number():
     '''
     用户相关的实体总数目
     '''
     return TabEntity2User.select().count()
Ejemplo n.º 9
0
 def query_all(limit=20):
     return TabEntity2User.select().limit(limit)
Ejemplo n.º 10
0
 def total_number():
     return TabEntity2User.select().count()
Ejemplo n.º 11
0
 def count_increate(rec, num):
     entry = TabEntity2User.update(timestamp=int(time.time()),
                                   count=num +
                                   1).where(TabEntity2User.uid == rec)
     entry.execute()
Ejemplo n.º 12
0
 def total_number():
     return TabEntity2User.select().distinct(
         TabEntity2User.entity_id).count()