def show_more(context, label=None, loading=settings.LOADING):
    """Show the link to get the next page in a Twitter-like pagination.

    Usage::

        {% show_more %}

    Alternatively you can override the label passed to the default template::

        {% show_more "even more" %}

    You can override the loading text too::

        {% show_more "even more" "working" %}

    Must be called after ``{% paginate objects %}``.
    """
    # This template tag could raise a PaginationError: you have to call
    # *paginate* or *lazy_paginate* before including the showmore template.
    data = utils.get_data_from_context(context)
    page = data['page']
    # show the template only if there is a next page
    if page.has_next():
        request = context['request']
        page_number = page.next_page_number()

        return _render_show_more(data, label, loading, page_number, request)

    # No next page, nothing to see.
    return {}
def show_more(context, label=None, loading=settings.LOADING):
    """Show the link to get the next page in a Twitter-like pagination.

    Usage::

        {% show_more %}

    Alternatively you can override the label passed to the default template::

        {% show_more "even more" %}

    You can override the loading text too::

        {% show_more "even more" "working" %}

    Must be called after ``{% paginate objects %}``.
    """
    # This template tag could raise a PaginationError: you have to call
    # *paginate* or *lazy_paginate* before including the showmore template.
    data = utils.get_data_from_context(context)
    page = data['page']
    querystring_key = data['querystring_key']
    request = context['request']

    page_info = {}
    # show the template only if there is a next page
    if page.has_next():
        page_number = page.next_page_number()

        # Generate the querystring.
        querystring = utils.get_querystring_for_page(
            request, page_number, querystring_key,
            default_number=data['default_number'])

        page_info.update({
            'label': label,
            'loading': loading,
            'path': iri_to_uri(data['override_path'] or request.path),
            'querystring': querystring,
            'querystring_key': querystring_key,
            'request': request,
        })

        context['next_querystring'] = querystring

    if page.has_previous():
        page_number = page.previous_page_number()
        querystring = utils.get_querystring_for_page(
            request, page_number, querystring_key,
            default_number=data['default_number'])

        context['previous_querystring'] = querystring

    # No next page, nothing to see.
    return page_info
 def render(self, context):
     # This template tag could raise a PaginationError: you have to call
     # *paginate* or *lazy_paginate* before including the getpages template.
     data = utils.get_data_from_context(context)
     # Return the string representation of the sequence of pages.
     pages = models.PageList(
         context['request'],
         data['page'],
         data['querystring_key'],
         default_number=data['default_number'],
         override_path=data['override_path'],
     )
     return utils.text(pages)
 def render(self, context):
     # This template tag could raise a PaginationError: you have to call
     # *paginate* or *lazy_paginate* before including the getpages template.
     data = utils.get_data_from_context(context)
     # Add the PageList instance to the context.
     context[self.var_name] = models.PageList(
         context['request'],
         data['page'],
         data['querystring_key'],
         default_number=data['default_number'],
         override_path=data['override_path'],
     )
     return ''
 def render(self, context):
     # This template tag could raise a PaginationError: you have to call
     # *paginate* or *lazy_paginate* before including the getpages template.
     data = utils.get_data_from_context(context)
     # Return the string representation of the sequence of pages.
     pages = models.PageList(
         context['request'],
         data['page'],
         data['querystring_key'],
         default_number=data['default_number'],
         override_path=data['override_path'],
     )
     return utils.text(pages)
 def render(self, context):
     # This template tag could raise a PaginationError: you have to call
     # *paginate* or *lazy_paginate* before including the getpages template.
     data = utils.get_data_from_context(context)
     # Add the PageList instance to the context.
     context[self.var_name] = models.PageList(
         context['request'],
         data['page'],
         data['querystring_key'],
         default_number=data['default_number'],
         override_path=data['override_path'],
     )
     return ''
Beispiel #7
0
def show_more(context, label=None, loading=settings.LOADING, class_name=None):
    """Show the link to get the next page in a Twitter-like pagination.

    Usage::

        {% show_more %}

    Alternatively you can override the label passed to the default template::

        {% show_more "even more" %}

    You can override the loading text too::

        {% show_more "even more" "working" %}

    You could pass in the extra CSS style class name as a third argument

       {% show_more "even more" "working" "class_name" %}

    Must be called after ``{% paginate objects %}``.
    """
    # This template tag could raise a PaginationError: you have to call
    # *paginate* or *lazy_paginate* before including the showmore template.
    data = utils.get_data_from_context(context)
    page = data['page']
    # show the template only if there is a next page
    if page.has_next():
        request = context['request']
        page_number = page.next_page_number()
        # Generate the querystring.
        querystring_key = data['querystring_key']
        querystring = utils.get_querystring_for_page(
            request, page_number, querystring_key,
            default_number=data['default_number'])
        return {
            'label': label,
            'loading': loading,
            'class_name': class_name,
            'path': iri_to_uri(data['override_path'] or request.path),
            'querystring': querystring,
            'querystring_key': querystring_key,
            'request': request,
        }
    # No next page, nothing to see.
    return {}
def show_more_up(context, label=None, loading=settings.LOADING):
    """Show the link to get the previous page in a Twitter-like pagination.

    Usage:: same as show more

    """
    # This template tag could raise a PaginationError: you have to call
    # *paginate* or *lazy_paginate* before including the showmore template.
    data = utils.get_data_from_context(context)
    page = data['page']
    # show the template only if there is a next page
    if page.has_previous() and page.previous_page_number()>1:
        request = context['request']
        page_number = page.previous_page_number()

        return _render_show_more(data, label, loading, page_number, request)

    # No next page, nothing to see.
    return {}
Beispiel #9
0
 def test_valid_context(self):
     # Ensure the endless data is correctly retrieved from context.
     context = {'endless': 'test-data'}
     self.assertEqual('test-data', utils.get_data_from_context(context))
Beispiel #10
0
 def test_valid_context(self):
     # Ensure the endless data is correctly retrieved from context.
     context = {'endless': 'test-data'}
     self.assertEqual('test-data', utils.get_data_from_context(context))