Post-processes statuses composed in modals
This commit is contained in:
@ -18,7 +18,7 @@ from bookwyrm.sanitize_html import InputHtmlParser
|
||||
from bookwyrm.settings import DOMAIN
|
||||
from bookwyrm.utils import regex
|
||||
from .helpers import handle_remote_webfinger, is_api_request
|
||||
from .reading import edit_readthrough
|
||||
from .helpers import load_date_in_user_tz_as_utc
|
||||
|
||||
|
||||
# pylint: disable= no-self-use
|
||||
@ -145,6 +145,45 @@ def update_progress(request, book_id): # pylint: disable=unused-argument
|
||||
return edit_readthrough(request)
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def edit_readthrough(request):
|
||||
"""can't use the form because the dates are too finnicky"""
|
||||
readthrough = get_object_or_404(models.ReadThrough, id=request.POST.get("id"))
|
||||
readthrough.raise_not_editable(request.user)
|
||||
|
||||
readthrough.start_date = load_date_in_user_tz_as_utc(
|
||||
request.POST.get("start_date"), request.user
|
||||
)
|
||||
readthrough.finish_date = load_date_in_user_tz_as_utc(
|
||||
request.POST.get("finish_date"), request.user
|
||||
)
|
||||
|
||||
progress = request.POST.get("progress")
|
||||
try:
|
||||
progress = int(progress)
|
||||
readthrough.progress = progress
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
progress_mode = request.POST.get("progress_mode")
|
||||
try:
|
||||
progress_mode = models.ProgressMode(progress_mode)
|
||||
readthrough.progress_mode = progress_mode
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
readthrough.save()
|
||||
|
||||
# record the progress update individually
|
||||
# use default now for date field
|
||||
readthrough.create_update()
|
||||
|
||||
if is_api_request(request):
|
||||
return HttpResponse()
|
||||
return redirect(request.headers.get("Referer", "/"))
|
||||
|
||||
|
||||
def find_mentions(content):
|
||||
"""detect @mentions in raw status content"""
|
||||
if not content:
|
||||
|
Reference in New Issue
Block a user