Exemple #1
0
def get_by_tag(request, tag_id, page=1):
    """
    Gets All the Video Post by Tag.
    URL: ^tag/(?P<tag_id>\d+)/(?P<page>\d+)/([\w-]+).html$
         ^tag/(?P<tag_id>\d+)/([\w-]+).html$
    """
    variables = dict()
    max_results = 5
    previous_page = page - 1
    next_page = page + 1
    tag_id = int(tag_id)
    tag = get_object_or_404(Tag, pk=tag_id)
    variables['tag'] = tag
    videopost_list = tag.videopost_set.filter(
        enabled=True, locked=False).order_by('-publication_date')
    if videopost_list:
        videoposts_paginated = paginator_simple(videopost_list, max_results,
                                                page)
        variables['videoposts'] = videoposts_paginated
        headline = _('Showing result for: %(tag)s.') % {'tag': tag.name}
        variables['headline'] = headline
        variables['previous-page-link'] = "tag/%d/%d/%s.html" % (
            tag_id, previous_page, tag.get_slug())
        variables['next-page-link'] = "tag/%d/%d/%s.html" % (tag_id, next_page,
                                                             tag.get_slug())
    else:
        messages.info(request, _('No Results Found.'))
    t = get_template('videopost/list.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)
Exemple #2
0
def get_by_tag(request, tag_id, page=1):
    """
    Gets All the Video Post by Tag.
    URL: ^tag/(?P<tag_id>\d+)/(?P<page>\d+)/([\w-]+).html$
         ^tag/(?P<tag_id>\d+)/([\w-]+).html$
    """
    variables = dict()
    max_results = 5
    previous_page = page - 1
    next_page = page + 1
    tag_id = int(tag_id)
    tag = get_object_or_404(Tag, pk=tag_id)
    variables['tag'] = tag
    videopost_list = tag.videopost_set.filter(enabled=True, locked=False).order_by('-publication_date')
    if videopost_list:
        videoposts_paginated = paginator_simple(videopost_list, max_results, page)
        variables['videoposts'] = videoposts_paginated
        headline = _('Showing result for: %(tag)s.') % {'tag': tag.name}
        variables['headline'] = headline                 
        variables['previous-page-link'] = "tag/%d/%d/%s.html" % (tag_id, previous_page, tag.get_slug())
        variables['next-page-link'] = "tag/%d/%d/%s.html" % (tag_id, next_page, tag.get_slug())
    else:
        messages.info(request, _('No Results Found.'))
    t = get_template('videopost/list.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)
Exemple #3
0
def get_by_date(request, page, year, month=None, day=None):
    """
    Gets All the Video Post by Date.
    URL: ^date/(?P<page>\d+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$
         ^date/(?P<page>\d+)/(?P<year>\d{4})/(?P<month>\d{2})/$
         ^date/(?P<page>\d+)/(?P<year>\d{4})/$
    """
    variables = dict()
    page = int(page)
    previous_page = page - 1
    next_page = page + 1
    max_results = 5
    if year.isdigit():
        year = int(year)
    else:
        return HttpResponse(status=400)
    headline = _('Showing result for %(year)s.') % {'year': year}
    previous_page_link = "date/%d/%d/" % (previous_page, year)
    next_page_link = "date/%d/%d/" % (next_page, year)
    videopost_list = VideoPost.objects.filter(enabled=True, locked=False)
    videopost_list = videopost_list.filter(
        publication_date__year=year).order_by('-publication_date')
    if month and month.isdigit():
        month = int(month)
        month_name = get_month_name(month)
        videopost_list = videopost_list.filter(publication_date__month=month)
        previous_page_link = previous_page_link + str(month) + "/"
        next_page_link = next_page_link + str(month) + "/"
        headline = _('Showing result for: %(month)s %(year)d.') % {
            'month': month_name,
            'year': year
        }
        if day and day.isdigit():
            day = int(day)
            day_name = get_day_name(day)
            videopost_list = videopost_list.filter(publication_date__day=day)
            previous_page_link = previous_page_link + str(day) + "/"
            next_page_link = next_page_link + str(day) + "/"
            headline = _('Showing result for: %(day)s %(month)s %(year)d.') % {
                'day': day_name,
                'month': month_name,
                'year': year
            }
    if videopost_list:
        videoposts_paginated = paginator_simple(videopost_list, max_results,
                                                page)
        variables['videoposts'] = videoposts_paginated
        variables['headline'] = headline
        variables['previous-page-link'] = "%d/" % previous_page
        variables['next-page-link'] = "%d/" % next_page
    else:
        messages.info(request, _('No Results Found.'))
    t = get_template('videopost/list.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)
Exemple #4
0
def get_by_date(request, page, year, month=None, day=None):
    """
    Gets All the Video Post by Date.
    URL: ^date/(?P<page>\d+)/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$
         ^date/(?P<page>\d+)/(?P<year>\d{4})/(?P<month>\d{2})/$
         ^date/(?P<page>\d+)/(?P<year>\d{4})/$
    """
    variables = dict()
    page = int(page)
    previous_page = page - 1
    next_page = page + 1
    max_results = 5
    if year.isdigit():
        year = int(year)
    else:
        return HttpResponse(status=400)
    headline = _('Showing result for %(year)s.') % {'year': year}
    previous_page_link = "date/%d/%d/" % (previous_page, year)
    next_page_link = "date/%d/%d/" % (next_page, year)
    videopost_list = VideoPost.objects.filter(enabled=True, locked=False)
    videopost_list = videopost_list.filter(publication_date__year=year).order_by('-publication_date')
    if month and month.isdigit():
        month = int(month)
        month_name = get_month_name(month)
        videopost_list = videopost_list.filter(publication_date__month=month)
        previous_page_link = previous_page_link + str(month) + "/"
        next_page_link = next_page_link + str(month) + "/"
        headline = _('Showing result for: %(month)s %(year)d.') % {'month': month_name, 'year': year}
        if day and day.isdigit():
            day = int(day)
            day_name = get_day_name(day)       
            videopost_list = videopost_list.filter(publication_date__day=day)
            previous_page_link = previous_page_link + str(day) + "/"
            next_page_link = next_page_link + str(day) + "/"
            headline = _('Showing result for: %(day)s %(month)s %(year)d.') % {'day': day_name, 'month': month_name, 'year': year}
    if videopost_list:            
        videoposts_paginated = paginator_simple(videopost_list, max_results, page)
        variables['videoposts'] = videoposts_paginated
        variables['headline'] = headline 
        variables['previous-page-link'] = "%d/" % previous_page
        variables['next-page-link'] = "%d/" % next_page
    else:
        messages.info(request, _('No Results Found.'))
    t = get_template('videopost/list.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)
Exemple #5
0
def retrieve_all(request, page=1):
    """
    Gets All the Video Post
    URL: ^(?P<page>\d+)/$
    """
    variables = dict()
    max_results = 5
    previous_page = int(page) - 1
    next_page = int(page) + 1
    videopost_list = VideoPost.objects.filter(enabled=True, locked=False).order_by('-publication_date')
    if videopost_list:
        videoposts_paginated = paginator_simple(videopost_list, max_results, page)
        variables['videoposts'] = videoposts_paginated
        variables['previous-page-link'] = "%d/" % previous_page
        variables['next-page-link'] = "%d/" % next_page
    else:
        messages.info(request, _('No Results Found.'))
    t = get_template('videopost/list.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)
Exemple #6
0
def retrieve_all(request, page=1):
    """
    Gets All the Video Post
    URL: ^(?P<page>\d+)/$
    """
    variables = dict()
    max_results = 5
    previous_page = int(page) - 1
    next_page = int(page) + 1
    videopost_list = VideoPost.objects.filter(
        enabled=True, locked=False).order_by('-publication_date')
    if videopost_list:
        videoposts_paginated = paginator_simple(videopost_list, max_results,
                                                page)
        variables['videoposts'] = videoposts_paginated
        variables['previous-page-link'] = "%d/" % previous_page
        variables['next-page-link'] = "%d/" % next_page
    else:
        messages.info(request, _('No Results Found.'))
    t = get_template('videopost/list.html')
    html = t.render(RequestContext(request, variables))
    return HttpResponse(html)