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

@ -19,11 +19,12 @@ def book_search(query):
for doc in data['docs'][:5]:
key = doc['key']
key = key.split('/')[-1]
author = doc.get('author_name') or ['Unknown']
results.append({
'title': doc.get('title'),
'olkey': key,
'year': doc.get('first_publish_year'),
'author': doc.get('author_name')[0],
'author': author[0],
})
return results
@ -68,7 +69,7 @@ def get_or_create_book(olkey, user=None, update=False):
author_id = author_id.split('/')[-1]
book.authors.add(get_or_create_author(author_id))
if data['covers'] and len(data['covers']):
if data.get('covers') and len(data['covers']):
book.cover.save(*get_cover(data['covers'][0]), save=True)
return book