Beispiel #1
0
 def test_paginator_6(self):
     p = Paginator(list(range(5)), 2, 1)
     self.assertEqual(
         paginate({
             'paginator': p,
             'page_obj': p.page(1)
         })['pages'], [1, 2])
Beispiel #2
0
def mobile_pagination(context):
    get_params = context['request'].GET.copy()
    if 'page' in get_params:
        del get_params['page']
    dict = paginate(context)
    dict['get_params'] = urllib.urlencode(get_params) + '&' if get_params else ''
    return dict
Beispiel #3
0
def mobile_pagination(context):
    get_params = context['request'].GET.copy()
    if 'page' in get_params:
        del get_params['page']
    dict = paginate(context)
    dict['get_params'] = urllib.urlencode(get_params) + '&' if get_params else ''
    return dict
def mobile_pagination(context):
    get_params = context["request"].GET.copy()
    if "page" in get_params:
        del get_params["page"]
    dict = paginate(context)
    dict["get_params"] = urllib.urlencode(get_params) + "&" if get_params else ""
    return dict
Beispiel #5
0
 def test_paginator_3(self):
     p = Paginator(list(range(17)), 2)
     self.assertEqual(
         paginate({
             'paginator': p,
             'page_obj': p.page(1)
         })['pages'], [1, 2, 3, 4, 5, 6, 7, 8, 9])
Beispiel #6
0
 def test_paginator_9(self):
     p = Paginator(list(range(21)), 2, 1)
     self.assertEqual(
         paginate({
             'paginator': p,
             'page_obj': p.page(1)
         })['pages'], [1, 2, 3, 4, None, 7, 8, 9, 10])
Beispiel #7
0
def dp_pagination_for(context, current_page):
    ''' Replacement for mezzanine template tag: pagination_for.
        It takes the same inputs but adapts them to use the django-pagination
        template we use everywhere else.

        current_page = instance of 'django.core.paginator.Page'
    '''
    # JIRA 617
    ret = u''

    if current_page is not None:
        context['paginator'] = current_page.paginator

        context['page_obj'] = current_page

        from pagination.templatetags.pagination_tags import paginate
        ret = paginate(context, window=3)

    return ret
Beispiel #8
0
def dp_pagination_for(context, current_page):
    ''' Replacement for mezzanine template tag: pagination_for.
        It takes the same inputs but adapts them to use the django-pagination
        template we use everywhere else.

        current_page = instance of 'django.core.paginator.Page'
    '''
    # JIRA 617
    ret = u''

    if current_page is not None:
        context['paginator'] = current_page.paginator

        context['page_obj'] = current_page

        from pagination.templatetags.pagination_tags import paginate
        ret = paginate(context, window=3)

    return ret
Beispiel #9
0
def lofi_pagination(context):
    return paginate(context)
Beispiel #10
0
 def test_paginator_9(self):
     p = Paginator(range(21), 2, 1)
     self.assertEqual(
         paginate({'paginator': p, 'page_obj': p.page(1)})['pages'],
         [1, 2, 3, 4, None, 7, 8, 9, 10]
     )
Beispiel #11
0
 def test_paginator_8(self):
     p = Paginator(range(21), 2, 1)
     pg = paginate({'paginator': p, 'page_obj': p.page(10)})
     self.assertEqual(pg['pages'], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
     self.assertEqual(pg['records']['first'], 19)
     self.assertEqual(pg['records']['last'], 21)
Beispiel #12
0
 def test_paginator_6(self):
     p = Paginator(range(5), 2, 1)
     self.assertEqual(
         paginate({'paginator': p, 'page_obj': p.page(1)})['pages'],
         [1, 2]
     )
Beispiel #13
0
 def test_paginator_5(self):
     p = Paginator(range(21), 2)
     self.assertEqual(
         paginate({'paginator': p, 'page_obj': p.page(1)})['pages'],
         [1, 2, 3, 4, None, 8, 9, 10, 11]
     )
Beispiel #14
0
 def test_paginator_3(self):
     p = Paginator(range(17), 2)
     self.assertEqual(
         paginate({'paginator': p, 'page_obj': p.page(1)})['pages'],
         [1, 2, 3, 4, 5, 6, 7, 8, 9]
     )
Beispiel #15
0
 def test_paginator_2(self):
     p = Paginator(range(15), 2)
     pg = paginate({'paginator': p, 'page_obj': p.page(8)})
     self.assertEqual(pg['pages'], [1, 2, 3, 4, 5, 6, 7, 8])
     self.assertEqual(pg['records']['first'], 15)
     self.assertEqual(pg['records']['last'], 15)
Beispiel #16
0
def lofi_pagination(context):
    return paginate(context)
Beispiel #17
0
def my_paginate(context, window=DEFAULT_WINDOW, hashtag=""):
    return paginate(context, window, hashtag)
Beispiel #18
0
 def test_paginator_7(self):
     p = Paginator(list(range(21)), 2, 1)
     pg = paginate({'paginator': p, 'page_obj': p.page(1)})
     self.assertEqual(pg['pages'], [1, 2, 3, 4, None, 7, 8, 9, 10])
     self.assertEqual(pg['records']['first'], 1)
     self.assertEqual(pg['records']['last'], 2)