From 069b4eae2a46c92e6c08780b48cb4040edc0b3f6 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 28 Oct 2020 16:52:23 -0700 Subject: [PATCH] Unshelve button on shelf page --- bookwyrm/templates/snippets/shelf.html | 12 ++++++++++++ bookwyrm/urls.py | 1 + bookwyrm/view_actions.py | 11 ++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/snippets/shelf.html b/bookwyrm/templates/snippets/shelf.html index 8f825f5f5..f8acf56c1 100644 --- a/bookwyrm/templates/snippets/shelf.html +++ b/bookwyrm/templates/snippets/shelf.html @@ -66,6 +66,18 @@ {% include 'snippets/stars.html' with rating=ratings|dict_key:book.id %} {% endif %} + +
+ {% csrf_token %} + + + +
+ {% endfor %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 5d75f49b2..6b9a29aec 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -117,6 +117,7 @@ urlpatterns = [ re_path(r'^delete-status/?$', actions.delete_status), re_path(r'^shelve/?$', actions.shelve), + re_path(r'^unshelve/?$', actions.unshelve), re_path(r'^follow/?$', actions.follow), re_path(r'^unfollow/?$', actions.unfollow), diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index e8c3e6f2a..c3c937842 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -285,6 +285,16 @@ def shelve(request): return redirect('/') +@login_required +def unshelve(request): + ''' put a on a user's shelf ''' + book = models.Edition.objects.get(id=request.POST['book']) + current_shelf = models.Shelf.objects.get(id=request.POST['shelf']) + + outgoing.handle_unshelve(request.user, book, current_shelf) + return redirect(request.headers.get('Referer', '/')) + + @login_required def rate(request): ''' just a star rating for a book ''' @@ -322,7 +332,6 @@ def reply(request): def handle_status(request, form): ''' all the "create a status" functions are the same ''' - book_id = request.POST.get('book') if not form.is_valid(): return redirect(request.headers.get('Referer', '/'))