From 6a68f07b0bf44625c2e7d223d762b217c09dad30 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 26 May 2022 10:12:06 -0700 Subject: [PATCH] Revert "Stopped shelf" --- bookwyrm/activitypub/base_activity.py | 2 +- .../migrations/0146_auto_20220316_2320.py | 80 ------------------- .../migrations/0148_merge_20220326_2006.py | 13 --- bookwyrm/models/shelf.py | 3 +- bookwyrm/models/status.py | 2 +- bookwyrm/models/user.py | 4 - .../templates/get_started/book_preview.html | 1 - bookwyrm/templates/reading_progress/stop.html | 14 ---- bookwyrm/templates/shelf/shelf.html | 5 +- .../reading_modals/stop_reading_modal.html | 42 ---------- .../templates/snippets/shelf_selector.html | 10 --- .../snippets/shelve_button/shelve_button.html | 3 - .../shelve_button_dropdown_options.html | 7 -- .../shelve_button/shelve_button_options.html | 7 -- bookwyrm/templates/user/user.html | 3 +- bookwyrm/tests/models/test_user_model.py | 4 +- bookwyrm/urls.py | 2 +- bookwyrm/views/helpers.py | 1 - bookwyrm/views/reading.py | 2 - 19 files changed, 8 insertions(+), 197 deletions(-) delete mode 100644 bookwyrm/migrations/0146_auto_20220316_2320.py delete mode 100644 bookwyrm/migrations/0148_merge_20220326_2006.py delete mode 100644 bookwyrm/templates/reading_progress/stop.html delete mode 100644 bookwyrm/templates/snippets/reading_modals/stop_reading_modal.html diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index 5e66077c..448d5563 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("Missing required field", field.name) + raise KeyError() 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 deleted file mode 100644 index e50bf25e..00000000 --- a/bookwyrm/migrations/0146_auto_20220316_2320.py +++ /dev/null @@ -1,80 +0,0 @@ -# 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 deleted file mode 100644 index 97866276..00000000 --- a/bookwyrm/migrations/0148_merge_20220326_2006.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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 3291d565..8ea274ea 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -18,9 +18,8 @@ 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, STOPPED_READING) + READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED) 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 b933edce..17fcd458 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", "stopped-reading"] + "ReadingStatusChoices", ["to-read", "reading", "read"] ) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index dce74022..be5c1992 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -374,10 +374,6 @@ 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 9cfb56b0..8a20d0d7 100644 --- a/bookwyrm/templates/get_started/book_preview.html +++ b/bookwyrm/templates/get_started/book_preview.html @@ -10,7 +10,6 @@ {% 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 deleted file mode 100644 index 5811c09b..00000000 --- a/bookwyrm/templates/reading_progress/stop.html +++ /dev/null @@ -1,14 +0,0 @@ -{% 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 b36dc01c..cc4bb143 100644 --- a/bookwyrm/templates/shelf/shelf.html +++ b/bookwyrm/templates/shelf/shelf.html @@ -86,7 +86,6 @@ {% 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 %} @@ -151,7 +150,7 @@ {% if is_self %} {% trans "Shelved" as text %}{% include 'snippets/table-sort-header.html' with field="shelved_date" sort=sort text=text %} {% trans "Started" as text %}{% include 'snippets/table-sort-header.html' with field="start_date" sort=sort text=text %} - {% if shelf.identifier == 'read' %}{% trans "Finished" as text %}{% else %}{% trans "Until" as text %}{% endif %}{% include 'snippets/table-sort-header.html' with field="finish_date" sort=sort text=text %} + {% trans "Finished" as text %}{% include 'snippets/table-sort-header.html' with field="finish_date" sort=sort text=text %} {% endif %} {% trans "Rating" as text %}{% include 'snippets/table-sort-header.html' with field="rating" sort=sort text=text %} {% endif %} @@ -181,7 +180,7 @@ {{ book.start_date|naturalday|default_if_none:""}} - + {{ book.finish_date|naturalday|default_if_none:""}} {% endif %} diff --git a/bookwyrm/templates/snippets/reading_modals/stop_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/stop_reading_modal.html deleted file mode 100644 index 80fb2d5b..00000000 --- a/bookwyrm/templates/snippets/reading_modals/stop_reading_modal.html +++ /dev/null @@ -1,42 +0,0 @@ -{% extends 'snippets/reading_modals/layout.html' %} -{% load i18n %} -{% load utilities %} - -{% block modal-title %} -{% blocktrans trimmed with book_title=book|book_title %} -Stop Reading "{{ book_title }}" -{% endblocktrans %} -{% endblock %} - -{% block modal-form-open %} -
-{% csrf_token %} - - - -{% endblock %} - -{% block reading-dates %} -
-
-
- - -
-
-
-
- - -
-
-
-{% endblock %} - -{% block form %} -{% include "snippets/reading_modals/form.html" with optional=True type="stop_modal" %} -{% endblock %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index feea50d7..2d1f2a83 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -49,13 +49,6 @@ {% join "finish_reading" uuid as modal_id %} {% include 'snippets/shelve_button/modal_button.html' with class=button_class fallback_url=fallback_url %} -{% elif shelf.identifier == 'stopped-reading' %} - -{% trans "Stopped reading" as button_text %} -{% url 'reading-status' 'stop' book.id as fallback_url %} -{% join "stop_reading" uuid as modal_id %} -{% include 'snippets/shelve_button/modal_button.html' with class=button_class fallback_url=fallback_url %} - {% elif shelf.identifier == 'to-read' %} {% trans "Want to read" as button_text %} @@ -106,8 +99,5 @@ {% join "finish_reading" uuid as modal_id %} {% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book id=modal_id move_from=current.id readthrough=readthrough refresh=True class="" %} -{% join "stop_reading" uuid as modal_id %} -{% include 'snippets/reading_modals/stop_reading_modal.html' with book=active_shelf.book id=modal_id move_from=current.id readthrough=readthrough refresh=True class="" %} - {% endwith %} {% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button.html b/bookwyrm/templates/snippets/shelve_button/shelve_button.html index 010bff05..04dc4e4b 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button.html @@ -29,9 +29,6 @@ {% join "finish_reading" uuid as modal_id %} {% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %} -{% join "stop_reading" uuid as modal_id %} -{% include 'snippets/reading_modals/stop_reading_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %} - {% join "progress_update" uuid as modal_id %} {% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html index 50d3e257..2b87e21f 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -26,13 +26,6 @@ {% join "finish_reading" button_uuid as modal_id %} {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} - {% elif shelf.identifier == 'stopped-reading' %} - - {% trans "Stop reading" as button_text %} - {% url 'reading-status' 'stop' book.id as fallback_url %} - {% join "stop_reading" button_uuid as modal_id %} - {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} - {% elif shelf.identifier == 'to-read' %} {% trans "Want to read" as button_text %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html index fb7ee452..04f4bdc2 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html @@ -33,13 +33,6 @@ {% join "finish_reading" button_uuid as modal_id %} {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} - {% elif shelf.identifier == 'stopped-reading' %} - - {% trans "Stop reading" as button_text %} - {% url 'reading-status' 'stop' book.id as fallback_url %} - {% join "stop_reading" button_uuid as modal_id %} - {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} - {% elif shelf.identifier == 'to-read' %} {% trans "Want to read" as button_text %} diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index af85159f..ccc4a44e 100755 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -33,9 +33,8 @@ {% if shelf.name == 'To Read' %}{% trans "To Read" %} {% elif shelf.name == 'Currently Reading' %}{% trans "Currently Reading" %} {% elif shelf.name == 'Read' %}{% trans "Read" %} - {% elif shelf.name == 'Stopped Reading' %}{% trans "Stopped Reading" %} {% else %}{{ shelf.name }}{% endif %} - {% if shelf.size > 4 %}({% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}){% endif %} + {% if shelf.size > 3 %}({% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}){% endif %}
{% for book in shelf.books %} diff --git a/bookwyrm/tests/models/test_user_model.py b/bookwyrm/tests/models/test_user_model.py index 37e2192b..adcee8fb 100644 --- a/bookwyrm/tests/models/test_user_model.py +++ b/bookwyrm/tests/models/test_user_model.py @@ -53,17 +53,15 @@ class User(TestCase): def test_user_shelves(self): shelves = models.Shelf.objects.filter(user=self.user).all() - self.assertEqual(len(shelves), 4) + self.assertEqual(len(shelves), 3) names = [s.name for s in shelves] self.assertTrue("To Read" in names) self.assertTrue("Currently Reading" in names) self.assertTrue("Read" in names) - self.assertTrue("Stopped Reading" in names) ids = [s.identifier for s in shelves] self.assertTrue("to-read" in ids) self.assertTrue("reading" in ids) self.assertTrue("read" in ids) - self.assertTrue("stopped-reading" in ids) def test_activitypub_serialize(self): activity = self.user.to_activity() diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 5abacae1..bb4cbbe2 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -622,7 +622,7 @@ urlpatterns = [ name="reading-status-update", ), re_path( - r"^reading-status/(?Pwant|start|finish|stop)/(?P\d+)/?$", + r"^reading-status/(?Pwant|start|finish)/(?P\d+)/?$", views.ReadingStatus.as_view(), name="reading-status", ), diff --git a/bookwyrm/views/helpers.py b/bookwyrm/views/helpers.py index 7d8eced7..a2c4b20d 100644 --- a/bookwyrm/views/helpers.py +++ b/bookwyrm/views/helpers.py @@ -138,7 +138,6 @@ def handle_reading_status(user, shelf, book, privacy): "to-read": "wants to read", "reading": "started reading", "read": "finished reading", - "stopped-reading": "stopped reading", }[shelf.identifier] except KeyError: # it's a non-standard shelf, don't worry about it diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 3cd153d2..2cd05202 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -29,7 +29,6 @@ class ReadingStatus(View): "want": "want.html", "start": "start.html", "finish": "finish.html", - "stop": "stop.html", }.get(status) if not template: return HttpResponseNotFound() @@ -42,7 +41,6 @@ class ReadingStatus(View): "want": models.Shelf.TO_READ, "start": models.Shelf.READING, "finish": models.Shelf.READ_FINISHED, - "stop": models.Shelf.STOPPED_READING, }.get(status) if not identifier: return HttpResponseBadRequest()