X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/3ac9cb26acd9b7c5ba421dac123ba8f75b782bd2..802753926b75af4c173d2765e5f3777a559f7ebb:/apps/catalogue/views.py?ds=sidebyside diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 6de5a268e..60f984a9d 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -294,12 +294,15 @@ def remove_from_shelf(request, shelf, book): book = get_object_or_404(models.Book, slug=book) shelf = get_object_or_404(models.Tag, slug=shelf, category='set', user=request.user) - models.Tag.objects.remove_tag(book, shelf) - - shelf.book_count -= 1 - shelf.save() - - return HttpResponse('Usunieto') + if shelf in book.tags: + models.Tag.objects.remove_tag(book, shelf) + + shelf.book_count -= 1 + shelf.save() + + return HttpResponse('Usunięto') + else: + return HttpResponse('Książki nie ma na półce') def collect_books(books):