Give user control over "want to read" posts

This commit is contained in:
Mouse Reeve 2021-01-30 15:18:38 -08:00
parent e5fd14b206
commit 9b326f7321
2 changed files with 8 additions and 3 deletions

View file

@ -8,6 +8,7 @@ Want to Read "<em>{{ book.title }}</em>"
<form name="shelve" action="/shelve/" method="post"> <form name="shelve" action="/shelve/" method="post">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="book" value="{{ active_shelf.book.id }}"> <input type="hidden" name="book" value="{{ active_shelf.book.id }}">
<input type="hidden" name="shelf" value="to-read">
{% endblock %} {% endblock %}
{% block modal-footer %} {% block modal-footer %}
@ -20,7 +21,7 @@ Want to Read "<em>{{ book.title }}</em>"
{% include 'snippets/privacy_select.html' %} {% include 'snippets/privacy_select.html' %}
</div> </div>
<div class="column"> <div class="column">
<button class="button is-success" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}> <button class="button is-success" type="submit">
<span>Want to read</span> <span>Want to read</span>
</button> </button>
{% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="want-to-read" controls_uid=uuid %} {% include 'snippets/toggle/toggle_button.html' with text="Cancel" controls_text="want-to-read" controls_uid=uuid %}

View file

@ -125,6 +125,8 @@ def shelve(request):
identifier=request.POST.get('shelf'), identifier=request.POST.get('shelf'),
user=request.user user=request.user
).first() ).first()
#if not desired_shelf:
# return HttpResponseNotFound()
if request.POST.get('reshelve', True): if request.POST.get('reshelve', True):
try: try:
@ -141,12 +143,14 @@ def shelve(request):
broadcast(request.user, shelfbook.to_add_activity(request.user)) broadcast(request.user, shelfbook.to_add_activity(request.user))
# post about "want to read" shelves # post about "want to read" shelves
if desired_shelf.identifier == 'to-read': if desired_shelf.identifier == 'to-read' and \
request.POST.get('post-status'):
privacy = request.POST.get('privacy') or desired_shelf.privacy
handle_reading_status( handle_reading_status(
request.user, request.user,
desired_shelf, desired_shelf,
book, book,
privacy=desired_shelf.privacy privacy=privacy
) )
return redirect('/') return redirect('/')