Merge branch 'main' into frontend/subtitle

This commit is contained in:
Fabien Basmaison 2021-06-11 08:49:46 +02:00
commit cf751a8efa
19 changed files with 175 additions and 132 deletions

View file

@ -3,7 +3,7 @@
let BookWyrm = new class { let BookWyrm = new class {
constructor() { constructor() {
this.MAX_FILE_SIZE_BYTES = 10 * 1000000 this.MAX_FILE_SIZE_BYTES = 10 * 1000000;
this.initOnDOMLoaded(); this.initOnDOMLoaded();
this.initReccuringTasks(); this.initReccuringTasks();
this.initEventListeners(); this.initEventListeners();
@ -45,14 +45,14 @@ let BookWyrm = new class {
* Execute code once the DOM is loaded. * Execute code once the DOM is loaded.
*/ */
initOnDOMLoaded() { initOnDOMLoaded() {
const bookwyrm = this const bookwyrm = this;
window.addEventListener('DOMContentLoaded', function() { window.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.tab-group') document.querySelectorAll('.tab-group')
.forEach(tabs => new TabGroup(tabs)); .forEach(tabs => new TabGroup(tabs));
document.querySelectorAll('input[type="file"]').forEach( document.querySelectorAll('input[type="file"]').forEach(
bookwyrm.disableIfTooLarge.bind(bookwyrm) bookwyrm.disableIfTooLarge.bind(bookwyrm)
) );
}); });
} }
@ -138,6 +138,7 @@ let BookWyrm = new class {
* @return {undefined} * @return {undefined}
*/ */
toggleAction(event) { toggleAction(event) {
event.preventDefault();
let trigger = event.currentTarget; let trigger = event.currentTarget;
let pressed = trigger.getAttribute('aria-pressed') === 'false'; let pressed = trigger.getAttribute('aria-pressed') === 'false';
let targetId = trigger.dataset.controls; let targetId = trigger.dataset.controls;
@ -182,6 +183,8 @@ let BookWyrm = new class {
if (focus) { if (focus) {
this.toggleFocus(focus); this.toggleFocus(focus);
} }
return false;
} }
/** /**
@ -298,25 +301,25 @@ let BookWyrm = new class {
} }
disableIfTooLarge(eventOrElement) { disableIfTooLarge(eventOrElement) {
const { addRemoveClass, MAX_FILE_SIZE_BYTES } = this const { addRemoveClass, MAX_FILE_SIZE_BYTES } = this;
const element = eventOrElement.currentTarget || eventOrElement const element = eventOrElement.currentTarget || eventOrElement;
const submits = element.form.querySelectorAll('[type="submit"]') const submits = element.form.querySelectorAll('[type="submit"]');
const warns = element.parentElement.querySelectorAll('.file-too-big') const warns = element.parentElement.querySelectorAll('.file-too-big');
const isTooBig = element.files && const isTooBig = element.files &&
element.files[0] && element.files[0] &&
element.files[0].size > MAX_FILE_SIZE_BYTES element.files[0].size > MAX_FILE_SIZE_BYTES;
if (isTooBig) { if (isTooBig) {
submits.forEach(submitter => submitter.disabled = true) submits.forEach(submitter => submitter.disabled = true);
warns.forEach( warns.forEach(
sib => addRemoveClass(sib, 'is-hidden', false) sib => addRemoveClass(sib, 'is-hidden', false)
) );
} else { } else {
submits.forEach(submitter => submitter.disabled = false) submits.forEach(submitter => submitter.disabled = false);
warns.forEach( warns.forEach(
sib => addRemoveClass(sib, 'is-hidden', true) sib => addRemoveClass(sib, 'is-hidden', true)
) );
}
} }
} }
}();

View file

@ -17,7 +17,7 @@ let LocalStorageTools = new class {
* @return {undefined} * @return {undefined}
*/ */
updateDisplay(event) { updateDisplay(event) {
// used in set reading goal // Used in set reading goal
let key = event.target.dataset.id; let key = event.target.dataset.id;
let value = event.target.dataset.value; let value = event.target.dataset.value;
@ -34,10 +34,10 @@ let LocalStorageTools = new class {
* @return {undefined} * @return {undefined}
*/ */
setDisplay(node) { setDisplay(node) {
// used in set reading goal // Used in set reading goal
let key = node.dataset.hide; let key = node.dataset.hide;
let value = window.localStorage.getItem(key); let value = window.localStorage.getItem(key);
BookWyrm.addRemoveClass(node, 'is-hidden', value); BookWyrm.addRemoveClass(node, 'is-hidden', value);
} }
} }();

View file

@ -1,7 +1,7 @@
{% load i18n %} {% load i18n %}
<div <div
role="dialog" role="dialog"
class="modal is-hidden" class="modal {% if active %}is-active{% else %}is-hidden{% endif %}"
id="{{ controls_text }}-{{ controls_uid }}" id="{{ controls_text }}-{{ controls_uid }}"
aria-labelledby="modal-card-title-{{ controls_text }}-{{ controls_uid }}" aria-labelledby="modal-card-title-{{ controls_text }}-{{ controls_uid }}"
aria-modal="true" aria-modal="true"

View file

@ -0,0 +1,14 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}
{% blocktrans trimmed with book_title=book.title %}
Finish "{{ book_title }}"
{% endblocktrans %}
{% endblock %}
{% block content %}
{% include "snippets/shelve_button/finish_reading_modal.html" with book=book active=True %}
{% endblock %}

View file

@ -0,0 +1,14 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}
{% blocktrans trimmed with book_title=book.title %}
Start "{{ book_title }}"
{% endblocktrans %}
{% endblock %}
{% block content %}
{% include "snippets/shelve_button/start_reading_modal.html" with book=book active=True %}
{% endblock %}

View file

@ -0,0 +1,14 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}
{% blocktrans trimmed with book_title=book.title %}
Want to Read "{{ book_title }}"
{% endblocktrans %}
{% endblock %}
{% block content %}
{% include "snippets/shelve_button/want_to_read_modal.html" with book=book active=True no_body=True %}
{% endblock %}

View file

@ -7,7 +7,7 @@
{% block modal-form-open %} {% block modal-form-open %}
<form name="finish-reading" action="/finish-reading/{{ book.id }}" method="post"> <form name="finish-reading" action="{% url 'reading-status' 'finish' book.id %}" method="post">
{% endblock %} {% endblock %}
{% block modal-body %} {% block modal-body %}

View file

@ -7,16 +7,25 @@
{% if dropdown %}<li role="menuitem" class="dropdown-item p-0">{% endif %} {% if dropdown %}<li role="menuitem" class="dropdown-item p-0">{% endif %}
<div class="{% if not dropdown and active_shelf.shelf.identifier|next_shelf != shelf.identifier %}is-hidden{% endif %}"> <div class="{% if not dropdown and active_shelf.shelf.identifier|next_shelf != shelf.identifier %}is-hidden{% endif %}">
{% if shelf.identifier == 'reading' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %} {% if shelf.identifier == 'reading' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %}
{% trans "Start reading" as button_text %} {% trans "Start reading" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="start-reading" controls_uid=button_uuid focus="modal-title-start-reading" disabled=is_current %} {% url 'reading-status' 'start' book.id as fallback_url %}
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="start-reading" controls_uid=button_uuid focus="modal-title-start-reading" disabled=is_current fallback_url=fallback_url %}
{% endif %}{% elif shelf.identifier == 'read' and active_shelf.shelf.identifier == 'read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %} {% endif %}{% elif shelf.identifier == 'read' and active_shelf.shelf.identifier == 'read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %}
<button type="button" class="button {{ class }}" disabled><span>{% trans "Read" %}</span> <button type="button" class="button {{ class }}" disabled><span>{% trans "Read" %}</span>
{% endif %}{% elif shelf.identifier == 'read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %} {% endif %}{% elif shelf.identifier == 'read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %}
{% trans "Finish reading" as button_text %} {% trans "Finish reading" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="finish-reading" controls_uid=button_uuid focus="modal-title-finish-reading" disabled=is_current %} {% url 'reading-status' 'finish' book.id as fallback_url %}
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="finish-reading" controls_uid=button_uuid focus="modal-title-finish-reading" disabled=is_current fallback_url=fallback_url %}
{% endif %}{% elif shelf.identifier == 'to-read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %} {% endif %}{% elif shelf.identifier == 'to-read' %}{% if not dropdown or active_shelf.shelf.identifier|next_shelf != shelf.identifier %}
{% trans "Want to read" as button_text %} {% trans "Want to read" as button_text %}
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="want-to-read" controls_uid=button_uuid focus="modal-title-want-to-read" disabled=is_current %} {% url 'reading-status' 'want' book.id as fallback_url %}
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="want-to-read" controls_uid=button_uuid focus="modal-title-want-to-read" disabled=is_current fallback_url=fallback_url %}
{% endif %}{% elif shelf.editable %} {% endif %}{% elif shelf.editable %}
<form name="shelve" action="/shelve/" method="post"> <form name="shelve" action="/shelve/" method="post">
{% csrf_token %} {% csrf_token %}
@ -44,7 +53,9 @@
{% 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="{{ active_shelf.shelf.id }}"> <input type="hidden" name="shelf" value="{{ active_shelf.shelf.id }}">
<button class="button is-fullwidth is-small{% if dropdown %} is-radiusless{% endif %} is-danger is-light" type="submit">{% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %}</button> <button class="button is-fullwidth is-small{% if dropdown %} is-radiusless{% endif %} is-danger is-light" type="submit">
{% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %}
</button>
</form> </form>
</li> </li>
{% endif %} {% endif %}

View file

@ -2,11 +2,13 @@
{% load i18n %} {% load i18n %}
{% block modal-title %} {% block modal-title %}
{% blocktrans with book_title=book.title %}Start "<em>{{ book_title }}</em>"{% endblocktrans %} {% blocktrans trimmed with book_title=book.title %}
Start "<em>{{ book_title }}</em>"
{% endblocktrans %}
{% endblock %} {% endblock %}
{% block modal-form-open %} {% block modal-form-open %}
<form name="start-reading" action="/start-reading/{{ book.id }}" method="post"> <form name="start-reading" action="{% url 'reading-status' 'start' book.id %}" method="post">
{% endblock %} {% endblock %}
{% block modal-body %} {% block modal-body %}

View file

@ -6,7 +6,7 @@
{% endblock %} {% endblock %}
{% block modal-form-open %} {% block modal-form-open %}
<form name="shelve" action="/shelve/" method="post"> <form name="shelve" action="{% url 'reading-status' 'want' book.id %}" 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"> <input type="hidden" name="shelf" value="to-read">

View file

@ -1,5 +1,12 @@
{% if fallback_url %}
<form name="fallback-form-{{ controls_uuid}}" method="GET" action="{{ fallback_url }}">
{% endif %}
<button <button
{% if not fallback_url %}
type="button" type="button"
{% else %}
type="submit"
{% endif %}
class="{% if not nonbutton %}button {% endif %}{{ class }}{% if button_type %} {{ button_type }}{% endif %}" class="{% if not nonbutton %}button {% endif %}{{ class }}{% if button_type %} {{ button_type }}{% endif %}"
data-controls="{{ controls_text }}{% if controls_uid %}-{{ controls_uid }}{% endif %}" data-controls="{{ controls_text }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"
{% if focus %}data-focus-target="{{ focus }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"{% endif %} {% if focus %}data-focus-target="{{ focus }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"{% endif %}
@ -20,3 +27,6 @@
<span>{{ text }}</span> <span>{{ text }}</span>
{% endif %} {% endif %}
</button> </button>
{% if fallback_url %}
</form>
{% endif %}

View file

@ -56,7 +56,7 @@ class ReadingViews(TestCase):
) )
request.user = self.local_user request.user = self.local_user
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
views.start_reading(request, self.book.id) views.ReadingStatus.as_view()(request, "start", self.book.id)
self.assertEqual(shelf.books.get(), self.book) self.assertEqual(shelf.books.get(), self.book)
@ -86,7 +86,7 @@ class ReadingViews(TestCase):
request = self.factory.post("") request = self.factory.post("")
request.user = self.local_user request.user = self.local_user
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
views.start_reading(request, self.book.id) views.ReadingStatus.as_view()(request, "start", self.book.id)
self.assertFalse(to_read_shelf.books.exists()) self.assertFalse(to_read_shelf.books.exists())
self.assertEqual(shelf.books.get(), self.book) self.assertEqual(shelf.books.get(), self.book)
@ -112,7 +112,7 @@ class ReadingViews(TestCase):
request.user = self.local_user request.user = self.local_user
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"): with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
views.finish_reading(request, self.book.id) views.ReadingStatus.as_view()(request, "finish", self.book.id)
self.assertEqual(shelf.books.get(), self.book) self.assertEqual(shelf.books.get(), self.book)

View file

@ -33,7 +33,7 @@ class ReadThrough(TestCase):
self.assertEqual(self.edition.readthrough_set.count(), 0) self.assertEqual(self.edition.readthrough_set.count(), 0)
self.client.post( self.client.post(
"/start-reading/{}".format(self.edition.id), "/reading-status/start/{}".format(self.edition.id),
{ {
"start_date": "2020-11-27", "start_date": "2020-11-27",
}, },
@ -54,10 +54,9 @@ class ReadThrough(TestCase):
self.assertEqual(self.edition.readthrough_set.count(), 0) self.assertEqual(self.edition.readthrough_set.count(), 0)
self.client.post( self.client.post(
"/start-reading/{}".format(self.edition.id), "/reading-status/start/{}".format(self.edition.id),
{ {
"start_date": "2020-11-27", "start_date": "2020-11-27",
"progress": 50,
}, },
) )
@ -66,15 +65,8 @@ class ReadThrough(TestCase):
self.assertEqual( self.assertEqual(
readthroughs[0].start_date, datetime(2020, 11, 27, tzinfo=timezone.utc) readthroughs[0].start_date, datetime(2020, 11, 27, tzinfo=timezone.utc)
) )
self.assertEqual(readthroughs[0].progress, 50)
self.assertEqual(readthroughs[0].finish_date, None) self.assertEqual(readthroughs[0].finish_date, None)
progress_updates = readthroughs[0].progressupdate_set.all()
self.assertEqual(len(progress_updates), 1)
self.assertEqual(progress_updates[0].mode, models.ProgressMode.PAGE)
self.assertEqual(progress_updates[0].progress, 50)
self.assertEqual(delay_mock.call_count, 1)
# Update progress # Update progress
self.client.post( self.client.post(
"/edit-readthrough", "/edit-readthrough",
@ -87,9 +79,9 @@ class ReadThrough(TestCase):
progress_updates = ( progress_updates = (
readthroughs[0].progressupdate_set.order_by("updated_date").all() readthroughs[0].progressupdate_set.order_by("updated_date").all()
) )
self.assertEqual(len(progress_updates), 2) self.assertEqual(len(progress_updates), 1)
self.assertEqual(progress_updates[1].mode, models.ProgressMode.PAGE) self.assertEqual(progress_updates[0].mode, models.ProgressMode.PAGE)
self.assertEqual(progress_updates[1].progress, 100) self.assertEqual(progress_updates[0].progress, 100)
# Edit doesn't publish anything # Edit doesn't publish anything
self.assertEqual(delay_mock.call_count, 1) self.assertEqual(delay_mock.call_count, 1)

View file

@ -223,7 +223,7 @@ urlpatterns = [
re_path( re_path(
r"^list/(?P<list_id>\d+)/curate/?$", views.Curate.as_view(), name="list-curate" r"^list/(?P<list_id>\d+)/curate/?$", views.Curate.as_view(), name="list-curate"
), ),
# Uyser books # User books
re_path(r"%s/books/?$" % user_path, views.Shelf.as_view(), name="user-shelves"), re_path(r"%s/books/?$" % user_path, views.Shelf.as_view(), name="user-shelves"),
re_path( re_path(
r"^%s/(helf|books)/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % user_path, r"^%s/(helf|books)/(?P<shelf_identifier>[\w-]+)(.json)?/?$" % user_path,
@ -315,8 +315,12 @@ urlpatterns = [
re_path(r"^delete-readthrough/?$", views.delete_readthrough), re_path(r"^delete-readthrough/?$", views.delete_readthrough),
re_path(r"^create-readthrough/?$", views.create_readthrough), re_path(r"^create-readthrough/?$", views.create_readthrough),
re_path(r"^delete-progressupdate/?$", views.delete_progressupdate), re_path(r"^delete-progressupdate/?$", views.delete_progressupdate),
re_path(r"^start-reading/(?P<book_id>\d+)/?$", views.start_reading), # shelve actions
re_path(r"^finish-reading/(?P<book_id>\d+)/?$", views.finish_reading), re_path(
r"^reading-status/(?P<status>want|start|finish)/(?P<book_id>\d+)/?$",
views.ReadingStatus.as_view(),
name="reading-status",
),
# following # following
re_path(r"^follow/?$", views.follow, name="follow"), re_path(r"^follow/?$", views.follow, name="follow"),
re_path(r"^unfollow/?$", views.unfollow, name="unfollow"), re_path(r"^unfollow/?$", views.unfollow, name="unfollow"),

View file

@ -24,8 +24,9 @@ from .landing import About, Home, Discover
from .list import Lists, List, Curate, UserLists from .list import Lists, List, Curate, UserLists
from .notifications import Notifications from .notifications import Notifications
from .outbox import Outbox from .outbox import Outbox
from .reading import edit_readthrough, create_readthrough, delete_readthrough from .reading import edit_readthrough, create_readthrough
from .reading import start_reading, finish_reading, delete_progressupdate from .reading import delete_readthrough, delete_progressupdate
from .reading import ReadingStatus
from .reports import Report, Reports, make_report, resolve_report, suspend_user from .reports import Report, Reports, make_report, resolve_report, suspend_user
from .rss_feed import RssFeed from .rss_feed import RssFeed
from .password import PasswordResetRequest, PasswordReset, ChangePassword from .password import PasswordResetRequest, PasswordReset, ChangePassword

View file

@ -7,30 +7,47 @@ from dateutil.parser import ParserError
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.http import HttpResponseBadRequest, HttpResponseNotFound from django.http import HttpResponseBadRequest, HttpResponseNotFound
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views import View
from django.views.decorators.http import require_POST from django.views.decorators.http import require_POST
from bookwyrm import models from bookwyrm import models
from .helpers import get_edition, handle_reading_status from .helpers import get_edition, handle_reading_status
from .shelf import handle_unshelve
@method_decorator(login_required, name="dispatch")
# pylint: disable=no-self-use # pylint: disable=no-self-use
@login_required class ReadingStatus(View):
@require_POST """consider reading a book"""
def start_reading(request, book_id):
"""begin reading a book""" def get(self, request, status, book_id):
"""modal page"""
book = get_edition(book_id) book = get_edition(book_id)
reading_shelf = models.Shelf.objects.filter( template = {
identifier=models.Shelf.READING, user=request.user "want": "want.html",
"start": "start.html",
"finish": "finish.html",
}.get(status)
if not template:
return HttpResponseNotFound()
return TemplateResponse(request, f"reading_progress/{template}", {"book": book})
def post(self, request, status, book_id):
"""desire a book"""
identifier = {
"want": models.Shelf.TO_READ,
"start": models.Shelf.READING,
"finish": models.Shelf.READ_FINISHED,
}.get(status)
if not identifier:
return HttpResponseBadRequest()
desired_shelf = models.Shelf.objects.filter(
identifier=identifier, user=request.user
).first() ).first()
# create a readthrough book = get_edition(book_id)
readthrough = update_readthrough(request, book=book)
if readthrough:
readthrough.save()
# create a progress update if we have a page
readthrough.create_update()
current_status_shelfbook = ( current_status_shelfbook = (
models.ShelfBook.objects.select_related("shelf") models.ShelfBook.objects.select_related("shelf")
@ -42,58 +59,25 @@ def start_reading(request, book_id):
.first() .first()
) )
if current_status_shelfbook is not None: if current_status_shelfbook is not None:
if current_status_shelfbook.shelf.identifier != models.Shelf.READING: if current_status_shelfbook.shelf.identifier != desired_shelf.identifier:
handle_unshelve(book, current_status_shelfbook.shelf) current_status_shelfbook.delete()
else: # It already was on the shelf else: # It already was on the shelf
return redirect(request.headers.get("Referer", "/")) return redirect(request.headers.get("Referer", "/"))
models.ShelfBook.objects.create(book=book, shelf=reading_shelf, user=request.user) models.ShelfBook.objects.create(
book=book, shelf=desired_shelf, user=request.user
# post about it (if you want) )
if request.POST.get("post-status"):
privacy = request.POST.get("privacy")
handle_reading_status(request.user, reading_shelf, book, privacy)
return redirect(request.headers.get("Referer", "/"))
@login_required
@require_POST
def finish_reading(request, book_id):
"""a user completed a book, yay"""
book = get_edition(book_id)
finished_read_shelf = models.Shelf.objects.filter(
identifier=models.Shelf.READ_FINISHED, user=request.user
).first()
if desired_shelf.identifier != models.Shelf.TO_READ:
# update or create a readthrough # update or create a readthrough
readthrough = update_readthrough(request, book=book) readthrough = update_readthrough(request, book=book)
if readthrough: if readthrough:
readthrough.save() readthrough.save()
current_status_shelfbook = (
models.ShelfBook.objects.select_related("shelf")
.filter(
shelf__identifier__in=models.Shelf.READ_STATUS_IDENTIFIERS,
user=request.user,
book=book,
)
.first()
)
if current_status_shelfbook is not None:
if current_status_shelfbook.shelf.identifier != models.Shelf.READ_FINISHED:
handle_unshelve(book, current_status_shelfbook.shelf)
else: # It already was on the shelf
return redirect(request.headers.get("Referer", "/"))
models.ShelfBook.objects.create(
book=book, shelf=finished_read_shelf, user=request.user
)
# post about it (if you want) # post about it (if you want)
if request.POST.get("post-status"): if request.POST.get("post-status"):
privacy = request.POST.get("privacy") privacy = request.POST.get("privacy")
handle_reading_status(request.user, finished_read_shelf, book, privacy) handle_reading_status(request.user, desired_shelf, book, privacy)
return redirect(request.headers.get("Referer", "/")) return redirect(request.headers.get("Referer", "/"))

View file

@ -178,11 +178,6 @@ def shelve(request):
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
book=book, shelf=desired_shelf, user=request.user book=book, shelf=desired_shelf, user=request.user
) )
if desired_shelf.identifier == models.Shelf.TO_READ and request.POST.get(
"post-status"
):
privacy = request.POST.get("privacy") or desired_shelf.privacy
handle_reading_status(request.user, desired_shelf, book, privacy=privacy)
else: else:
try: try:
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
@ -206,7 +201,6 @@ def unshelve(request):
return redirect(request.headers.get("Referer", "/")) return redirect(request.headers.get("Referer", "/"))
# pylint: disable=unused-argument
def handle_unshelve(book, shelf): def handle_unshelve(book, shelf):
"""unshelve a book""" """unshelve a book"""
row = models.ShelfBook.objects.get(book=book, shelf=shelf) row = models.ShelfBook.objects.get(book=book, shelf=shelf)

View file

@ -1,5 +1,5 @@
celery==4.4.2 celery==4.4.2
Django==3.2.1 Django==3.2.4
django-model-utils==4.0.0 django-model-utils==4.0.0
environs==7.2.0 environs==7.2.0
flower==0.9.4 flower==0.9.4

View file

@ -2042,9 +2042,9 @@ to-regex-range@^5.0.1:
is-number "^7.0.0" is-number "^7.0.0"
trim-newlines@^3.0.0: trim-newlines@^3.0.0:
version "3.0.0" version "3.0.1"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.0.tgz#79726304a6a898aa8373427298d54c2ee8b1cb30" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144"
integrity sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA== integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==
trough@^1.0.0: trough@^1.0.0:
version "1.0.5" version "1.0.5"