Unshelve button on shelf page

This commit is contained in:
Mouse Reeve 2020-10-28 16:52:23 -07:00
parent bdde69473a
commit 069b4eae2a
3 changed files with 23 additions and 1 deletions

View file

@ -66,6 +66,18 @@
{% include 'snippets/stars.html' with rating=ratings|dict_key:book.id %}
</td>
{% endif %}
<td>
<form name="unshelve" action="/unshelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="shelf" value="{{ shelf.id }}">
<button class="button is-small" type="submit" style="">
<span class="icon icon-x">
<span class="is-sr-only">Remove from shelf</span>
</span>
</button>
</form>
</td>
</tr>
{% endfor %}
</table>

View file

@ -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),

View file

@ -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', '/'))