Ejemplo n.º 1
0
    def render(self, *args, **kwargs):
        kind = args[0]
        current = int(args[1])
        # kind
        # current 当前页面

        num_of_cat = MWiki.count_of_certain_kind(kind)

        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/admin/page_pager.html',
                                  kwd=kwd,
                                  pager_num=page_num,
                                  kind=kind,
                                  page_current=current)
Ejemplo n.º 2
0
 def test_count_of_certain_kind(self):
     aa = MWiki.count_of_certain_kind('1')
     self.add_mess()
     bb = MWiki.count_of_certain_kind('1')
     assert aa + 1 <= bb
     self.tearDown()