diff --git a/bookwyrm/activitypub/note.py b/bookwyrm/activitypub/note.py index aca62d7c5..d61471fe0 100644 --- a/bookwyrm/activitypub/note.py +++ b/bookwyrm/activitypub/note.py @@ -70,6 +70,8 @@ class Quotation(Comment): """a quote and commentary on a book""" quote: str + position: int = None + positionMode: str = None type: str = "Quotation" diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index e88124702..690526050 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -101,6 +101,8 @@ class QuotationForm(CustomForm): "content_warning", "sensitive", "privacy", + "position", + "position_mode", ] diff --git a/bookwyrm/migrations/0088_auto_20210905_2233.py b/bookwyrm/migrations/0088_auto_20210905_2233.py new file mode 100644 index 000000000..028cf7bf7 --- /dev/null +++ b/bookwyrm/migrations/0088_auto_20210905_2233.py @@ -0,0 +1,34 @@ +# Generated by Django 3.2.4 on 2021-09-05 22:33 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0087_merge_0086_auto_20210827_1727_0086_auto_20210828_1724"), + ] + + operations = [ + migrations.AddField( + model_name="quotation", + name="position", + field=models.IntegerField( + blank=True, + null=True, + validators=[django.core.validators.MinValueValidator(0)], + ), + ), + migrations.AddField( + model_name="quotation", + name="position_mode", + field=models.CharField( + blank=True, + choices=[("PG", "page"), ("PCT", "percent")], + default="PG", + max_length=3, + null=True, + ), + ), + ] diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 9274a5813..d0f094d22 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -290,6 +290,16 @@ class Quotation(BookStatus): """like a review but without a rating and transient""" quote = fields.HtmlField() + position = models.IntegerField( + validators=[MinValueValidator(0)], null=True, blank=True + ) + position_mode = models.CharField( + max_length=3, + choices=ProgressMode.choices, + default=ProgressMode.PAGE, + null=True, + blank=True, + ) @property def pure_content(self): diff --git a/bookwyrm/templates/snippets/create_status/comment.html b/bookwyrm/templates/snippets/create_status/comment.html index d830ddcbf..8f3f5c2b6 100644 --- a/bookwyrm/templates/snippets/create_status/comment.html +++ b/bookwyrm/templates/snippets/create_status/comment.html @@ -26,13 +26,32 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j
{{ status.quote|safe }}-
— {% include 'snippets/book_titleby.html' with book=status.book %}
++ — {% include 'snippets/book_titleby.html' with book=status.book %} + {% if status.position %} + {% if status.position_mode == 'PG' %} + {% blocktrans with page=status.position|intcomma %}(Page {{ page }}){% endblocktrans %} + {% else %} + {% blocktrans with percent=status.position %}({{ percent }}%){% endblocktrans %} + {% endif %} + {% endif %} +