diff --git a/bookwyrm/migrations/0134_alter_partially_read.py b/bookwyrm/migrations/0134_alter_partially_read.py new file mode 100644 index 000000000..85e9ed9f8 --- /dev/null +++ b/bookwyrm/migrations/0134_alter_partially_read.py @@ -0,0 +1,29 @@ +# 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/models/shelf.py b/bookwyrm/models/shelf.py index 320d495d2..4c57eb96c 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -17,8 +17,9 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): TO_READ = "to-read" READING = "reading" READ_FINISHED = "read" + PARTIALLY_READ = "partially-read" - READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED) + READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED, PARTIALLY_READ) 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 29b3ba9cc..99756df51 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", "partially-read"] ) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 6367dcaef..223bad0fa 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -372,6 +372,10 @@ class User(OrderedCollectionPageMixin, AbstractUser): "name": "Read", "identifier": "read", }, + { + "name": "Partially Read", + "identifier": "partially-read", + }, ] for shelf in shelves: diff --git a/bookwyrm/templates/get_started/book_preview.html b/bookwyrm/templates/get_started/book_preview.html index 8a20d0d77..51a5a4e6e 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 == 'partially-read' %}{% trans "Partially Read" %} {% else %}{{ shelf.name }}{% endif %} {% endfor %} diff --git a/bookwyrm/templates/shelf/shelf.html b/bookwyrm/templates/shelf/shelf.html index cc4bb1436..67faf0a48 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 == 'partially-read' %}{% trans "Partially Read" %} {% else %}{{ shelf.name }}{% endif %} {% include 'snippets/privacy-icons.html' with item=shelf %} diff --git a/bookwyrm/templates/snippets/reading_modals/partially_read_modal.html b/bookwyrm/templates/snippets/reading_modals/partially_read_modal.html new file mode 100644 index 000000000..60c39c408 --- /dev/null +++ b/bookwyrm/templates/snippets/reading_modals/partially_read_modal.html @@ -0,0 +1,42 @@ +{% extends 'snippets/reading_modals/layout.html' %} +{% load i18n %} +{% load utilities %} + +{% block modal-title %} +{% blocktrans trimmed with book_title=book|book_title %} +Partially Read "{{ 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="partially_read_model" %} +{% endblock %} diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index 197cf5b6c..7589ffc61 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -49,6 +49,13 @@ {% 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' %} + +{% trans "Partially read" as button_text %} +{% url 'reading-status' 'stop' book.id as fallback_url %} +{% join "partially_read" 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 %} @@ -97,5 +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="" %} + {% endwith %} {% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button.html b/bookwyrm/templates/snippets/shelve_button/shelve_button.html index 04dc4e4b0..6944db6af 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button.html @@ -29,6 +29,9 @@ {% 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 "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 1fa26a886..23e5f4a44 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -26,6 +26,13 @@ {% 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' %} + + {% trans "Partially read" as button_text %} + {% url 'reading-status' 'stop' book.id as fallback_url %} + {% join "partially_read" 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 04f4bdc26..0a711addd 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_options.html @@ -33,6 +33,13 @@ {% 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' %} + + {% trans "Stop reading" as button_text %} + {% url 'reading-status' 'stop' book.id as fallback_url %} + {% join "partially_read" 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/translated_shelf_name.html b/bookwyrm/templates/snippets/translated_shelf_name.html index 4da47e370..dc1c579b3 100644 --- a/bookwyrm/templates/snippets/translated_shelf_name.html +++ b/bookwyrm/templates/snippets/translated_shelf_name.html @@ -7,6 +7,8 @@ {% trans "Currently Reading" %} {% elif shelf.identifier == 'read' %} {% trans "Read" %} +{% elif shelf.identifier == 'partially-read' %} + {% trans "Partially Read" %} {% else %} {{ shelf.name }} {% endif %} diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index ccc4a44ea..8d7fd31a2 100755 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -33,8 +33,9 @@ {% 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" %} {% else %}{{ shelf.name }}{% endif %} - {% if shelf.size > 3 %}({% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}){% endif %} + {% if shelf.size > 4 %}({% 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 aa62dce3a..8d3439632 100644 --- a/bookwyrm/tests/models/test_user_model.py +++ b/bookwyrm/tests/models/test_user_model.py @@ -58,10 +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) 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) def test_activitypub_serialize(self): activity = self.user.to_activity() diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 79d868c95..670610bd7 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -543,7 +543,7 @@ urlpatterns = [ name="reading-status-update", ), re_path( - r"^reading-status/(?Pwant|start|finish)/(?P\d+)/?$", + r"^reading-status/(?Pwant|start|finish|stop)/(?P\d+)/?$", views.ReadingStatus.as_view(), name="reading-status", ), diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 2cd05202c..b80bc50df 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -29,6 +29,7 @@ class ReadingStatus(View): "want": "want.html", "start": "start.html", "finish": "finish.html", + "stop": "stop.html", }.get(status) if not template: return HttpResponseNotFound() @@ -41,6 +42,7 @@ class ReadingStatus(View): "want": models.Shelf.TO_READ, "start": models.Shelf.READING, "finish": models.Shelf.READ_FINISHED, + "stop": models.Shelf.PARTIALLY_READ, }.get(status) if not identifier: return HttpResponseBadRequest()