コード例 #1
0
    def list(self, list, **kwargs):
        '''
        List the replies.
        '''

        def get_pager_idx():
            '''
            Get the pager index.
            '''
            cur_p = kwargs.get('cur_p')
            the_num = int(cur_p) if cur_p else 1
            the_num = 1 if the_num < 1 else the_num
            return the_num

        current_page_num = get_pager_idx()
        num_of_cat = MNullifyInfo.count_of_certain()
        page_num = int(num_of_cat / CMS_CFG['list_num']) + 1

        kwd = {
            'current_page': current_page_num,

        }
        self.render('static_pages/nullify/index.html',
                    postinfo=MNullifyInfo.query_pager_by_valid(current_page_num),
                    userinfo=self.userinfo,
                    cfg=CMS_CFG,
                    kwd=kwd,
                    router_post= router_post)
コード例 #2
0
 def test_query_pager_by_valid(self):
     self.add_message()
     aa = MNullifyInfo.query_pager_by_valid()
     tf = False
     for i in aa:
         if i.uid == self.post_id:
             tf = True
     assert tf
     self.tearDown()
コード例 #3
0
    def render(self, *args, **kwargs):
        current = int(args[0])

        num_of_cat = MNullifyInfo.count_of_certain()

        tmp_page_num = int(num_of_cat / config.CMS_CFG['list_num'])

        page_num = (tmp_page_num if
                    abs(tmp_page_num - num_of_cat / config.CMS_CFG['list_num'])
                    < 0.1 else tmp_page_num + 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/nullify_pager.html',
                                  kwd=kwd,
                                  pager_num=page_num,
                                  page_current=current)
コード例 #4
0
 def test_count_of_certain(self):
     aa = MNullifyInfo.count_of_certain()
     self.add_message()
     bb = MNullifyInfo.count_of_certain()
     assert bb == aa + 1
     self.tearDown()