Merge pull request #360 from mouse-reeve/shelve_buttons

Fixes unset active shelf in shelve button pulldown
This commit is contained in:
Mouse Reeve 2020-11-20 21:18:28 -08:00 committed by GitHub
commit 56b6fb9c97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 19 deletions

View file

@ -2,6 +2,7 @@
{% if request.user.is_authenticated %}
{% with book.id|uuid as uuid %}
{% active_shelf book as active_shelf %}
<div class="field is-grouped">
{% if active_shelf.identifier == 'read' %}
<button class="button is-small" disabled>

View file

@ -168,25 +168,6 @@ def active_shelf(context, book):
return shelf.shelf if shelf else None
@register.simple_tag(takes_context=True)
def shelve_button_text(context, book):
''' check what shelf a user has a book on, if any '''
#TODO: books can be on multiple shelves
shelf = models.ShelfBook.objects.filter(
shelf__user=context['request'].user,
book=book
).first()
if not shelf:
return 'Want to read'
identifier = shelf.shelf.identifier
if identifier == 'to-read':
return 'Start reading'
if identifier == 'reading':
return 'I\'m done!'
return 'Read'
@register.simple_tag(takes_context=False)
def latest_read_through(book, user):
''' the most recent read activity '''