8fb1b13fa2ee9174347b381b274b06e3ddb2322b
[wolnelektury.git] / apps / pdcounter / views.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from datetime import datetime
6 from django.template import RequestContext
7 from django.shortcuts import render_to_response, get_object_or_404
8 from pdcounter import models
9 from suggest.forms import PublishingSuggestForm
10
11
12 def book_stub_detail(request, slug):
13     book = get_object_or_404(models.BookStub, slug=slug)
14     pd_counter = datetime(book.pd, 1, 1)
15
16     form = PublishingSuggestForm(
17             initial={"books": u"%s — %s, \n" % (book.author, book.title)})
18
19     return render_to_response('pdcounter/book_stub_detail.html', locals(),
20         context_instance=RequestContext(request))
21
22
23 def author_detail(request, slug):
24     author = get_object_or_404(models.Author, slug=slug)
25     pd_counter = datetime(author.goes_to_pd(), 1, 1)
26
27     form = PublishingSuggestForm(initial={"books": author.name + ", \n"})
28
29     return render_to_response('pdcounter/author_detail.html', locals(),
30         context_instance=RequestContext(request))