Ejemplo n.º 1
0
    def test_count_of_user(self):
        user_id = self.user_id
        b = MCollect.count_of_user(user_id)
        self.add_mess()

        a = MCollect.count_of_user(user_id)

        assert a == b + 1
        self.tearDown()
Ejemplo n.º 2
0
    def render(self, *args, **kwargs):
        user_id = args[0]
        current = int(args[1])
        # cat_slug 分类
        # current 当前页面

        the_count = MCollect.count_of_user(user_id)

        pager_count = int(the_count / config.CMS_CFG['list_num'])

        page_num = (pager_count if
                    abs(pager_count - the_count / config.CMS_CFG['list_num']) <
                    0.1 else pager_count + 1)

        kwd = {
            'page_home': False if current <= 1 else True,
            'page_end': False if current >= page_num else True,
            'page_pre': False if current <= 1 else True,
            'page_next': False if current >= page_num else True,
        }

        return self.render_string('modules/post/collect_pager.html',
                                  kwd=kwd,
                                  pager_num=page_num,
                                  page_current=current)
Ejemplo n.º 3
0
    def list(self, list, cur_p=''):
        if cur_p == '':
            current_page_num = 1
        else:
            current_page_num = int(cur_p)

        current_page_num = 1 if current_page_num < 1 else current_page_num

        num_of_cat = MCollect.count_of_user(self.userinfo.uid)
        page_num = int(num_of_cat / CMS_CFG['list_num']) + 1

        kwd = {'current_page': current_page_num}

        self.render('misc/collect/list.html',
                    recs_collect=MCollect.query_pager_by_all(
                        self.userinfo.uid, current_page_num).naive(),
                    pager=tools.gen_pager_purecss('/collect/{0}'.format(list),
                                                  page_num, current_page_num),
                    userinfo=self.userinfo,
                    cfg=CMS_CFG,
                    kwd=kwd)
    def show_list(self, the_list, cur_p=''):
        '''
        List of the user collections.
        '''

        current_page_num = int(cur_p) if cur_p else 1
        current_page_num = 1 if current_page_num < 1 else current_page_num

        num_of_cat = MCollect.count_of_user(self.userinfo.uid)
        page_num = int(num_of_cat / CMS_CFG['list_num']) + 1

        kwd = {'current_page': current_page_num}

        self.render('misc/collect/list.html',
                    recs_collect=MCollect.query_pager_by_all(
                        self.userinfo.uid, current_page_num).objects(),
                    pager=tools.gen_pager_purecss(
                        '/collect/{0}'.format(the_list), page_num,
                        current_page_num),
                    userinfo=self.userinfo,
                    cfg=CMS_CFG,
                    kwd=kwd)
Ejemplo n.º 5
0
 def test_count_of_user(self):
     user_id = self.user_id
     MCollect.count_of_user(user_id)
     assert True