Rename 'Partially Read' to 'Stopped Reading'

This commit is contained in:
Thomas Versteeg 2022-02-12 19:44:06 +01:00
parent bc89dd7041
commit c88b34814f
17 changed files with 105 additions and 72 deletions

View file

@ -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),
),
]

View file

@ -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,
),
),
]

View file

@ -17,9 +17,9 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
TO_READ = "to-read" TO_READ = "to-read"
READING = "reading" READING = "reading"
READ_FINISHED = "read" 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) name = fields.CharField(max_length=100)
identifier = models.CharField(max_length=100) identifier = models.CharField(max_length=100)

View file

@ -265,7 +265,7 @@ class GeneratedNote(Status):
ReadingStatusChoices = models.TextChoices( ReadingStatusChoices = models.TextChoices(
"ReadingStatusChoices", ["to-read", "reading", "read", "partially-read"] "ReadingStatusChoices", ["to-read", "reading", "read", "stopped-reading"]
) )

View file

@ -373,8 +373,8 @@ class User(OrderedCollectionPageMixin, AbstractUser):
"identifier": "read", "identifier": "read",
}, },
{ {
"name": "Partially Read", "name": "Stopped Reading",
"identifier": "partially-read", "identifier": "stopped-reading",
}, },
] ]

View file

@ -10,7 +10,7 @@
{% if shelf.identifier == 'to-read' %}{% trans "To Read" %} {% if shelf.identifier == 'to-read' %}{% trans "To Read" %}
{% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %} {% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %}
{% elif shelf.identifier == 'read' %}{% trans "Read" %} {% 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 %} {% else %}{{ shelf.name }}{% endif %}
</option> </option>
{% endfor %} {% endfor %}

View file

@ -86,7 +86,7 @@
{% if shelf.identifier == 'to-read' %}{% trans "To Read" %} {% if shelf.identifier == 'to-read' %}{% trans "To Read" %}
{% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %} {% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %}
{% elif shelf.identifier == 'read' %}{% trans "Read" %} {% 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 %} {% else %}{{ shelf.name }}{% endif %}
<span class="subtitle"> <span class="subtitle">
{% include 'snippets/privacy-icons.html' with item=shelf %} {% include 'snippets/privacy-icons.html' with item=shelf %}

View file

@ -4,12 +4,12 @@
{% block modal-title %} {% block modal-title %}
{% blocktrans trimmed with book_title=book|book_title %} {% blocktrans trimmed with book_title=book|book_title %}
Partially Read "<em>{{ book_title }}</em>" Stop Reading "<em>{{ book_title }}</em>"
{% endblocktrans %} {% endblocktrans %}
{% endblock %} {% endblock %}
{% block modal-form-open %} {% block modal-form-open %}
<form name="partially-read-{{ uuid }}" action="{% url 'reading-status' 'stop' book.id %}" method="post" {% if not refresh %}class="submit-status"{% endif %}> <form name="stop-reading-{{ uuid }}" action="{% url 'reading-status' 'stop' book.id %}" method="post" {% if not refresh %}class="submit-status"{% endif %}>
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}"> <input type="hidden" name="id" value="{{ readthrough.id }}">
<input type="hidden" name="reading_status" value="stop"> <input type="hidden" name="reading_status" value="stop">
@ -38,5 +38,5 @@ Partially Read "<em>{{ book_title }}</em>"
{% endblock %} {% endblock %}
{% block form %} {% 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 %} {% endblock %}

View file

@ -49,11 +49,11 @@
{% join "finish_reading" uuid as modal_id %} {% join "finish_reading" uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=button_class fallback_url=fallback_url %} {% 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 %} {% 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 %} {% include 'snippets/shelve_button/modal_button.html' with class=button_class fallback_url=fallback_url %}
{% elif shelf.identifier == 'to-read' %} {% elif shelf.identifier == 'to-read' %}
@ -104,8 +104,8 @@
{% join "finish_reading" uuid as modal_id %} {% 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="" %} {% 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 %} {% join "stop_reading" 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="" %} {% 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 %} {% endwith %}
{% endblock %} {% endblock %}

View file

@ -29,8 +29,8 @@
{% join "finish_reading" uuid as modal_id %} {% 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="" %} {% 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 %} {% join "stop_reading" uuid as modal_id %}
{% include 'snippets/reading_modals/partially_read_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %} {% 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 %} {% 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="" %} {% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %}

View file

@ -26,11 +26,11 @@
{% join "finish_reading" button_uuid as modal_id %} {% join "finish_reading" button_uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} {% 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 %} {% 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 %} {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %}
{% elif shelf.identifier == 'to-read' %} {% elif shelf.identifier == 'to-read' %}

View file

@ -33,11 +33,11 @@
{% join "finish_reading" button_uuid as modal_id %} {% join "finish_reading" button_uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} {% 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 %} {% trans "Stop reading" as button_text %}
{% url 'reading-status' 'stop' book.id as fallback_url %} {% 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 %} {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %}
{% elif shelf.identifier == 'to-read' %} {% elif shelf.identifier == 'to-read' %}

View file

@ -7,8 +7,8 @@
{% trans "Currently Reading" %} {% trans "Currently Reading" %}
{% elif shelf.identifier == 'read' %} {% elif shelf.identifier == 'read' %}
{% trans "Read" %} {% trans "Read" %}
{% elif shelf.identifier == 'partially-read' %} {% elif shelf.identifier == 'stopped-reading' %}
{% trans "Partially Read" %} {% trans "Stopped Reading" %}
{% else %} {% else %}
{{ shelf.name }} {{ shelf.name }}
{% endif %} {% endif %}

View file

@ -33,7 +33,7 @@
{% if shelf.name == 'To Read' %}{% trans "To Read" %} {% if shelf.name == 'To Read' %}{% trans "To Read" %}
{% elif shelf.name == 'Currently Reading' %}{% trans "Currently Reading" %} {% elif shelf.name == 'Currently Reading' %}{% trans "Currently Reading" %}
{% elif shelf.name == 'Read' %}{% trans "Read" %} {% 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 %} {% else %}{{ shelf.name }}{% endif %}
{% if shelf.size > 4 %}<small>(<a href="{{ shelf.local_path }}">{% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}</a>)</small>{% endif %} {% if shelf.size > 4 %}<small>(<a href="{{ shelf.local_path }}">{% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}</a>)</small>{% endif %}
</h3> </h3>

View file

@ -36,7 +36,8 @@ def get_next_shelf(current_shelf):
def active_shelf(context, book): def active_shelf(context, book):
"""check what shelf a user has a book on, if any""" """check what shelf a user has a book on, if any"""
user = context["request"].user user = context["request"].user
return cache.get_or_set( return (
cache.get_or_set(
f"active_shelf-{user.id}-{book.id}", f"active_shelf-{user.id}-{book.id}",
lambda u, b: ( lambda u, b: (
models.ShelfBook.objects.filter( models.ShelfBook.objects.filter(
@ -48,7 +49,9 @@ def active_shelf(context, book):
user, user,
book, book,
timeout=15552000, timeout=15552000,
) or {"book": book} )
or {"book": book}
)
@register.simple_tag(takes_context=False) @register.simple_tag(takes_context=False)

View file

@ -58,12 +58,12 @@ class User(TestCase):
self.assertTrue("To Read" in names) self.assertTrue("To Read" in names)
self.assertTrue("Currently Reading" in names) self.assertTrue("Currently Reading" in names)
self.assertTrue("Read" 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] ids = [s.identifier for s in shelves]
self.assertTrue("to-read" in ids) self.assertTrue("to-read" in ids)
self.assertTrue("reading" in ids) self.assertTrue("reading" in ids)
self.assertTrue("read" in ids) self.assertTrue("read" in ids)
self.assertTrue("partially-read" in ids) self.assertTrue("stopped-reading" in ids)
def test_activitypub_serialize(self): def test_activitypub_serialize(self):
activity = self.user.to_activity() activity = self.user.to_activity()

View file

@ -42,7 +42,7 @@ class ReadingStatus(View):
"want": models.Shelf.TO_READ, "want": models.Shelf.TO_READ,
"start": models.Shelf.READING, "start": models.Shelf.READING,
"finish": models.Shelf.READ_FINISHED, "finish": models.Shelf.READ_FINISHED,
"stop": models.Shelf.PARTIALLY_READ, "stop": models.Shelf.STOPPED_READING,
}.get(status) }.get(status)
if not identifier: if not identifier:
return HttpResponseBadRequest() return HttpResponseBadRequest()