mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Save and display stopped date in readthrough
This commit is contained in:
parent
dfe0656eb4
commit
4c5d2570ab
4 changed files with 8 additions and 4 deletions
|
@ -35,7 +35,7 @@ class ReadThrough(BookWyrmModel):
|
|||
cache.delete(f"latest_read_through-{self.user.id}-{self.book.id}")
|
||||
self.user.update_active_date()
|
||||
# an active readthrough must have an unset finish date
|
||||
if self.finish_date:
|
||||
if self.finish_date or self.stopped_date:
|
||||
self.is_active = False
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
</label>
|
||||
{% include "snippets/progress_field.html" with id=field_id %}
|
||||
{% endif %}
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="id_finish_date_{{ readthrough.id }}">
|
||||
{% trans "Finished reading" %}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="column">
|
||||
{% trans "Progress Updates:" %}
|
||||
<ul>
|
||||
{% if readthrough.finish_date or readthrough.progress %}
|
||||
{% if readthrough.finish_date or readthrough.stopped_date or readthrough.progress %}
|
||||
<li>
|
||||
{% if readthrough.finish_date %}
|
||||
{{ readthrough.finish_date | localtime | naturalday }}: {% trans "finished" %}
|
||||
|
|
|
@ -92,6 +92,7 @@ class ReadingStatus(View):
|
|||
desired_shelf.identifier,
|
||||
start_date=request.POST.get("start_date"),
|
||||
finish_date=request.POST.get("finish_date"),
|
||||
stopped_date=request.POST.get("stopped_date"),
|
||||
)
|
||||
|
||||
# post about it (if you want)
|
||||
|
@ -160,8 +161,9 @@ class ReadThrough(View):
|
|||
|
||||
|
||||
@transaction.atomic
|
||||
# pylint: disable=too-many-arguments
|
||||
def update_readthrough_on_shelve(
|
||||
user, annotated_book, status, start_date=None, finish_date=None
|
||||
user, annotated_book, status, start_date=None, finish_date=None, stopped_date=None
|
||||
):
|
||||
"""update the current readthrough for a book when it is re-shelved"""
|
||||
# there *should* only be one of current active readthrough, but it's a list
|
||||
|
@ -183,8 +185,9 @@ def update_readthrough_on_shelve(
|
|||
)
|
||||
# santiize and set dates
|
||||
active_readthrough.start_date = load_date_in_user_tz_as_utc(start_date, user)
|
||||
# if the finish date is set, the readthrough will be automatically set as inactive
|
||||
# if the stop or finish date is set, the readthrough will be set as inactive
|
||||
active_readthrough.finish_date = load_date_in_user_tz_as_utc(finish_date, user)
|
||||
active_readthrough.stopped_date = load_date_in_user_tz_as_utc(stopped_date, user)
|
||||
|
||||
active_readthrough.save()
|
||||
|
||||
|
|
Loading…
Reference in a new issue