diff --git a/bookwyrm/forms/forms.py b/bookwyrm/forms/forms.py index 9d8f9f39..4aa1e575 100644 --- a/bookwyrm/forms/forms.py +++ b/bookwyrm/forms/forms.py @@ -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"] diff --git a/bookwyrm/migrations/0149_merge_20220526_1716.py b/bookwyrm/migrations/0149_merge_20220526_1716.py new file mode 100644 index 00000000..b42bccd3 --- /dev/null +++ b/bookwyrm/migrations/0149_merge_20220526_1716.py @@ -0,0 +1,13 @@ +# Generated by Django 3.2.13 on 2022-05-26 17:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0148_alter_user_preferred_language"), + ("bookwyrm", "0148_merge_20220326_2006"), + ] + + operations = [] diff --git a/bookwyrm/migrations/0150_readthrough_stopped_date.py b/bookwyrm/migrations/0150_readthrough_stopped_date.py new file mode 100644 index 00000000..6ce2f89a --- /dev/null +++ b/bookwyrm/migrations/0150_readthrough_stopped_date.py @@ -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), + ), + ] diff --git a/bookwyrm/models/readthrough.py b/bookwyrm/models/readthrough.py index ceb8e0b6..314b40a5 100644 --- a/bookwyrm/models/readthrough.py +++ b/bookwyrm/models/readthrough.py @@ -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): @@ -34,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) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 416610e4..e16c576e 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _ env = Env() env.read_env() DOMAIN = env("DOMAIN") -VERSION = "0.3.4" +VERSION = "0.4.0" RELEASE_API = env( "RELEASE_API", @@ -21,7 +21,7 @@ RELEASE_API = env( PAGE_LENGTH = env("PAGE_LENGTH", 15) DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English") -JS_CACHE = "bc93172a" +JS_CACHE = "e678183b" # email EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend") diff --git a/bookwyrm/static/js/status_cache.js b/bookwyrm/static/js/status_cache.js index b19489c1..0a9f3abc 100644 --- a/bookwyrm/static/js/status_cache.js +++ b/bookwyrm/static/js/status_cache.js @@ -203,6 +203,8 @@ let StatusCache = new (class { .forEach((item) => (item.disabled = false)); next_identifier = next_identifier == "complete" ? "read" : next_identifier; + next_identifier = + next_identifier == "stopped-reading-complete" ? "stopped-reading" : next_identifier; // Disable the current state button.querySelector( diff --git a/bookwyrm/templates/readthrough/readthrough_form.html b/bookwyrm/templates/readthrough/readthrough_form.html index 1558dada..45c92043 100644 --- a/bookwyrm/templates/readthrough/readthrough_form.html +++ b/bookwyrm/templates/readthrough/readthrough_form.html @@ -19,6 +19,7 @@ {% include "snippets/progress_field.html" with id=field_id %} {% endif %} +