Adds very simple author pages

This commit is contained in:
Mouse Reeve
2020-02-10 22:32:03 -08:00
parent 0f1240ca1f
commit 964c56079c
5 changed files with 36 additions and 3 deletions

View File

@ -190,6 +190,22 @@ def book_page(request, book_identifier):
return TemplateResponse(request, 'book.html', data)
@login_required
def author_page(request, author_identifier):
''' landing page for an author '''
try:
author = models.Author.objects.get(openlibrary_key=author_identifier)
except ValueError:
return HttpResponseNotFound()
books = models.Book.objects.filter(authors=author)
data = {
'author': author,
'books': books,
}
return TemplateResponse(request, 'author.html', data)
@login_required
def shelve(request, shelf_id, book_id, reshelve=True):
''' put a book on a user's shelf '''