Ejemplo n.º 1
0
def entries_all(request):
    context = dict()
    context['title'] = djournal_settings.TITLE
    items = Entry.objects.filter(published=True)
    if items:
        page = request.GET.get('page', 1)
        paginate(items, page, context)
    else:
        headline =_('No Search Results.')
        context['headline'] = headline
    t = get_template('djournal/entries.html')
    html = t.render(RequestContext(request, context))
    return HttpResponse(html)
Ejemplo n.º 2
0
def entries_tag(request, tag_id):
    context = dict()
    tag_id = int(tag_id)
    tag = get_object_or_404(Tag, pk=tag_id)
    items = tag.entry_set.filter(published=True)
    context['tag'] = tag
    if items:
        page = request.GET.get('page', 1)
        paginate(items, page, context)
        headline = _('Showing results for: %s') % tag.name
    else:
        headline = _('No Search Results for: %s') % tag.name
    context['headline'] = headline
    context['tag'] = tag
    t = get_template('djournal/entries.html')
    html = t.render(RequestContext(request, context))
    return HttpResponse(html)
Ejemplo n.º 3
0
def entries_month(request, year, month):
    context = dict()
    if year.isdigit() and month.isdigit():
        year = int(year)
        month = int(month)
        month_name = get_month_name(month)
    else:
        return HttpResponse(status=400)
    items = Entry.objects.filter(published=True, modification_date__month=month, modification_date__year=year)
    if items:
        headline = _('Showing results for: %(month)s %(year)d') % {'month': month_name, 'year': year}
        page = request.GET.get('page', 1)
        paginate(items, page, context)
    else:
        headline = _('No Search Results for: %(month)s %(year)d') % {'month': month_name, 'year': year}
    context['headline'] = headline
    context['year_expanded'] = year
    t = get_template('djournal/entries.html')
    html = t.render(RequestContext(request, context))
    return HttpResponse(html)
Ejemplo n.º 4
0
def entries_year(request, year):
    """
    Gets All the Video Post by Date.
    URL: ^date/(?P<page>\d+)/(?P<year>\d{4})/$
    """
    context = dict()
    if year.isdigit():
        year = int(year)
    else:
        return HttpResponse(status=400)
    items = Entry.objects.filter(published=True, modification_date__year=year)
    if items:
        page = request.GET.get('page', 1)
        paginate(items, page, context)
        headline = _('Showing results for: %(year)d') % {'year': year}
    else:
        context['info_enabled'] = True
        headline = _('No Search Results for: %(year)d') % {'year': year}
    context['headline'] = headline
    context['year_expanded'] = year
    t = get_template('djournal/entries.html')
    html = t.render(RequestContext(request, context))
    return HttpResponse(html)