Exemple #1
0
def tag_page(request, tag, page):
    """
    Lists documents with a certain tag.
    """
    # Check if the page is cached
    cache_key = 'tag_page:%s-%s' % (tag, page)
    cached_response = get_cached_response(request, cache_key)
    if cached_response:
        return cached_response
    # Get the data
    tag = Tag.get_by_key_name(tag)
    if not tag:
        raise Http404
    object_list = Document.all().filter('tags =', tag.key()).filter(
        "is_published =", True)
    paginator = Paginator(object_list, 10)
    # Limit it to thise page
    try:
        page = paginator.page(page)
    except (EmptyPage, InvalidPage):
        raise Http404
    # Create a response and pass it back
    context = {
        'headline': 'Documents tagged ‘%s’' % tag.title,
        'object_list': page.object_list,
        'page_number': page.number,
        'has_next': page.has_next(),
        'next_page_number': page.next_page_number(),
        'next_page_url':
        '/tag/%s/page/%s/' % (tag.title, page.next_page_number())
    }
    return direct_to_template(request, 'document_list.html', context)
def tag_page(request, tag, page):
    """
    Lists documents with a certain tag.
    """
    # Check if the page is cached
    cache_key = 'tag_page:%s-%s' % (tag, page)
    cached_response = get_cached_response(request, cache_key)
    if cached_response:
        return cached_response
    # Get the data
    tag = Tag.get_by_key_name(tag)
    if not tag:
        raise Http404
    object_list = Document.all().filter('tags =', tag.key()).filter("is_published =", True)
    paginator = Paginator(object_list, 10)
    # Limit it to thise page
    try:
        page = paginator.page(page)
    except (EmptyPage, InvalidPage):
        raise Http404
    # Create a response and pass it back
    context = {
        'headline': 'Documents tagged ‘%s’' % tag.title,
        'object_list': page.object_list,
        'page_number': page.number,
        'has_next': page.has_next(),
        'next_page_number': page.next_page_number(),
        'next_page_url': '/tag/%s/page/%s/' % (tag.title, page.next_page_number())
    }
    return direct_to_template(request, 'document_list.html', context)
Exemple #3
0
def list_tag_post(request,tag_name):
    tag = Tag.get_by_key_name(tag_name)
    if not tag:
        raise Http404  
    # tag.getPosts().order('-create_time')
    tag.post_list = tag.getPosts()
    return object_list(request, queryset=tag.post_list, allow_empty=True,
            template_name='list_tag_post.html', extra_context={'is_author': is_author(), 'is_author': is_author(), 'tag': tag},
            paginate_by=settings.POST_LIST_PAGE_SIZE)     
Exemple #4
0
def list_tag_post(request, tag_name):
    tag = Tag.get_by_key_name(tag_name)
    if not tag:
        raise Http404
    # tag.getPosts().order('-create_time')
    tag.post_list = tag.getPosts()
    return object_list(request,
                       queryset=tag.post_list,
                       allow_empty=True,
                       template_name='list_tag_post.html',
                       extra_context={
                           'is_author': is_author(),
                           'is_author': is_author(),
                           'tag': tag
                       },
                       paginate_by=settings.POST_LIST_PAGE_SIZE)