Пример #1
0
def archive_year(request, year):
    posts = Post.query(Post.active == True).order(-Post.created_at).fetch()
    posts_filtered = []

    for post in posts:
        if post.created_at.year == int(year):
            posts_filtered.append(post)

    archive = build_archive()
    return render_to_response('index.html', {'posts': posts_filtered, 'archive': archive})
Пример #2
0
def build_archive():
    posts = Post.query(Post.active == True).order(-Post.created_at).fetch()
    archive = {}

    for post in posts:
        year = post.created_at.year
        month = post.created_at.strftime('%m-%B')

        if year not in archive:
            archive[year] = []

        if month not in archive[year]:
            archive[year].append(month)

    return archive
Пример #3
0
def index(request):
    posts = Post.query(Post.active == True).order(-Post.created_at).fetch()
    archive = build_archive()
    return render_to_response('index.html', {'posts': posts, 'archive': archive})