Merge pull request #102 from cthulahoops/shelf_button_user

Show shelf buttons appropriate for current user.
This commit is contained in:
Mouse Reeve 2020-03-27 08:57:17 -07:00 committed by GitHub
commit 7be17ea09c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -21,6 +21,8 @@
</div> </div>
</div> </div>
{% include 'snippets/shelve_button.html' %}
</div> </div>
</div> </div>
</div> </div>

View file

@ -84,7 +84,7 @@ 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: try:
shelf = models.ShelfBook.objects.get( shelf = models.ShelfBook.objects.get(
shelf__user=context['user'], shelf__user=context['request'].user,
book=book book=book
) )
except models.ShelfBook.DoesNotExist: except models.ShelfBook.DoesNotExist:
@ -102,7 +102,7 @@ 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: try:
shelf = models.ShelfBook.objects.get( shelf = models.ShelfBook.objects.get(
shelf__user=context['user'], shelf__user=context['request'].user,
book=book book=book
) )
except models.ShelfBook.DoesNotExist: except models.ShelfBook.DoesNotExist: