mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Fixes error handling for book button filters
This commit is contained in:
parent
09f030db88
commit
5ebe1aa7c7
1 changed files with 14 additions and 14 deletions
|
@ -91,14 +91,14 @@ def get_user_liked(user, status):
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def shelve_button_identifier(context, book):
|
def shelve_button_identifier(context, book):
|
||||||
''' check what shelf a user has a book on, if any '''
|
''' check what shelf a user has a book on, if any '''
|
||||||
try:
|
#TODO: books can be on multiple shelves, handle that better
|
||||||
#TODO: books can be on multiple shelves, handle that better
|
shelf = models.ShelfBook.objects.filter(
|
||||||
shelf = models.ShelfBook.objects.filter(
|
shelf__user=context['request'].user,
|
||||||
shelf__user=context['request'].user,
|
book=book
|
||||||
book=book
|
).first()
|
||||||
).first()
|
if not shelf:
|
||||||
except models.ShelfBook.DoesNotExist:
|
|
||||||
return 'to-read'
|
return 'to-read'
|
||||||
|
|
||||||
identifier = shelf.shelf.identifier
|
identifier = shelf.shelf.identifier
|
||||||
if identifier == 'to-read':
|
if identifier == 'to-read':
|
||||||
return 'reading'
|
return 'reading'
|
||||||
|
@ -110,14 +110,14 @@ def shelve_button_identifier(context, book):
|
||||||
@register.simple_tag(takes_context=True)
|
@register.simple_tag(takes_context=True)
|
||||||
def shelve_button_text(context, book):
|
def shelve_button_text(context, book):
|
||||||
''' check what shelf a user has a book on, if any '''
|
''' check what shelf a user has a book on, if any '''
|
||||||
try:
|
#TODO: books can be on multiple shelves
|
||||||
#TODO: books can be on multiple shelves
|
shelf = models.ShelfBook.objects.filter(
|
||||||
shelf = models.ShelfBook.objects.filter(
|
shelf__user=context['request'].user,
|
||||||
shelf__user=context['request'].user,
|
book=book
|
||||||
book=book
|
).first()
|
||||||
).first()
|
if not shelf:
|
||||||
except models.ShelfBook.DoesNotExist:
|
|
||||||
return 'Want to read'
|
return 'Want to read'
|
||||||
|
|
||||||
identifier = shelf.shelf.identifier
|
identifier = shelf.shelf.identifier
|
||||||
if identifier == 'to-read':
|
if identifier == 'to-read':
|
||||||
return 'Start reading'
|
return 'Start reading'
|
||||||
|
|
Loading…
Reference in a new issue