diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 448d55637..5e66077cb 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -65,7 +65,7 @@ class ActivityObject: try: value = kwargs[field.name] if value in (None, MISSING, {}): - raise KeyError() + raise KeyError("Missing required field", field.name) try: is_subclass = issubclass(field.type, ActivityObject) except TypeError: diff --git a/bookwyrm/migrations/0146_auto_20220316_2320.py b/bookwyrm/migrations/0146_auto_20220316_2320.py new file mode 100644 index 000000000..e50bf25ec --- /dev/null +++ b/bookwyrm/migrations/0146_auto_20220316_2320.py @@ -0,0 +1,80 @@ +# Generated by Django 3.2.12 on 2022-03-16 23:20 + +import bookwyrm.models.fields +from django.db import migrations +from bookwyrm.models import Shelf + + +def add_shelves(apps, schema_editor): + """add any superusers to the "admin" group""" + + db_alias = schema_editor.connection.alias + shelf_model = apps.get_model("bookwyrm", "Shelf") + + users = apps.get_model("bookwyrm", "User") + local_users = users.objects.using(db_alias).filter(local=True) + for user in local_users: + remote_id = f"{user.remote_id}/books/stopped" + shelf_model.objects.using(db_alias).create( + name="Stopped reading", + identifier=Shelf.STOPPED_READING, + user=user, + editable=False, + remote_id=remote_id, + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0145_sitesettings_version"), + ] + + operations = [ + migrations.AlterField( + model_name="comment", + name="reading_status", + field=bookwyrm.models.fields.CharField( + blank=True, + choices=[ + ("to-read", "To-Read"), + ("reading", "Reading"), + ("read", "Read"), + ("stopped-reading", "Stopped-Reading"), + ], + max_length=255, + null=True, + ), + ), + migrations.AlterField( + model_name="quotation", + name="reading_status", + field=bookwyrm.models.fields.CharField( + blank=True, + choices=[ + ("to-read", "To-Read"), + ("reading", "Reading"), + ("read", "Read"), + ("stopped-reading", "Stopped-Reading"), + ], + max_length=255, + null=True, + ), + ), + migrations.AlterField( + model_name="review", + name="reading_status", + field=bookwyrm.models.fields.CharField( + blank=True, + choices=[ + ("to-read", "To-Read"), + ("reading", "Reading"), + ("read", "Read"), + ("stopped-reading", "Stopped-Reading"), + ], + max_length=255, + null=True, + ), + ), + migrations.RunPython(add_shelves, reverse_code=migrations.RunPython.noop), + ] diff --git a/bookwyrm/migrations/0148_merge_20220326_2006.py b/bookwyrm/migrations/0148_merge_20220326_2006.py new file mode 100644 index 000000000..978662765 --- /dev/null +++ b/bookwyrm/migrations/0148_merge_20220326_2006.py @@ -0,0 +1,13 @@ +# Generated by Django 3.2.12 on 2022-03-26 20:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0146_auto_20220316_2320"), + ("bookwyrm", "0147_alter_user_preferred_language"), + ] + + operations = [] diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index 8ea274ea1..3291d5653 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -18,8 +18,9 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): TO_READ = "to-read" READING = "reading" READ_FINISHED = "read" + STOPPED_READING = "stopped-reading" - READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED) + READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED, STOPPED_READING) name = fields.CharField(max_length=100) identifier = models.CharField(max_length=100) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 17fcd4587..b933edce7 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -265,7 +265,7 @@ class GeneratedNote(Status): ReadingStatusChoices = models.TextChoices( - "ReadingStatusChoices", ["to-read", "reading", "read"] + "ReadingStatusChoices", ["to-read", "reading", "read", "stopped-reading"] ) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index be5c19922..dce74022c 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -374,6 +374,10 @@ class User(OrderedCollectionPageMixin, AbstractUser): "name": "Read", "identifier": "read", }, + { + "name": "Stopped Reading", + "identifier": "stopped-reading", + }, ] for shelf in shelves: diff --git a/bookwyrm/templates/get_started/book_preview.html b/bookwyrm/templates/get_started/book_preview.html index 8a20d0d77..9cfb56b00 100644 --- a/bookwyrm/templates/get_started/book_preview.html +++ b/bookwyrm/templates/get_started/book_preview.html @@ -10,6 +10,7 @@ {% if shelf.identifier == 'to-read' %}{% trans "To Read" %} {% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %} {% elif shelf.identifier == 'read' %}{% trans "Read" %} + {% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %} {% else %}{{ shelf.name }}{% endif %} {% endfor %} diff --git a/bookwyrm/templates/reading_progress/stop.html b/bookwyrm/templates/reading_progress/stop.html new file mode 100644 index 000000000..5811c09b6 --- /dev/null +++ b/bookwyrm/templates/reading_progress/stop.html @@ -0,0 +1,14 @@ +{% extends 'layout.html' %} +{% load i18n %} + +{% block title %} +{% blocktrans trimmed with book_title=book.title %} +Stop Reading "{{ book_title }}" +{% endblocktrans %} +{% endblock %} + +{% block content %} + +{% include "snippets/reading_modals/stop_reading_modal.html" with book=book active=True static=True %} + +{% endblock %} diff --git a/bookwyrm/templates/shelf/shelf.html b/bookwyrm/templates/shelf/shelf.html index cc4bb1436..b36dc01cb 100644 --- a/bookwyrm/templates/shelf/shelf.html +++ b/bookwyrm/templates/shelf/shelf.html @@ -86,6 +86,7 @@ {% if shelf.identifier == 'to-read' %}{% trans "To Read" %} {% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %} {% elif shelf.identifier == 'read' %}{% trans "Read" %} + {% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %} {% else %}{{ shelf.name }}{% endif %} {% include 'snippets/privacy-icons.html' with item=shelf %} @@ -150,7 +151,7 @@ {% if is_self %}