From c88b34814f2530b5d14197c89743a00a31cebfb0 Mon Sep 17 00:00:00 2001 From: Thomas Versteeg Date: Sat, 12 Feb 2022 19:44:06 +0100 Subject: [PATCH] Rename 'Partially Read' to 'Stopped Reading' --- .../migrations/0134_alter_partially_read.py | 29 --------- .../migrations/0134_alter_stopped_reading.py | 59 +++++++++++++++++++ bookwyrm/models/shelf.py | 4 +- bookwyrm/models/status.py | 2 +- bookwyrm/models/user.py | 4 +- .../templates/get_started/book_preview.html | 2 +- bookwyrm/templates/shelf/shelf.html | 6 +- ...ead_modal.html => stop_reading_modal.html} | 6 +- .../templates/snippets/shelf_selector.html | 10 ++-- .../snippets/shelve_button/shelve_button.html | 4 +- .../shelve_button_dropdown_options.html | 6 +- .../shelve_button/shelve_button_options.html | 4 +- .../snippets/translated_shelf_name.html | 4 +- bookwyrm/templates/user/user.html | 2 +- bookwyrm/templatetags/shelf_tags.py | 29 +++++---- bookwyrm/tests/models/test_user_model.py | 4 +- bookwyrm/views/reading.py | 2 +- 17 files changed, 105 insertions(+), 72 deletions(-) delete mode 100644 bookwyrm/migrations/0134_alter_partially_read.py create mode 100644 bookwyrm/migrations/0134_alter_stopped_reading.py rename bookwyrm/templates/snippets/reading_modals/{partially_read_modal.html => stop_reading_modal.html} (85%) diff --git a/bookwyrm/migrations/0134_alter_partially_read.py b/bookwyrm/migrations/0134_alter_partially_read.py deleted file mode 100644 index 85e9ed9f..00000000 --- a/bookwyrm/migrations/0134_alter_partially_read.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 3.2.11 on 2022-02-11 13:19 - -import bookwyrm.models.fields -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('bookwyrm', '0133_alter_listitem_notes'), - ] - - 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'), ('partially-read', 'Partially-Read')], 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'), ('partially-read', 'Partially-Read')], 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'), ('partially-read', 'Partially-Read')], max_length=255, null=True), - ), - ] diff --git a/bookwyrm/migrations/0134_alter_stopped_reading.py b/bookwyrm/migrations/0134_alter_stopped_reading.py new file mode 100644 index 00000000..c0c2c652 --- /dev/null +++ b/bookwyrm/migrations/0134_alter_stopped_reading.py @@ -0,0 +1,59 @@ +# Generated by Django 3.2.11 on 2022-02-11 13:19 + +import bookwyrm.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0133_alter_listitem_notes"), + ] + + 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, + ), + ), + ] diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index 4c57eb96..14bb45c3 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -17,9 +17,9 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): TO_READ = "to-read" READING = "reading" READ_FINISHED = "read" - PARTIALLY_READ = "partially-read" + STOPPED_READING = "stopped-reading" - READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED, PARTIALLY_READ) + 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 99756df5..66fd76aa 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", "partially-read"] + "ReadingStatusChoices", ["to-read", "reading", "read", "stopped-reading"] ) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 223bad0f..157b5f88 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -373,8 +373,8 @@ class User(OrderedCollectionPageMixin, AbstractUser): "identifier": "read", }, { - "name": "Partially Read", - "identifier": "partially-read", + "name": "Stopped Reading", + "identifier": "stopped-reading", }, ] diff --git a/bookwyrm/templates/get_started/book_preview.html b/bookwyrm/templates/get_started/book_preview.html index 51a5a4e6..9cfb56b0 100644 --- a/bookwyrm/templates/get_started/book_preview.html +++ b/bookwyrm/templates/get_started/book_preview.html @@ -10,7 +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 == 'partially-read' %}{% trans "Partially Read" %} + {% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %} {% else %}{{ shelf.name }}{% endif %} {% endfor %} diff --git a/bookwyrm/templates/shelf/shelf.html b/bookwyrm/templates/shelf/shelf.html index 2a980e15..b36dc01c 100644 --- a/bookwyrm/templates/shelf/shelf.html +++ b/bookwyrm/templates/shelf/shelf.html @@ -86,7 +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 == 'partially-read' %}{% trans "Partially Read" %} + {% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %} {% else %}{{ shelf.name }}{% endif %} {% include 'snippets/privacy-icons.html' with item=shelf %} @@ -151,7 +151,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 %} + {% 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 %} {% endif %} {% trans "Rating" as text %}{% include 'snippets/table-sort-header.html' with field="rating" sort=sort text=text %} {% endif %} @@ -181,7 +181,7 @@ {{ book.start_date|naturalday|default_if_none:""}} - + {{ book.finish_date|naturalday|default_if_none:""}} {% endif %} diff --git a/bookwyrm/templates/snippets/reading_modals/partially_read_modal.html b/bookwyrm/templates/snippets/reading_modals/stop_reading_modal.html similarity index 85% rename from bookwyrm/templates/snippets/reading_modals/partially_read_modal.html rename to bookwyrm/templates/snippets/reading_modals/stop_reading_modal.html index 2260f8c1..163a3415 100644 --- a/bookwyrm/templates/snippets/reading_modals/partially_read_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/stop_reading_modal.html @@ -4,12 +4,12 @@ {% block modal-title %} {% blocktrans trimmed with book_title=book|book_title %} -Partially Read "{{ book_title }}" +Stop Reading "{{ book_title }}" {% endblocktrans %} {% endblock %} {% block modal-form-open %} -
+ {% csrf_token %} @@ -38,5 +38,5 @@ Partially Read "{{ book_title }}" {% endblock %} {% block form %} -{% include "snippets/reading_modals/form.html" with optional=True type="partially_read_model" %} +{% 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 7589ffc6..ef245cec 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -49,11 +49,11 @@ {% 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 == 'partially-read' %} +{% elif shelf.identifier == 'stopped-reading' %} -{% trans "Partially read" as button_text %} +{% trans "Stopped reading" as button_text %} {% url 'reading-status' 'stop' book.id as fallback_url %} -{% join "partially_read" uuid as modal_id %} +{% 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' %} @@ -104,8 +104,8 @@ {% 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 "partially_read" uuid as modal_id %} -{% include 'snippets/reading_modals/partially_read_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 6944db6a..010bff05 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button.html @@ -29,8 +29,8 @@ {% 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 "partially_read" uuid as modal_id %} -{% include 'snippets/reading_modals/partially_read_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 23e5f4a4..236c0797 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -26,11 +26,11 @@ {% 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 == 'partially-read' %} + {% elif shelf.identifier == 'stopped-reading' %} - {% trans "Partially read" as button_text %} + {% trans "Stop reading" as button_text %} {% url 'reading-status' 'stop' book.id as fallback_url %} - {% join "partially_read" button_uuid as modal_id %} + {% 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' %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html index 0a711add..fb7ee452 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html @@ -33,11 +33,11 @@ {% 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 == 'partially-read' %} + {% elif shelf.identifier == 'stopped-reading' %} {% trans "Stop reading" as button_text %} {% url 'reading-status' 'stop' book.id as fallback_url %} - {% join "partially_read" button_uuid as modal_id %} + {% 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' %} diff --git a/bookwyrm/templates/snippets/translated_shelf_name.html b/bookwyrm/templates/snippets/translated_shelf_name.html index dc1c579b..763ca854 100644 --- a/bookwyrm/templates/snippets/translated_shelf_name.html +++ b/bookwyrm/templates/snippets/translated_shelf_name.html @@ -7,8 +7,8 @@ {% trans "Currently Reading" %} {% elif shelf.identifier == 'read' %} {% trans "Read" %} -{% elif shelf.identifier == 'partially-read' %} - {% trans "Partially Read" %} +{% elif shelf.identifier == 'stopped-reading' %} + {% trans "Stopped Reading" %} {% else %} {{ shelf.name }} {% endif %} diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index 8d7fd31a..af85159f 100755 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -33,7 +33,7 @@ {% 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 == 'Partially Read' %}{% trans "Partially 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 %} diff --git a/bookwyrm/templatetags/shelf_tags.py b/bookwyrm/templatetags/shelf_tags.py index 6c4f59c3..7aef638f 100644 --- a/bookwyrm/templatetags/shelf_tags.py +++ b/bookwyrm/templatetags/shelf_tags.py @@ -36,19 +36,22 @@ def get_next_shelf(current_shelf): def active_shelf(context, book): """check what shelf a user has a book on, if any""" user = context["request"].user - return cache.get_or_set( - f"active_shelf-{user.id}-{book.id}", - lambda u, b: ( - models.ShelfBook.objects.filter( - shelf__user=u, - book__parent_work__editions=b, - ).first() - or False - ), - user, - book, - timeout=15552000, - ) or {"book": book} + return ( + cache.get_or_set( + f"active_shelf-{user.id}-{book.id}", + lambda u, b: ( + models.ShelfBook.objects.filter( + shelf__user=u, + book__parent_work__editions=b, + ).first() + or False + ), + user, + book, + timeout=15552000, + ) + or {"book": book} + ) @register.simple_tag(takes_context=False) diff --git a/bookwyrm/tests/models/test_user_model.py b/bookwyrm/tests/models/test_user_model.py index 8d343963..e4395e2f 100644 --- a/bookwyrm/tests/models/test_user_model.py +++ b/bookwyrm/tests/models/test_user_model.py @@ -58,12 +58,12 @@ class User(TestCase): self.assertTrue("To Read" in names) self.assertTrue("Currently Reading" in names) self.assertTrue("Read" in names) - self.assertTrue("Partially 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("partially-read" in ids) + self.assertTrue("stopped-reading" in ids) def test_activitypub_serialize(self): activity = self.user.to_activity() diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index b80bc50d..3cd153d2 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -42,7 +42,7 @@ class ReadingStatus(View): "want": models.Shelf.TO_READ, "start": models.Shelf.READING, "finish": models.Shelf.READ_FINISHED, - "stop": models.Shelf.PARTIALLY_READ, + "stop": models.Shelf.STOPPED_READING, }.get(status) if not identifier: return HttpResponseBadRequest()