Пример #1
0
def activity(request, page="1", explicit_page_request=False):
    # Make sure page parameter is an integer
    try:
        page = int(page)
    except:
        raise Http404

    # Make sure we only have one canonical first page
    if explicit_page_request and page == 1:
        return redirect('main_activity')

    # Previous URL used GET parameter 'page', so let's check
    # for that and redirect to new view if necessary
    if not explicit_page_request:
        try:
            requestNum = request.GET['page']
            if requestNum != None and requestNum.isdigit():
                return redirect('activity_paged', page=requestNum)
        except KeyError:
            pass

    activity_list = Activity.objects.published().defer("username", "author", "comments", "guid")
    paginator = InfinitePaginator(activity_list, 25)

    try:
        activities = paginator.page(page)
    except:
        raise Http404

    return render_to_response('activity.html',
                activities.create_template_context('activity_paged', 'main_activity'),
                context_instance=RequestContext(request))
Пример #2
0
def activity(request, page="1", explicit_page_request=False):
    # Make sure page parameter is an integer
    try:
        page = int(page)
    except:
        raise Http404

    # Make sure we only have one canonical first page
    if explicit_page_request and page == 1:
        return redirect('main_activity')

    # Previous URL used GET parameter 'page', so let's check
    # for that and redirect to new view if necessary
    if not explicit_page_request:
        try:
            requestNum = request.GET['page']
            if requestNum != None and requestNum.isdigit():
                return redirect('activity_paged', page=requestNum)
        except KeyError:
            pass

    activity_list = Activity.objects.published().defer("username", "author",
                                                       "comments", "guid")
    paginator = InfinitePaginator(activity_list, 25)

    try:
        activities = paginator.page(page)
    except:
        raise Http404

    return render_to_response('activity.html',
                              activities.create_template_context(
                                  'activity_paged', 'main_activity'),
                              context_instance=RequestContext(request))
Пример #3
0
def blog_entry_list(request, page=1, explicit_page_request=False):
    # Make sure page parameter is an integer.
    try:
        page = int(page)
    except ValueError:
        page = 1

    # Make sure we only have one canonical first page
    if explicit_page_request and page == 1:
        return redirect('blog_index')

    # Previous URL used GET parameter 'page', so let's check
    # for that and redirect to new view if necessary
    if not explicit_page_request:
        try:
            requestNum = request.GET['page']
            if requestNum != None and requestNum.isdigit():
                return redirect('blog_index_paged', page=requestNum)
        except KeyError:
            pass

    entry_list = Entry.objects.published_for_list()
    paginator = InfinitePaginator(entry_list, 10)
    try:
        entries = paginator.page(page)
    except:
        raise Http404

    return render_to_response('blog/entry_list.html',
                entries.create_template_context('blog_index_paged', 'blog_index'),
                context_instance=RequestContext(request))