示例#1
0
def archive_month(request, year, month):
    c = Context(request, date=datetime.date(int(year), int(month), 1),
        posts=posts.get_list(listed__exact=True,
                             posted__year=int(year),
                             posted__month=int(month),
                             order_by=['posted']))
    t = template_loader.get_template('blog/archive-month')
    return HttpResponse(t.render(c))
示例#2
0
def latest(request, format=None):
    c = Context(request, posts=posts.get_list(listed__exact=True, limit=5, order_by=['-posted']))
    if format == 'atom':
        t = template_loader.get_template('blog/atom.xml')
        ct = atom_content_type
    else:
        t = template_loader.get_template('blog/latest')
        ct = None
    return HttpResponse(t.render(c), ct)
示例#3
0
def archive_index(request):
    c = db.cursor()
    # FIXME -- use db abstraction layer for DATE_TRUNC
    c.execute("""SELECT DISTINCT DATE_TRUNC('month', posted) AS posted
                 FROM blog_posts ORDER BY posted DESC""")
    rows = c.fetchall()
    c.close()

    c = Context(request, months=[ {
                    'date': date,
                    'posts': len(posts.get_list(listed__exact=True,
                                                posted__year=date.year,
                                                posted__month=date.month)),
                    } for date, in rows ])
    t = template_loader.get_template('blog/archive-index')
    return HttpResponse(t.render(c))
示例#4
0
def draft_index(request):
    return {
        'drafts': posts.get_list(listed__exact=False,
                                 order_by=['-posted']),
    }