Adds stopped date separate from finish date on readthrough

This commit is contained in:
Mouse Reeve 2022-05-26 11:33:31 -07:00
parent 1f6fbd8d29
commit 375c5a8789
5 changed files with 29 additions and 3 deletions

View file

@ -53,7 +53,12 @@ class ReadThroughForm(CustomForm):
self.add_error(
"finish_date", _("Reading finish date cannot be before start date.")
)
stopped_date = cleaned_data.get("stopped_date")
if start_date and stopped_date and start_date > stopped_date:
self.add_error(
"stopped_date", _("Reading stopped date cannot be before start date.")
)
class Meta:
model = models.ReadThrough
fields = ["user", "book", "start_date", "finish_date"]
fields = ["user", "book", "start_date", "finish_date", "stopped_date"]

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2022-05-26 18:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0149_merge_20220526_1716"),
]
operations = [
migrations.AddField(
model_name="readthrough",
name="stopped_date",
field=models.DateTimeField(blank=True, null=True),
),
]

View file

@ -27,6 +27,7 @@ class ReadThrough(BookWyrmModel):
)
start_date = models.DateTimeField(blank=True, null=True)
finish_date = models.DateTimeField(blank=True, null=True)
stopped_date = models.DateTimeField(blank=True, null=True)
is_active = models.BooleanField(default=True)
def save(self, *args, **kwargs):

View file

@ -12,6 +12,8 @@
<li>
{% if readthrough.finish_date %}
{{ readthrough.finish_date | localtime | naturalday }}: {% trans "finished" %}
{% elif readthrough.stopped_date %}
{{ readthrough.stopped_date | localtime | naturalday }}: {% trans "stopped" %}
{% else %}
{% if readthrough.progress_mode == 'PG' %}

View file

@ -29,9 +29,9 @@ Stop Reading "<em>{{ book_title }}</em>"
<div class="column is-half">
<div class="field">
<label class="label" for="id_read_until_date_{{ uuid }}">
{% trans "Read until" %}
{% trans "Stopped reading" %}
</label>
<input type="date" name="finish_date" class="input" id="id_read_until_date_{{ uuid }}" value="{% now "Y-m-d" %}">
<input type="date" name="stopped_date" class="input" id="id_read_until_date_{{ uuid }}" value="{% now "Y-m-d" %}">
</div>
</div>
</div>