From f085315d70d7cbb7f772b51ef6cb8cce8d6f42a2 Mon Sep 17 00:00:00 2001 From: Giebisch Date: Mon, 30 Jan 2023 16:12:14 +0100 Subject: [PATCH] Added Backend Part --- bookwyrm/forms/status.py | 1 + .../migrations/0174_auto_20230130_1240.py | 26 +++++++++++++++++++ bookwyrm/models/status.py | 3 +++ .../snippets/create_status/quotation.html | 13 ++++++++++ .../snippets/status/content_status.html | 4 +-- 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 bookwyrm/migrations/0174_auto_20230130_1240.py diff --git a/bookwyrm/forms/status.py b/bookwyrm/forms/status.py index 0800166bf..b562595ee 100644 --- a/bookwyrm/forms/status.py +++ b/bookwyrm/forms/status.py @@ -53,6 +53,7 @@ class QuotationForm(CustomForm): "sensitive", "privacy", "position", + "endposition", "position_mode", ] diff --git a/bookwyrm/migrations/0174_auto_20230130_1240.py b/bookwyrm/migrations/0174_auto_20230130_1240.py new file mode 100644 index 000000000..1b81c2087 --- /dev/null +++ b/bookwyrm/migrations/0174_auto_20230130_1240.py @@ -0,0 +1,26 @@ +# Generated by Django 3.2.16 on 2023-01-30 12:40 + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ('bookwyrm', '0173_default_user_auth_group_setting'), + ] + + operations = [ + migrations.AddField( + model_name='quotation', + name='endposition', + field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0)]), + ), + migrations.AlterField( + model_name='sitesettings', + name='default_user_auth_group', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='auth.group'), + ), + ] diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 19eab584d..d5dc8e9c1 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -329,6 +329,9 @@ class Quotation(BookStatus): position = models.IntegerField( validators=[MinValueValidator(0)], null=True, blank=True ) + endposition = models.IntegerField( + validators=[MinValueValidator(0)], null=True, blank=True + ) position_mode = models.CharField( max_length=3, choices=ProgressMode.choices, diff --git a/bookwyrm/templates/snippets/create_status/quotation.html b/bookwyrm/templates/snippets/create_status/quotation.html index a9ddb17f4..9cc76d5a9 100644 --- a/bookwyrm/templates/snippets/create_status/quotation.html +++ b/bookwyrm/templates/snippets/create_status/quotation.html @@ -65,6 +65,19 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j {% if not draft %}data-cache-draft="id_position_{{ book.id }}_{{ type }}"{% endif %} > +
+ +
{% endblock %} diff --git a/bookwyrm/templates/snippets/status/content_status.html b/bookwyrm/templates/snippets/status/content_status.html index e39284fcf..4c4d89341 100644 --- a/bookwyrm/templates/snippets/status/content_status.html +++ b/bookwyrm/templates/snippets/status/content_status.html @@ -99,9 +99,9 @@ — {% 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 %} + {% blocktrans with page=status.position|intcomma %}(Page {{ page }}{% endblocktrans%}{% if status.endposition%} - {% blocktrans with endpage=status.endposition|intcomma %}{{ endpage }}{% endblocktrans %}{% endif%}) {% else %} - {% blocktrans with percent=status.position %}({{ percent }}%){% endblocktrans %} + {% blocktrans with percent=status.position %}({{ percent }}%{% endblocktrans %}{% if status.endposition%}{% blocktrans with endpercent=status.endposition|intcomma %} - {{ endpercent }}%{% endblocktrans %}{% endif %}) {% endif %} {% endif %}