Beispiel #1
0
def new_news_items(request):
    """
    View for the new news items.

    Only responds to GET requests.
    """

    if request.user.is_authenticated() and request.user.get_profile().option_show_dead:
        querymanager = NewsItem.objects.all().order_by('-date_posted')
    else:
        querymanager = NewsItem.objects.filter(dead=False).order_by('-date_posted')

    page = get_pagenum(request)
    latest_page = get_paginator_page(querymanager, page)

    header = 'New'

    this = reverse('news.views.news_items.new_news_items')
    next = get_next_with_pages(reverse('news.views.news_items.new_news_items'), page)

    return render_to_response('news/news_item_list.html',
            {'news_item_list': latest_page.object_list,
             'paginator_page': latest_page,
             'header': header,
             'next': next,
             'this': this},
            context_instance=RequestContext(request))
Beispiel #2
0
def index(request):
    """
    View for the front page.

    Only responds to GET requests.
    """
    render_start = datetime.datetime.now()

    querymanager = get_frontpage_querymanager(request)
    page = get_pagenum(request)
    front_page = get_paginator_page(querymanager, page)

    header = 'Front Page'

    next = get_next_with_pages(reverse('news.views.news_items.index'), page)
    this = reverse('news.views.news_items.index')

    render_end = datetime.datetime.now()

    return render_to_response('news/news_item_list.html',
            {'news_item_list': front_page.object_list,
             'paginator_page': front_page,
             'header': header,
             #'render_time': render_end - render_start,
             'next': next,
             'this': this},
            context_instance=RequestContext(request))
Beispiel #3
0
def new_comments(request):
    """
    View for the new comments.

    Only responds to GETs.
    """
    querymanager = Comment.objects.filter(dead=False).order_by('-date_posted')
    page = get_pagenum(request)
    latest_page = get_paginator_page(querymanager, page)

    header = 'New Comments'

    this = reverse('news.views.comments.new_comments')
    next = get_next_with_pages(reverse('news.views.comments.new_comments'), page)

    return render_to_response('news/comment_list.html',
            {'latest_comments': latest_page.object_list,
             'paginator_page': latest_page,
             'header': header,
             'next': next,
             'this': this},
            context_instance=RequestContext(request))