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.
5 from datetime import datetime
6 from django.shortcuts import render, get_object_or_404
7 from django.views.decorators import cache
8 from suggest.forms import PublishingSuggestForm
13 def book_stub_detail(request, slug):
14 book = get_object_or_404(models.BookStub, slug=slug)
15 if book.pd and not book.in_pd():
16 pd_counter = datetime(book.pd, 1, 1)
20 form = PublishingSuggestForm(initial={"books": u"%s — %s, \n" % (book.author, book.title)})
22 return render(request, 'pdcounter/book_stub_detail.html', {
24 'pd_counter': pd_counter,
30 def author_detail(request, slug):
31 author = get_object_or_404(models.Author, slug=slug)
32 if not author.alive():
33 pd_counter = datetime(author.goes_to_pd(), 1, 1)
37 form = PublishingSuggestForm(initial={"books": author.name + ", \n"})
39 return render(request, 'pdcounter/author_detail.html', {
41 'pd_counter': pd_counter,