From d6f7f76c4d8c35ebafb994f6f4ee01b932ae2bf0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 2 Jan 2024 11:37:01 -0800 Subject: [PATCH 01/40] Removes outdated/unused version and updating code I had the bright idea of creating this update script but it doesn't work and hasn't been maintained, so it's just sitting there causing confusing and requiring weird things to exist in other places. Now, the unused `version` field can be removed and I can scrap the management command for getting versions. --- .../management/commands/instance_version.py | 54 ------------------- ..._version_sitesettings_available_version.py | 18 +++++++ bookwyrm/models/site.py | 2 +- bookwyrm/views/admin/dashboard.py | 18 ++----- update.sh | 37 ------------- 5 files changed, 24 insertions(+), 105 deletions(-) delete mode 100644 bookwyrm/management/commands/instance_version.py create mode 100644 bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py delete mode 100755 update.sh diff --git a/bookwyrm/management/commands/instance_version.py b/bookwyrm/management/commands/instance_version.py deleted file mode 100644 index ca150d640..000000000 --- a/bookwyrm/management/commands/instance_version.py +++ /dev/null @@ -1,54 +0,0 @@ -""" Get your admin code to allow install """ -from django.core.management.base import BaseCommand - -from bookwyrm import models -from bookwyrm.settings import VERSION - - -# pylint: disable=no-self-use -class Command(BaseCommand): - """command-line options""" - - help = "What version is this?" - - def add_arguments(self, parser): - """specify which function to run""" - parser.add_argument( - "--current", - action="store_true", - help="Version stored in database", - ) - parser.add_argument( - "--target", - action="store_true", - help="Version stored in settings", - ) - parser.add_argument( - "--update", - action="store_true", - help="Update database version", - ) - - # pylint: disable=unused-argument - def handle(self, *args, **options): - """execute init""" - site = models.SiteSettings.objects.get() - current = site.version or "0.0.1" - target = VERSION - if options.get("current"): - print(current) - return - - if options.get("target"): - print(target) - return - - if options.get("update"): - site.version = target - site.save() - return - - if current != target: - print(f"{current}/{target}") - else: - print(current) diff --git a/bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py b/bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py new file mode 100644 index 000000000..219ae32f6 --- /dev/null +++ b/bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.23 on 2024-01-02 19:36 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0191_merge_20240102_0326'), + ] + + operations = [ + migrations.RenameField( + model_name='sitesettings', + old_name='version', + new_name='available_version', + ), + ] diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py index bd53f1f07..7ca7e0015 100644 --- a/bookwyrm/models/site.py +++ b/bookwyrm/models/site.py @@ -45,7 +45,7 @@ class SiteSettings(SiteModel): default_theme = models.ForeignKey( "Theme", null=True, blank=True, on_delete=models.SET_NULL ) - version = models.CharField(null=True, blank=True, max_length=10) + available_version = models.CharField(null=True, blank=True, max_length=10) # admin setup options install_mode = models.BooleanField(default=False) diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index 9d256fc6c..c5648ff11 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -15,7 +15,6 @@ from django.views import View from csp.decorators import csp_update from bookwyrm import models, settings -from bookwyrm.connectors.abstract_connector import get_data from bookwyrm.utils import regex @@ -59,18 +58,11 @@ class Dashboard(View): == site._meta.get_field("privacy_policy").get_default() ) - # check version - - try: - release = get_data(settings.RELEASE_API, timeout=3) - available_version = release.get("tag_name", None) - if available_version and version.parse(available_version) > version.parse( - settings.VERSION - ): - data["current_version"] = settings.VERSION - data["available_version"] = available_version - except: # pylint: disable= bare-except - pass + if site.available_version and version.parse(site.available_version) > version.parse( + settings.VERSION + ): + data["current_version"] = settings.VERSION + data["available_version"] = site.available_version return TemplateResponse(request, "settings/dashboard/dashboard.html", data) diff --git a/update.sh b/update.sh deleted file mode 100755 index 727ce1b24..000000000 --- a/update.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -e - -# determine inital and target versions -initial_version="`./bw-dev runweb python manage.py instance_version --current`" -target_version="`./bw-dev runweb python manage.py instance_version --target`" - -initial_version="`echo $initial_version | tail -n 1 | xargs`" -target_version="`echo $target_version | tail -n 1 | xargs`" -if [[ "$initial_version" = "$target_version" ]]; then - echo "Already up to date; version $initial_version" - exit -fi - -echo "---------------------------------------" -echo "Updating from version: $initial_version" -echo ".......... to version: $target_version" -echo "---------------------------------------" - -function version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } - -# execute scripts between initial and target -for version in `ls -A updates/ | sort -V `; do - if version_gt $initial_version $version; then - # too early - continue - fi - if version_gt $version $target_version; then - # too late - continue - fi - echo "Running tasks for version $version" - ./updates/$version -done - -./bw-dev runweb python manage.py instance_version --update -echo "✨ ----------- Done! --------------- ✨" From 5509941aa4d14fc5422644cac5e8ff658e1fbd5b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 2 Jan 2024 12:23:32 -0800 Subject: [PATCH 02/40] Adds schedule-able task to check for version updates --- ..._version_sitesettings_available_version.py | 8 +++---- bookwyrm/models/site.py | 14 ++++++++++++ .../settings/dashboard/dashboard.html | 4 ++++ .../dashboard/warnings/check_for_updates.html | 22 +++++++++++++++++++ bookwyrm/views/admin/dashboard.py | 21 +++++++++++++++++- 5 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html diff --git a/bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py b/bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py index 219ae32f6..db67b4e92 100644 --- a/bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py +++ b/bookwyrm/migrations/0192_rename_version_sitesettings_available_version.py @@ -6,13 +6,13 @@ from django.db import migrations class Migration(migrations.Migration): dependencies = [ - ('bookwyrm', '0191_merge_20240102_0326'), + ("bookwyrm", "0191_merge_20240102_0326"), ] operations = [ migrations.RenameField( - model_name='sitesettings', - old_name='version', - new_name='available_version', + model_name="sitesettings", + old_name="version", + new_name="available_version", ), ] diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py index 7ca7e0015..f82a4d94b 100644 --- a/bookwyrm/models/site.py +++ b/bookwyrm/models/site.py @@ -10,8 +10,11 @@ from django.dispatch import receiver from django.utils import timezone from model_utils import FieldTracker +from bookwyrm.connectors.abstract_connector import get_data from bookwyrm.preview_images import generate_site_preview_image_task from bookwyrm.settings import DOMAIN, ENABLE_PREVIEW_IMAGES, STATIC_FULL_URL +from bookwyrm.settings import RELEASE_API +from bookwyrm.tasks import app, MISC from .base_model import BookWyrmModel, new_access_code from .user import User from .fields import get_absolute_url @@ -244,3 +247,14 @@ def preview_image(instance, *args, **kwargs): if len(changed_fields) > 0: generate_site_preview_image_task.delay() + + +@app.task(queue=MISC) +def check_for_updates_task(): + """ See if git remote knows about a new version """ + site = SiteSettings.objects.get() + release = get_data(RELEASE_API, timeout=3) + available_version = release.get("tag_name", None) + if available_version: + site.available_version = available_version + site.save(update_fields=["available_version"]) diff --git a/bookwyrm/templates/settings/dashboard/dashboard.html b/bookwyrm/templates/settings/dashboard/dashboard.html index 4c109c7e1..d43b3bade 100644 --- a/bookwyrm/templates/settings/dashboard/dashboard.html +++ b/bookwyrm/templates/settings/dashboard/dashboard.html @@ -45,6 +45,10 @@ {% include 'settings/dashboard/warnings/update_version.html' with warning_level="warning" fullwidth=True %} {% endif %} + {% if schedule_form %} + {% include 'settings/dashboard/warnings/check_for_updates.html' with warning_level="success" fullwidth=True %} + {% endif %} + {% if missing_privacy or missing_conduct %}
{% if missing_privacy %} diff --git a/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html b/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html new file mode 100644 index 000000000..07f11a62d --- /dev/null +++ b/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html @@ -0,0 +1,22 @@ +{% extends 'settings/dashboard/warnings/layout.html' %} +{% load i18n %} + +{% block warning_text %} + +
+ {% csrf_token %} + +

+ {% blocktrans trimmed with current=current_version available=available_version %} + Check for available version updates? (Recommended) + {% endblocktrans %} +

+ + {{ schedule_form.every.as_hidden }} + {{ schedule_form.period.as_hidden }} + + +
+ +{% endblock %} + diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index c5648ff11..ea0675f59 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -6,15 +6,18 @@ from dateutil.parser import parse from packaging import version from django.contrib.auth.decorators import login_required, permission_required +from django.db import transaction from django.db.models import Q +from django.shortcuts import redirect from django.template.response import TemplateResponse from django.utils import timezone from django.utils.decorators import method_decorator from django.views import View +from django_celery_beat.models import PeriodicTask from csp.decorators import csp_update -from bookwyrm import models, settings +from bookwyrm import forms, models, settings from bookwyrm.utils import regex @@ -64,8 +67,24 @@ class Dashboard(View): data["current_version"] = settings.VERSION data["available_version"] = site.available_version + if not PeriodicTask.objects.filter(name="check-for-updates").exists(): + data["schedule_form"] = forms.IntervalScheduleForm({"every": 1, "period": "days"}) + return TemplateResponse(request, "settings/dashboard/dashboard.html", data) + def post(self, request): + """ Create a schedule task to check for updates """ + schedule_form = forms.IntervalScheduleForm(request.POST) + + with transaction.atomic(): + schedule = schedule_form.save(request) + PeriodicTask.objects.get_or_create( + interval=schedule, + name="check-for-updates", + task="bookwyrm.models.site.check_for_updates_task" + ) + return redirect("settings-dashboard") + def get_charts_and_stats(request): """Defines the dashboard charts""" From f36af42f414196f3e12d30a843470979cbcb9713 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 2 Jan 2024 13:05:44 -0800 Subject: [PATCH 03/40] Adds view to see scheduled tasks --- bookwyrm/models/site.py | 2 +- bookwyrm/templates/settings/layout.html | 4 + bookwyrm/templates/settings/schedules.html | 116 +++++++++++++++++++++ bookwyrm/urls.py | 5 + bookwyrm/views/__init__.py | 1 + bookwyrm/views/admin/dashboard.py | 14 +-- bookwyrm/views/admin/schedule.py | 23 ++++ 7 files changed, 158 insertions(+), 7 deletions(-) create mode 100644 bookwyrm/templates/settings/schedules.html create mode 100644 bookwyrm/views/admin/schedule.py diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py index f82a4d94b..ad0dbff64 100644 --- a/bookwyrm/models/site.py +++ b/bookwyrm/models/site.py @@ -251,7 +251,7 @@ def preview_image(instance, *args, **kwargs): @app.task(queue=MISC) def check_for_updates_task(): - """ See if git remote knows about a new version """ + """See if git remote knows about a new version""" site = SiteSettings.objects.get() release = get_data(RELEASE_API, timeout=3) available_version = release.get("tag_name", None) diff --git a/bookwyrm/templates/settings/layout.html b/bookwyrm/templates/settings/layout.html index dcaaaeb38..70c7ef0f4 100644 --- a/bookwyrm/templates/settings/layout.html +++ b/bookwyrm/templates/settings/layout.html @@ -85,6 +85,10 @@ {% url 'settings-celery' as url %} {% trans "Celery status" %} +
  • + {% url 'settings-schedules' as url %} + {% trans "Scheduled tasks" %} +
  • {% url 'settings-email-config' as url %} {% trans "Email Configuration" %} diff --git a/bookwyrm/templates/settings/schedules.html b/bookwyrm/templates/settings/schedules.html new file mode 100644 index 000000000..fe096092d --- /dev/null +++ b/bookwyrm/templates/settings/schedules.html @@ -0,0 +1,116 @@ +{% extends 'settings/layout.html' %} +{% load i18n %} +{% load humanize %} +{% load utilities %} + +{% block title %} +{% trans "Scheduled tasks" %} +{% endblock %} + +{% block header %} +{% trans "Scheduled tasks" %} +{% endblock %} + +{% block panel %} + +
    +

    {% trans "Tasks" %}

    +
    + + + + + + + + + + + {% for task in tasks %} + + + + + + + + + + {% empty %} + + + + {% endfor %} +
    + {% trans "Name" %} + + {% trans "Celery task" %} + + {% trans "Date changed" %} + + {% trans "Last run at" %} + + {% trans "Schedule" %} + + {% trans "Schedule ID" %} + + {% trans "Enabled" %} +
    + {{ task.name }} + + {{ task.task }} + + {{ task.date_changed }} + + {{ task.last_run_at }} + + {% firstof task.interval task.crontab "None" %} + + {{ task.interval.id }} + + {{ task.enabled|yesno }} +
    + {% trans "No scheduled tasks" %} +
    +
    +
    + +
    +

    {% trans "Schedules" %}

    +
    + + + + + + + {% for schedule in schedules %} + + + + + + {% empty %} + + + + {% endfor %} +
    + {% trans "ID" %} + + {% trans "Schedule" %} + + {% trans "Tasks" %} +
    + {{ schedule.id }} + + {{ schedule }} + + {{ schedule.periodictask_set.count }} +
    + {% trans "No schedules found" %} +
    +
    +
    + +{% endblock %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 76e60245b..64742347a 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -359,6 +359,11 @@ urlpatterns = [ re_path( r"^settings/celery/ping/?$", views.celery_ping, name="settings-celery-ping" ), + re_path( + r"^settings/schedules/?$", + views.ScheduledTasks.as_view(), + name="settings-schedules", + ), re_path( r"^settings/email-config/?$", views.EmailConfig.as_view(), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 3be813208..d77f2675f 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -5,6 +5,7 @@ from .admin.announcements import EditAnnouncement, delete_announcement from .admin.automod import AutoMod, automod_delete, run_automod from .admin.automod import schedule_automod_task, unschedule_automod_task from .admin.celery_status import CeleryStatus, celery_ping +from .admin.schedule import ScheduledTasks from .admin.dashboard import Dashboard from .admin.federation import Federation, FederatedServer from .admin.federation import AddFederatedServer, ImportServerBlocklist diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index ea0675f59..4b2575fa6 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -61,19 +61,21 @@ class Dashboard(View): == site._meta.get_field("privacy_policy").get_default() ) - if site.available_version and version.parse(site.available_version) > version.parse( - settings.VERSION - ): + if site.available_version and version.parse( + site.available_version + ) > version.parse(settings.VERSION): data["current_version"] = settings.VERSION data["available_version"] = site.available_version if not PeriodicTask.objects.filter(name="check-for-updates").exists(): - data["schedule_form"] = forms.IntervalScheduleForm({"every": 1, "period": "days"}) + data["schedule_form"] = forms.IntervalScheduleForm( + {"every": 1, "period": "days"} + ) return TemplateResponse(request, "settings/dashboard/dashboard.html", data) def post(self, request): - """ Create a schedule task to check for updates """ + """Create a schedule task to check for updates""" schedule_form = forms.IntervalScheduleForm(request.POST) with transaction.atomic(): @@ -81,7 +83,7 @@ class Dashboard(View): PeriodicTask.objects.get_or_create( interval=schedule, name="check-for-updates", - task="bookwyrm.models.site.check_for_updates_task" + task="bookwyrm.models.site.check_for_updates_task", ) return redirect("settings-dashboard") diff --git a/bookwyrm/views/admin/schedule.py b/bookwyrm/views/admin/schedule.py new file mode 100644 index 000000000..ce5944ee5 --- /dev/null +++ b/bookwyrm/views/admin/schedule.py @@ -0,0 +1,23 @@ +""" Scheduled celery tasks """ +from django.contrib.auth.decorators import login_required, permission_required +from django.template.response import TemplateResponse +from django.utils.decorators import method_decorator +from django.views import View +from django_celery_beat.models import PeriodicTask, IntervalSchedule + + +@method_decorator(login_required, name="dispatch") +@method_decorator( + permission_required("bookwyrm.edit_instance_settings", raise_exception=True), + name="dispatch", +) +# pylint: disable=no-self-use +class ScheduledTasks(View): + """Manage automated flagging""" + + def get(self, request): + """view schedules""" + data = {} + data["tasks"] = PeriodicTask.objects.all() + data["schedules"] = IntervalSchedule.objects.all() + return TemplateResponse(request, "settings/schedules.html", data) From 8be9e91d2162871faae0aaabbecdf8da449b6c2d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 2 Jan 2024 13:16:53 -0800 Subject: [PATCH 04/40] Re-use schedules rather than creating new ones --- bookwyrm/views/admin/automod.py | 4 ++-- bookwyrm/views/admin/dashboard.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bookwyrm/views/admin/automod.py b/bookwyrm/views/admin/automod.py index 9a32dd9ee..58818ad9b 100644 --- a/bookwyrm/views/admin/automod.py +++ b/bookwyrm/views/admin/automod.py @@ -6,7 +6,7 @@ from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View from django.views.decorators.http import require_POST -from django_celery_beat.models import PeriodicTask +from django_celery_beat.models import PeriodicTask, IntervalSchedule from bookwyrm import forms, models @@ -54,7 +54,7 @@ def schedule_automod_task(request): return TemplateResponse(request, "settings/automod/rules.html", data) with transaction.atomic(): - schedule = form.save(request) + schedule, _ = IntervalSchedule.objects.get_or_create(**form.cleaned_data) PeriodicTask.objects.get_or_create( interval=schedule, name="automod-task", diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index 4b2575fa6..a4c630067 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -13,7 +13,7 @@ from django.template.response import TemplateResponse from django.utils import timezone from django.utils.decorators import method_decorator from django.views import View -from django_celery_beat.models import PeriodicTask +from django_celery_beat.models import PeriodicTask, IntervalSchedule from csp.decorators import csp_update @@ -79,7 +79,9 @@ class Dashboard(View): schedule_form = forms.IntervalScheduleForm(request.POST) with transaction.atomic(): - schedule = schedule_form.save(request) + schedule, _ = IntervalSchedule.objects.get_or_create( + **schedule_form.cleaned_data + ) PeriodicTask.objects.get_or_create( interval=schedule, name="check-for-updates", From 193a1c7d54564c3ab35be20e27681566c2305581 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 2 Jan 2024 13:28:25 -0800 Subject: [PATCH 05/40] updates wording and fixes get or create logic --- VERSION | 2 +- .../settings/dashboard/warnings/check_for_updates.html | 4 ++-- bookwyrm/views/admin/dashboard.py | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 39e898a4f..ee6cdce3c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.7.1 +0.6.1 diff --git a/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html b/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html index 07f11a62d..f0a2a8013 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html +++ b/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html @@ -8,14 +8,14 @@

    {% blocktrans trimmed with current=current_version available=available_version %} - Check for available version updates? (Recommended) + Would you like to automatically check for new BookWyrm releases? (recommended) {% endblocktrans %}

    {{ schedule_form.every.as_hidden }} {{ schedule_form.period.as_hidden }} - + {% endblock %} diff --git a/bookwyrm/views/admin/dashboard.py b/bookwyrm/views/admin/dashboard.py index a4c630067..21b19bf16 100644 --- a/bookwyrm/views/admin/dashboard.py +++ b/bookwyrm/views/admin/dashboard.py @@ -77,6 +77,8 @@ class Dashboard(View): def post(self, request): """Create a schedule task to check for updates""" schedule_form = forms.IntervalScheduleForm(request.POST) + if not schedule_form.is_valid(): + raise schedule_form.ValidationError(schedule_form.errors) with transaction.atomic(): schedule, _ = IntervalSchedule.objects.get_or_create( From d287581620a5d1238988803d05ce2ce9c6cbf52b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 2 Jan 2024 13:31:18 -0800 Subject: [PATCH 06/40] Fixes html validation error --- .../settings/dashboard/warnings/check_for_updates.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html b/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html index f0a2a8013..00f320824 100644 --- a/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html +++ b/bookwyrm/templates/settings/dashboard/warnings/check_for_updates.html @@ -1,6 +1,8 @@ {% extends 'settings/dashboard/warnings/layout.html' %} {% load i18n %} +{% block warning_link %}#{% endblock %} + {% block warning_text %}
    From 6cd2c9113506cf71756fc1bb5f025297fbcc4f53 Mon Sep 17 00:00:00 2001 From: Wesley Aptekar-Cassels Date: Thu, 4 Jan 2024 18:58:12 -0500 Subject: [PATCH 07/40] Allow page numbers to be text, instead of integers. Fixes: #2640 --- .../0192_make_page_positions_text.py | 23 +++++++++++++++++++ bookwyrm/models/status.py | 10 ++++---- .../snippets/create_status/quotation.html | 6 ++--- bookwyrm/tests/views/books/test_book.py | 8 ++++--- 4 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 bookwyrm/migrations/0192_make_page_positions_text.py diff --git a/bookwyrm/migrations/0192_make_page_positions_text.py b/bookwyrm/migrations/0192_make_page_positions_text.py new file mode 100644 index 000000000..940a9e941 --- /dev/null +++ b/bookwyrm/migrations/0192_make_page_positions_text.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.23 on 2024-01-04 23:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0191_merge_20240102_0326"), + ] + + operations = [ + migrations.AlterField( + model_name="quotation", + name="endposition", + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name="quotation", + name="position", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index cc44fe2bf..f33c32824 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -338,11 +338,13 @@ class Quotation(BookStatus): quote = fields.HtmlField() raw_quote = models.TextField(blank=True, null=True) - position = models.IntegerField( - validators=[MinValueValidator(0)], null=True, blank=True + position = models.TextField( + null=True, + blank=True, ) - endposition = models.IntegerField( - validators=[MinValueValidator(0)], null=True, blank=True + endposition = models.TextField( + null=True, + blank=True, ) position_mode = models.CharField( max_length=3, diff --git a/bookwyrm/templates/snippets/create_status/quotation.html b/bookwyrm/templates/snippets/create_status/quotation.html index bd1d817ad..dc17585a9 100644 --- a/bookwyrm/templates/snippets/create_status/quotation.html +++ b/bookwyrm/templates/snippets/create_status/quotation.html @@ -56,8 +56,7 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j Date: Tue, 9 Jan 2024 15:31:05 +0530 Subject: [PATCH 08/40] Issue-3187: changes --- bookwyrm/templates/feed/feed.html | 2 +- bookwyrm/views/feed.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index 7ecf10b70..820314b7a 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -33,7 +33,7 @@ - {% if request.user.show_goal and not goal and tab.key == 'home' %} + {% if request.user.show_goal and not goal and tab.key == 'home' and has_read_throughs %} {% now 'Y' as year %}
    {% include 'feed/goal_card.html' with year=year %} diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index 17218b93e..381d233e9 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -52,6 +52,8 @@ class Feed(View): suggestions = suggested_users.get_suggestions(request.user) + readthroughs = models.ReadThrough.objects.filter(user=request.user) + data = { **feed_page_data(request.user), **{ @@ -66,6 +68,7 @@ class Feed(View): "path": f"/{tab['key']}", "annual_summary_year": get_annual_summary_year(), "has_tour": True, + "has_read_throughs": True if len(readthroughs) else False, }, } return TemplateResponse(request, "feed/feed.html", data) From 854eb36618fe4371b37b4da3a86c68d6778d195b Mon Sep 17 00:00:00 2001 From: Carlos Camara Date: Sat, 13 Jan 2024 16:43:41 +0000 Subject: [PATCH 09/40] Export bookshelves and review date --- .../tests/views/preferences/test_export.py | 9 +++-- bookwyrm/views/preferences/export.py | 36 +++++++++++++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/bookwyrm/tests/views/preferences/test_export.py b/bookwyrm/tests/views/preferences/test_export.py index d633ae952..7a1bcd6db 100644 --- a/bookwyrm/tests/views/preferences/test_export.py +++ b/bookwyrm/tests/views/preferences/test_export.py @@ -18,7 +18,9 @@ class ExportViews(TestCase): """viewing and creating statuses""" @classmethod - def setUpTestData(self): # pylint: disable=bad-classmethod-argument + def setUpTestData( + self, + ): # pylint: disable=bad-classmethod-argument, disable=invalid-name """we need basic test data and mocks""" with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( "bookwyrm.activitystreams.populate_stream_task.delay" @@ -40,6 +42,7 @@ class ExportViews(TestCase): bnf_id="beep", ) + # pylint: disable=invalid-name def setUp(self): """individual test setup""" self.factory = RequestFactory() @@ -66,7 +69,7 @@ class ExportViews(TestCase): # pylint: disable=line-too-long self.assertEqual( export.content, - b"title,author_text,remote_id,openlibrary_key,inventaire_id,librarything_key,goodreads_key,bnf_id,viaf,wikidata,asin,aasin,isfdb,isbn_10,isbn_13,oclc_number,start_date,finish_date,stopped_date,rating,review_name,review_cw,review_content\r\nTest Book,," + b"title,author_text,remote_id,openlibrary_key,inventaire_id,librarything_key,goodreads_key,bnf_id,viaf,wikidata,asin,aasin,isfdb,isbn_10,isbn_13,oclc_number,start_date,finish_date,stopped_date,rating,review_name,review_cw,review_content,review_published,shelf,shelf_name,shelf_date\r\nTest Book,," + self.book.remote_id.encode("utf-8") - + b",,,,,beep,,,,,,123456789X,9781234567890,,,,,,,,\r\n", + + b",,,,,beep,,,,,,123456789X,9781234567890,,,,,,,,,,,,\r\n", ) diff --git a/bookwyrm/views/preferences/export.py b/bookwyrm/views/preferences/export.py index 3443be461..d16f3aaa3 100644 --- a/bookwyrm/views/preferences/export.py +++ b/bookwyrm/views/preferences/export.py @@ -17,6 +17,7 @@ from bookwyrm import models from bookwyrm.models.bookwyrm_export_job import BookwyrmExportJob from bookwyrm.settings import PAGE_LENGTH + # pylint: disable=no-self-use,too-many-locals @method_decorator(login_required, name="dispatch") class Export(View): @@ -54,8 +55,19 @@ class Export(View): fields = ( ["title", "author_text"] + deduplication_fields - + ["start_date", "finish_date", "stopped_date"] - + ["rating", "review_name", "review_cw", "review_content"] + + [ + "start_date", + "finish_date", + "stopped_date", + "rating", + "review_name", + "review_cw", + "review_content", + "review_published", + "shelf", + "shelf_name", + "shelf_date", + ] ) writer.writerow(fields) @@ -97,9 +109,27 @@ class Export(View): .first() ) if review: + book.review_published = ( + review.published_date.date() if review.published_date else None + ) book.review_name = review.name book.review_cw = review.content_warning - book.review_content = review.raw_content + book.review_content = ( + review.raw_content if review.raw_content else review.content + ) # GoodReads imported reviews do not have raw_content, but content. + + shelfbook = ( + models.ShelfBook.objects.filter(user=request.user, book=book) + .order_by("-shelved_date", "-created_date", "-updated_date") + .last() + ) + if shelfbook: + book.shelf = shelfbook.shelf.identifier + book.shelf_name = shelfbook.shelf.name + book.shelf_date = ( + shelfbook.shelved_date.date() if shelfbook.shelved_date else None + ) + writer.writerow([getattr(book, field, "") or "" for field in fields]) return HttpResponse( From 9a487b0442c0d9e94b511491bf61bd00b3cfebfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Sat, 13 Jan 2024 17:51:14 +0100 Subject: [PATCH 10/40] Ensure dev-tools uses bookworm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 1937177e1 ("dev-tools: use apt source for Node instead of setup script"), I introduced the use of `Signed-By` with a public key block, which is only supported in bookworm (bullseye only supports fingerprints, TTBOMK). Python's Docker images already use bookworm by default, but we explicitly require it now to avoid build errors if someone has a very old image laying around (see, e.g., #3190). (This can be dropped after Debian 13 ‘trixie’ is released.) --- dev-tools/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-tools/Dockerfile b/dev-tools/Dockerfile index 3b7740a78..6c132944f 100644 --- a/dev-tools/Dockerfile +++ b/dev-tools/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9 +FROM python:3.9-bookworm WORKDIR /app/dev-tools ENV PATH="/app/dev-tools/node_modules/.bin:$PATH" From 5ef104b802dce740835f4a34bb4403459e2791bc Mon Sep 17 00:00:00 2001 From: Rohan Sureshkumar Date: Mon, 15 Jan 2024 17:22:33 +0530 Subject: [PATCH 11/40] Issue-3187: addressing review comments --- bookwyrm/templates/feed/feed.html | 4 ++-- bookwyrm/views/feed.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index 820314b7a..56c380202 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -33,7 +33,7 @@ - {% if request.user.show_goal and not goal and tab.key == 'home' and has_read_throughs %} + {% if request.user.show_goal and not goal and tab.key == 'home' %} {% now 'Y' as year %}
    {% include 'feed/goal_card.html' with year=year %} @@ -41,7 +41,7 @@
    {% endif %} - {% if annual_summary_year and tab.key == 'home' %} + {% if annual_summary_year and tab.key == 'home' and has_read_throughs %}
  • -
    +
    {% if superlatives.top_rated %} {% with book=superlatives.top_rated.default_edition rating=superlatives.top_rated.rating %} -
    +
    @@ -53,7 +53,7 @@ {% if superlatives.wanted %} {% with book=superlatives.wanted.default_edition %} -
    +
    @@ -72,7 +72,7 @@ {% if superlatives.controversial %} {% with book=superlatives.controversial.default_edition %} -
    +
    From ddbda3ab9ca1f1e4658e711d3a5e5fbd971369c4 Mon Sep 17 00:00:00 2001 From: Carlos Camara Date: Tue, 16 Jan 2024 08:12:24 +0000 Subject: [PATCH 13/40] Fix test_export --- bookwyrm/tests/views/preferences/test_export.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bookwyrm/tests/views/preferences/test_export.py b/bookwyrm/tests/views/preferences/test_export.py index 7a1bcd6db..3f758b2f7 100644 --- a/bookwyrm/tests/views/preferences/test_export.py +++ b/bookwyrm/tests/views/preferences/test_export.py @@ -56,11 +56,12 @@ class ExportViews(TestCase): def test_export_file(self, *_): """simple export""" - models.ShelfBook.objects.create( + shelfbook = models.ShelfBook.objects.create( shelf=self.local_user.shelf_set.first(), user=self.local_user, book=self.book, ) + book_date = str.encode(f"{shelfbook.shelved_date.date()}") request = self.factory.post("") request.user = self.local_user export = views.Export.as_view()(request) @@ -69,7 +70,7 @@ class ExportViews(TestCase): # pylint: disable=line-too-long self.assertEqual( export.content, - b"title,author_text,remote_id,openlibrary_key,inventaire_id,librarything_key,goodreads_key,bnf_id,viaf,wikidata,asin,aasin,isfdb,isbn_10,isbn_13,oclc_number,start_date,finish_date,stopped_date,rating,review_name,review_cw,review_content,review_published,shelf,shelf_name,shelf_date\r\nTest Book,," - + self.book.remote_id.encode("utf-8") - + b",,,,,beep,,,,,,123456789X,9781234567890,,,,,,,,,,,,\r\n", + b"title,author_text,remote_id,openlibrary_key,inventaire_id,librarything_key,goodreads_key,bnf_id,viaf,wikidata,asin,aasin,isfdb,isbn_10,isbn_13,oclc_number,start_date,finish_date,stopped_date,rating,review_name,review_cw,review_content,review_published,shelf,shelf_name,shelf_date\r\n" + + b"Test Book,,%b,,,,,beep,,,,,,123456789X,9781234567890,,,,,,,,,,to-read,To Read,%b\r\n" + % (self.book.remote_id.encode("utf-8"), book_date), ) From d640e4ac96005cdc2b21b6a08f97a8805c26d00b Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Tue, 16 Jan 2024 21:32:13 +1100 Subject: [PATCH 14/40] disable user exports by default - new setting to enable user exports defaults to False - add setting to enable and disable user exports - do not allow user exports when using s3 storage - do not serve non-image files from /images/ (requires update to nginx settings) - increase default file upload limit to 100MB to enable user exports to be imported (can be changed in .env) --- .env.example | 3 ++ .../0192_sitesettings_user_exports_enabled.py | 18 +++++++ bookwyrm/models/site.py | 1 + bookwyrm/settings.py | 2 + .../templates/preferences/export-user.html | 6 ++- .../templates/settings/imports/imports.html | 51 ++++++++++++++++++- bookwyrm/urls.py | 10 ++++ bookwyrm/views/__init__.py | 2 + bookwyrm/views/admin/imports.py | 25 ++++++++- nginx/development | 7 ++- nginx/production | 7 ++- 11 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 bookwyrm/migrations/0192_sitesettings_user_exports_enabled.py diff --git a/.env.example b/.env.example index fb0f7308d..20ce8240b 100644 --- a/.env.example +++ b/.env.example @@ -137,3 +137,6 @@ TWO_FACTOR_LOGIN_MAX_SECONDS=60 # and AWS_S3_CUSTOM_DOMAIN (if used) are added by default. # Value should be a comma-separated list of host names. CSP_ADDITIONAL_HOSTS= +# The last number here means "megabytes" +# Increase if users are having trouble uploading BookWyrm export files. +DATA_UPLOAD_MAX_MEMORY_SIZE = (1024**2 * 100) \ No newline at end of file diff --git a/bookwyrm/migrations/0192_sitesettings_user_exports_enabled.py b/bookwyrm/migrations/0192_sitesettings_user_exports_enabled.py new file mode 100644 index 000000000..ec5b411e2 --- /dev/null +++ b/bookwyrm/migrations/0192_sitesettings_user_exports_enabled.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.23 on 2024-01-16 10:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0191_merge_20240102_0326"), + ] + + operations = [ + migrations.AddField( + model_name="sitesettings", + name="user_exports_enabled", + field=models.BooleanField(default=False), + ), + ] diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py index bd53f1f07..8075b6434 100644 --- a/bookwyrm/models/site.py +++ b/bookwyrm/models/site.py @@ -96,6 +96,7 @@ class SiteSettings(SiteModel): imports_enabled = models.BooleanField(default=True) import_size_limit = models.IntegerField(default=0) import_limit_reset = models.IntegerField(default=0) + user_exports_enabled = models.BooleanField(default=False) user_import_time_limit = models.IntegerField(default=48) field_tracker = FieldTracker(fields=["name", "instance_tagline", "logo"]) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index fcc91857a..cc941da84 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -442,3 +442,5 @@ if HTTP_X_FORWARDED_PROTO: # Do not change this setting unless you already have an existing # user with the same username - in which case you should change it! INSTANCE_ACTOR_USERNAME = "bookwyrm.instance.actor" + +DATA_UPLOAD_MAX_MEMORY_SIZE = env.int("DATA_UPLOAD_MAX_MEMORY_SIZE", (1024**2 * 100)) diff --git a/bookwyrm/templates/preferences/export-user.html b/bookwyrm/templates/preferences/export-user.html index a468c3f74..cd3119e3e 100644 --- a/bookwyrm/templates/preferences/export-user.html +++ b/bookwyrm/templates/preferences/export-user.html @@ -46,7 +46,11 @@ {% trans "If you wish to migrate any statuses (comments, reviews, or quotes) you must either set the account you are moving to as an alias of this one, or move this account to the new account, before you import your user data." %} {% endspaceless %}

    - {% if next_available %} + {% if not site.user_exports_enabled %} +

    + {% trans "New user exports are currently disabled." %} +

    + {% elif next_available %}

    {% blocktrans trimmed %} You will be able to create a new export file at {{ next_available }} diff --git a/bookwyrm/templates/settings/imports/imports.html b/bookwyrm/templates/settings/imports/imports.html index 8898aab71..11b3c7e03 100644 --- a/bookwyrm/templates/settings/imports/imports.html +++ b/bookwyrm/templates/settings/imports/imports.html @@ -90,6 +90,33 @@

    + + {% if site.user_exports_enabled %} +
    + + + {% trans "Disable starting new user exports" %} + + + +
    +
    + {% trans "This is only intended to be used when things have gone very wrong with exports and you need to pause the feature while addressing issues." %} + {% trans "While exports are disabled, users will not be allowed to start new user exports, but existing exports will not be affected." %} +
    + {% csrf_token %} +
    + +
    +
    +
    @@ -108,7 +135,7 @@ {% trans "Set the value to 0 to not enforce any limit." %}
    - + {% csrf_token %} @@ -120,6 +147,28 @@
    + {% else %} +
    +
    +

    {% trans "Users are currently unable to start new user exports. This is the default setting." %}

    + {% if use_s3 %} +

    {% trans "It is not currently possible to provide user exports when using s3 storage. The BookWyrm development team are working on a fix for this." %}

    + {% endif %} +
    + {% csrf_token %} +
    + +
    +
    + {% endif %}

    {% trans "Book Imports" %}

    diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 76e60245b..1a577c84b 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -338,6 +338,16 @@ urlpatterns = [ views.disable_imports, name="settings-imports-disable", ), + re_path( + r"^settings/user-exports/enable/?$", + views.enable_user_exports, + name="settings-user-exports-enable", + ), + re_path( + r"^settings/user-exports/disable/?$", + views.disable_user_exports, + name="settings-user-exports-disable", + ), re_path( r"^settings/imports/enable/?$", views.enable_imports, diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 3be813208..f11c11dd6 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -18,6 +18,8 @@ from .admin.imports import ( set_import_size_limit, set_user_import_completed, set_user_import_limit, + enable_user_exports, + disable_user_exports, ) from .admin.ip_blocklist import IPBlocklist from .admin.invite import ManageInvites, Invite, InviteRequest diff --git a/bookwyrm/views/admin/imports.py b/bookwyrm/views/admin/imports.py index a85d6c79e..0924536bf 100644 --- a/bookwyrm/views/admin/imports.py +++ b/bookwyrm/views/admin/imports.py @@ -9,7 +9,7 @@ from django.views.decorators.http import require_POST from bookwyrm import models from bookwyrm.views.helpers import redirect_to_referer -from bookwyrm.settings import PAGE_LENGTH +from bookwyrm.settings import PAGE_LENGTH, USE_S3 # pylint: disable=no-self-use @@ -59,6 +59,7 @@ class ImportList(View): "import_size_limit": site_settings.import_size_limit, "import_limit_reset": site_settings.import_limit_reset, "user_import_time_limit": site_settings.user_import_time_limit, + "use_s3": USE_S3, } return TemplateResponse(request, "settings/imports/imports.html", data) @@ -126,3 +127,25 @@ def set_user_import_limit(request): site.user_import_time_limit = int(request.POST.get("limit")) site.save(update_fields=["user_import_time_limit"]) return redirect("settings-imports") + + +@require_POST +@permission_required("bookwyrm.edit_instance_settings", raise_exception=True) +# pylint: disable=unused-argument +def enable_user_exports(request): + """Allow users to export account data""" + site = models.SiteSettings.objects.get() + site.user_exports_enabled = True + site.save(update_fields=["user_exports_enabled"]) + return redirect("settings-imports") + + +@require_POST +@permission_required("bookwyrm.edit_instance_settings", raise_exception=True) +# pylint: disable=unused-argument +def disable_user_exports(request): + """Don't allow users to export account data""" + site = models.SiteSettings.objects.get() + site.user_exports_enabled = False + site.save(update_fields=["user_exports_enabled"]) + return redirect("settings-imports") diff --git a/nginx/development b/nginx/development index 841db0124..ac663053c 100644 --- a/nginx/development +++ b/nginx/development @@ -64,13 +64,18 @@ server { # directly serve images and static files from the # bookwyrm filesystem using sendfile. # make the logs quieter by not reporting these requests - location ~ ^/(images|static)/ { + location ~ \.(bmp|ico|jpg|jpeg|png|tif|tiff|webp)$ { root /app; try_files $uri =404; add_header X-Cache-Status STATIC; access_log off; } + # block access to any non-image files from images or static + location ~ ^/(images|static)/ { + return 403; + } + # monitor the celery queues with flower, no caching enabled location /flower/ { proxy_pass http://flower:8888; diff --git a/nginx/production b/nginx/production index 9018ab9de..4e40f32a0 100644 --- a/nginx/production +++ b/nginx/production @@ -96,12 +96,17 @@ server { # # directly serve images and static files from the # # bookwyrm filesystem using sendfile. # # make the logs quieter by not reporting these requests -# location ~ ^/(images|static)/ { +# location ~ \.(bmp|ico|jpg|jpeg|png|tif|tiff|webp)$ { # root /app; # try_files $uri =404; # add_header X-Cache-Status STATIC; # access_log off; # } + +# # block access to any non-image files from images or static +# location ~ ^/(images|static)/ { +# return 403; +# } # # # monitor the celery queues with flower, no caching enabled # location /flower/ { From ea7f3c297e6f92ca82c06b6fb3ace0d37ebdd53f Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Wed, 17 Jan 2024 20:12:06 +1100 Subject: [PATCH 15/40] allow js and css --- nginx/development | 4 ++-- nginx/production | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nginx/development b/nginx/development index ac663053c..64cd1b911 100644 --- a/nginx/development +++ b/nginx/development @@ -64,7 +64,7 @@ server { # directly serve images and static files from the # bookwyrm filesystem using sendfile. # make the logs quieter by not reporting these requests - location ~ \.(bmp|ico|jpg|jpeg|png|tif|tiff|webp)$ { + location ~ \.(bmp|ico|jpg|jpeg|png|tif|tiff|webp|css|js)$ { root /app; try_files $uri =404; add_header X-Cache-Status STATIC; @@ -72,7 +72,7 @@ server { } # block access to any non-image files from images or static - location ~ ^/(images|static)/ { + location ~ ^/images/ { return 403; } diff --git a/nginx/production b/nginx/production index 4e40f32a0..76ed19449 100644 --- a/nginx/production +++ b/nginx/production @@ -96,7 +96,7 @@ server { # # directly serve images and static files from the # # bookwyrm filesystem using sendfile. # # make the logs quieter by not reporting these requests -# location ~ \.(bmp|ico|jpg|jpeg|png|tif|tiff|webp)$ { +# location ~ \.(bmp|ico|jpg|jpeg|png|tif|tiff|webp|css|js)$ { # root /app; # try_files $uri =404; # add_header X-Cache-Status STATIC; @@ -104,7 +104,7 @@ server { # } # # block access to any non-image files from images or static -# location ~ ^/(images|static)/ { +# location ~ ^/images/ { # return 403; # } # From b990d9ccd8f2bff4990b79f7dc7cd494190d0536 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Wed, 17 Jan 2024 21:06:04 +1100 Subject: [PATCH 16/40] Pass correct user id in Move notification We were passing the *requesting* user's moved_to value to the Move notification template, instead of the id of the user that they are being notified about. Additionally, the id_to_username template tag had no fallback for if the user_id is None. This resolves both problems and removes an unnecessary space in a template for when the logged in user made the move. Fixes #3196 --- bookwyrm/templates/moved.html | 2 +- bookwyrm/templates/notifications/items/move_user.html | 2 +- bookwyrm/templatetags/utilities.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/moved.html b/bookwyrm/templates/moved.html index 545fc3d87..382b752be 100644 --- a/bookwyrm/templates/moved.html +++ b/bookwyrm/templates/moved.html @@ -23,7 +23,7 @@

    - {% id_to_username request.user.moved_to as username %} + {% id_to_username request.user.moved_to as username %} {% blocktrans trimmed with moved_to=user.moved_to %} You have moved your account to {{ username }} {% endblocktrans %} diff --git a/bookwyrm/templates/notifications/items/move_user.html b/bookwyrm/templates/notifications/items/move_user.html index b94d96dc4..3121d3f45 100644 --- a/bookwyrm/templates/notifications/items/move_user.html +++ b/bookwyrm/templates/notifications/items/move_user.html @@ -14,7 +14,7 @@ {% block description %} {% if related_user_moved_to %} - {% id_to_username request.user.moved_to as username %} + {% id_to_username related_user_moved_to as username %} {% blocktrans trimmed %} {{ related_user }} has moved to {{ username }} {% endblocktrans %} diff --git a/bookwyrm/templatetags/utilities.py b/bookwyrm/templatetags/utilities.py index fca66688a..230db366e 100644 --- a/bookwyrm/templatetags/utilities.py +++ b/bookwyrm/templatetags/utilities.py @@ -125,7 +125,8 @@ def id_to_username(user_id): name = parts[-1] value = f"{name}@{domain}" - return value + return value + return "a new user account" @register.filter(name="get_file_size") From 8e2649ba3b26bc03ff90d8a5790f7b19301ebd34 Mon Sep 17 00:00:00 2001 From: Rohan Sureshkumar Date: Thu, 18 Jan 2024 21:23:25 +0530 Subject: [PATCH 17/40] Issue-3187: change variable name and code formatting --- bookwyrm/templates/feed/feed.html | 2 +- bookwyrm/views/feed.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/feed/feed.html b/bookwyrm/templates/feed/feed.html index 56c380202..1b6cf29ff 100644 --- a/bookwyrm/templates/feed/feed.html +++ b/bookwyrm/templates/feed/feed.html @@ -41,7 +41,7 @@ {% endif %} - {% if annual_summary_year and tab.key == 'home' and has_read_throughs %} + {% if annual_summary_year and tab.key == 'home' and has_summary_read_throughs %}

    -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index 17218b93e..2d91990d0 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -197,6 +197,8 @@ class Status(View): "status": status, "children": children, "ancestors": ancestors, + "title": status.page_title, + "description": status.page_description, "preview": preview, }, } From ad56024ffe8adac7a8cab916b160b2f18edd2f1d Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Sat, 20 Jan 2024 17:18:50 +0100 Subject: [PATCH 22/40] Add Status.page_image property --- bookwyrm/models/status.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 04fb8daa3..236826a2b 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -190,6 +190,15 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): """description of the page in meta tags when only this status is shown""" return None + @property + def page_image(self): + """image to use as preview in meta tags when only this status is shown""" + if self.mention_books.exists(): + book = self.mention_books.first() + return book.preview_image + else: + return self.user.preview_image + def to_replies(self, **kwargs): """helper function for loading AP serialized replies to a status""" return self.to_ordered_collection( @@ -313,6 +322,10 @@ class BookStatus(Status): abstract = True + @property + def page_image(self): + return self.book.preview_image or super().page_image + class Comment(BookStatus): """like a review but without a rating and transient""" From 290ee997b3c935297811f033d8da0a564ba48f52 Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Sat, 20 Jan 2024 17:24:20 +0100 Subject: [PATCH 23/40] Refactor OpenGraph tags logic --- bookwyrm/templates/snippets/opengraph.html | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/bookwyrm/templates/snippets/opengraph.html b/bookwyrm/templates/snippets/opengraph.html index 1e87a464f..78a6b1b3f 100644 --- a/bookwyrm/templates/snippets/opengraph.html +++ b/bookwyrm/templates/snippets/opengraph.html @@ -1,24 +1,25 @@ {% load static %} -{% if preview_images_enabled is True %} +{% firstof image site.preview_image as page_image %} +{% if page_image %} - {% if image %} - - - {% else %} - - - {% endif %} + + +{% elif site.logo %} + + + + {% else %} - - + + + {% endif %} - - - - +{% firstof description site.instance_tagline as description %} + + From ea9d3f8ba1ac3db3a050b0355bd3de3d20cd061e Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Sat, 20 Jan 2024 17:25:20 +0100 Subject: [PATCH 24/40] Use Status.page_image for OpenGraph tags --- bookwyrm/templates/feed/status.html | 4 ++-- bookwyrm/views/feed.py | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bookwyrm/templates/feed/status.html b/bookwyrm/templates/feed/status.html index b381c3714..64e992a01 100644 --- a/bookwyrm/templates/feed/status.html +++ b/bookwyrm/templates/feed/status.html @@ -6,7 +6,7 @@ {% block opengraph %} - {% include 'snippets/opengraph.html' with image=preview %} + {% include 'snippets/opengraph.html' with image=page_image %} {% endblock %} @@ -39,4 +39,4 @@
    -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index 2d91990d0..d1feb278e 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -185,12 +185,6 @@ class Status(View): params=[status.id, visible_thread, visible_thread], ) - preview = None - if hasattr(status, "book"): - preview = status.book.preview_image - elif status.mention_books.exists(): - preview = status.mention_books.first().preview_image - data = { **feed_page_data(request.user), **{ @@ -199,7 +193,7 @@ class Status(View): "ancestors": ancestors, "title": status.page_title, "description": status.page_description, - "preview": preview, + "page_image": status.page_image, }, } return TemplateResponse(request, "feed/status.html", data) From 646b27b7a7e1099e81d5c3fa4c2b0008f54c889e Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Sat, 20 Jan 2024 17:28:51 +0100 Subject: [PATCH 25/40] OpenGraph: fall back on book cover when preview images are disabled --- bookwyrm/models/status.py | 4 ++-- bookwyrm/templates/book/book.html | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 236826a2b..94893d6ae 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -195,7 +195,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): """image to use as preview in meta tags when only this status is shown""" if self.mention_books.exists(): book = self.mention_books.first() - return book.preview_image + return book.preview_image or book.cover else: return self.user.preview_image @@ -324,7 +324,7 @@ class BookStatus(Status): @property def page_image(self): - return self.book.preview_image or super().page_image + return self.book.preview_image or self.book.cover or super().page_image class Comment(BookStatus): diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 8e76fb014..4c345832e 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -9,7 +9,8 @@ {% block title %}{{ book|book_title }}{% endblock %} {% block opengraph %} - {% include 'snippets/opengraph.html' with title=book.title description=book|book_description image=book.preview_image %} + {% firstof book.preview_image book.cover as book_image %} + {% include 'snippets/opengraph.html' with title=book.title description=book|book_description image=book_image %} {% endblock %} {% block content %} From eb6bea013fd1634f178da689e4843adcd05a6296 Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Sun, 21 Jan 2024 11:04:08 +0100 Subject: [PATCH 26/40] Fix pylint warning --- bookwyrm/models/status.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 94893d6ae..0c9b18cc9 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -196,8 +196,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): if self.mention_books.exists(): book = self.mention_books.first() return book.preview_image or book.cover - else: - return self.user.preview_image + return self.user.preview_image def to_replies(self, **kwargs): """helper function for loading AP serialized replies to a status""" From 30ba8d37dc130ac547c59a5b7c2b7fae3d529214 Mon Sep 17 00:00:00 2001 From: Wesley Aptekar-Cassels Date: Tue, 23 Jan 2024 18:19:31 -0500 Subject: [PATCH 27/40] Add redis automatic rewrite configuration. This should hopefully prevent the AOF file from growing too large. --- redis.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/redis.conf b/redis.conf index 2a417579f..79d6804f5 100644 --- a/redis.conf +++ b/redis.conf @@ -2,6 +2,9 @@ bind 127.0.0.1 ::1 protected-mode yes port 6379 +auto-aof-rewrite-percentage 50 +auto-aof-rewrite-min-size 128mb + rename-command FLUSHDB "" rename-command FLUSHALL "" rename-command DEBUG "" From c4596544a341a5030fe02fe7b1df704f343a35ee Mon Sep 17 00:00:00 2001 From: Rohan Sureshkumar Date: Wed, 24 Jan 2024 19:18:46 +0530 Subject: [PATCH 28/40] Issue-3187: fix failing tests --- bookwyrm/views/feed.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index 79e2f24d2..6e8f820e4 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -52,9 +52,18 @@ class Feed(View): paginated = Paginator(filtered_activities, PAGE_LENGTH) suggestions = suggested_users.get_suggestions(request.user) - cutoff = date(get_annual_summary_year(), 12, 31) - readthroughs = models.ReadThrough.objects.filter( - user=request.user, finish_date__lte=cutoff + + cutoff = ( + date(get_annual_summary_year(), 12, 31) + if get_annual_summary_year() + else None + ) + readthroughs = ( + models.ReadThrough.objects.filter( + user=request.user, finish_date__lte=cutoff + ) + if get_annual_summary_year() + else [] ) data = { From 2d4b11aaeedd9530ad4ddcfcea6f8aeb2b55dda9 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Thu, 25 Jan 2024 01:50:10 +0300 Subject: [PATCH 29/40] Adding FictionBook format ("FB2", "FB3") to autocomplete options in "Get a copy" block. --- bookwyrm/static/js/autocomplete.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bookwyrm/static/js/autocomplete.js b/bookwyrm/static/js/autocomplete.js index a98cd9634..6836d356d 100644 --- a/bookwyrm/static/js/autocomplete.js +++ b/bookwyrm/static/js/autocomplete.js @@ -111,6 +111,10 @@ const tries = { }, }, f: { + b: { + 2: "FB2", + 3: "FB3", + }, l: { a: { c: "FLAC", From 82f9aa9da4ae68c2e042bbb981c89d8089cd39dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Wed, 24 Jan 2024 19:30:45 +0100 Subject: [PATCH 30/40] Set SESSION_COOKIE_AGE from environment, default to one month While we do wish for a longer maximum age (up to one year, see #3082), we only want to do that after termination of active sessions is implemented (see #2278). In the meantime, by reading and setting the variable from settings, we allow site admins to alter the default. --- bookwyrm/settings.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 16241f9df..4af7afb14 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -30,6 +30,9 @@ RELEASE_API = env( PAGE_LENGTH = env.int("PAGE_LENGTH", 15) DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English") +# TODO: extend maximum age to 1 year once termination of active sessions +# is implemented (see bookwyrm-social#2278, bookwyrm-social#3082). +SESSION_COOKIE_AGE = env.int("SESSION_COOKIE_AGE", 3600 * 24 * 30) # 1 month JS_CACHE = "ac315a3b" From 80ad36e75b20213939852470506f12593353216c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Wed, 24 Jan 2024 19:54:55 +0100 Subject: [PATCH 31/40] Include SESSION_COOKIE_AGE in .env.example Suggested-by: Alexey Skobkin --- .env.example | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 20ce8240b..d0971660e 100644 --- a/.env.example +++ b/.env.example @@ -137,6 +137,10 @@ TWO_FACTOR_LOGIN_MAX_SECONDS=60 # and AWS_S3_CUSTOM_DOMAIN (if used) are added by default. # Value should be a comma-separated list of host names. CSP_ADDITIONAL_HOSTS= + # The last number here means "megabytes" # Increase if users are having trouble uploading BookWyrm export files. -DATA_UPLOAD_MAX_MEMORY_SIZE = (1024**2 * 100) \ No newline at end of file +DATA_UPLOAD_MAX_MEMORY_SIZE = (1024**2 * 100) + +# Time before being logged out (in seconds) +# SESSION_COOKIE_AGE=2592000 # current default: 30 days From 31babdfa510d88f89d08cbfb56de94cd8c0ac028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Fri, 26 Jan 2024 06:01:34 -0300 Subject: [PATCH 32/40] Always prefer shared inboxes when computing receipent lists This avoids duplicate submissions to remote instances when mentioning followers (i.e., `POST /user/foo/inbox` followed by `POST /inbox`, which results in two separate `add_status` tasks, and might generate duplicates in the target instance). --- bookwyrm/models/activitypub_mixin.py | 2 +- bookwyrm/tests/models/test_activitypub_mixin.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bookwyrm/models/activitypub_mixin.py b/bookwyrm/models/activitypub_mixin.py index d0a941f43..41772a162 100644 --- a/bookwyrm/models/activitypub_mixin.py +++ b/bookwyrm/models/activitypub_mixin.py @@ -153,7 +153,7 @@ class ActivitypubMixin: mentions = self.recipients if hasattr(self, "recipients") else [] # we always send activities to explicitly mentioned users' inboxes - recipients = [u.inbox for u in mentions or [] if not u.local] + recipients = [u.shared_inbox or u.inbox for u in mentions if not u.local] # unless it's a dm, all the followers should receive the activity if privacy != "direct": diff --git a/bookwyrm/tests/models/test_activitypub_mixin.py b/bookwyrm/tests/models/test_activitypub_mixin.py index cad970412..2f6fad76d 100644 --- a/bookwyrm/tests/models/test_activitypub_mixin.py +++ b/bookwyrm/tests/models/test_activitypub_mixin.py @@ -227,14 +227,18 @@ class ActivitypubMixins(TestCase): shared_inbox="http://example.com/inbox", outbox="https://example.com/users/nutria/outbox", ) - MockSelf = namedtuple("Self", ("privacy", "user")) - mock_self = MockSelf("public", self.local_user) + MockSelf = namedtuple("Self", ("privacy", "user", "recipients")) self.local_user.followers.add(self.remote_user) self.local_user.followers.add(another_remote_user) + mock_self = MockSelf("public", self.local_user, []) recipients = ActivitypubMixin.get_recipients(mock_self) - self.assertEqual(len(recipients), 1) - self.assertEqual(recipients[0], "http://example.com/inbox") + self.assertCountEqual(recipients, ["http://example.com/inbox"]) + + # should also work with recipient that is a follower + mock_self.recipients.append(another_remote_user) + recipients = ActivitypubMixin.get_recipients(mock_self) + self.assertCountEqual(recipients, ["http://example.com/inbox"]) def test_get_recipients_software(self, *_): """should differentiate between bookwyrm and other remote users""" From 8ac873419fe66de65cdddf6a25560ed24c4e4a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Fri, 26 Jan 2024 06:29:59 -0300 Subject: [PATCH 33/40] refactor: eagerly use a set in recipients, get_recipients --- bookwyrm/models/activitypub_mixin.py | 25 +++++++++++++------------ bookwyrm/models/status.py | 6 +++--- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bookwyrm/models/activitypub_mixin.py b/bookwyrm/models/activitypub_mixin.py index 41772a162..db737b8bc 100644 --- a/bookwyrm/models/activitypub_mixin.py +++ b/bookwyrm/models/activitypub_mixin.py @@ -152,8 +152,9 @@ class ActivitypubMixin: # find anyone who's tagged in a status, for example mentions = self.recipients if hasattr(self, "recipients") else [] - # we always send activities to explicitly mentioned users' inboxes - recipients = [u.shared_inbox or u.inbox for u in mentions if not u.local] + # we always send activities to explicitly mentioned users (using shared inboxes + # where available to avoid duplicate submissions to a given instance) + recipients = {u.shared_inbox or u.inbox for u in mentions if not u.local} # unless it's a dm, all the followers should receive the activity if privacy != "direct": @@ -173,18 +174,18 @@ class ActivitypubMixin: if user: queryset = queryset.filter(following=user) - # ideally, we will send to shared inboxes for efficiency - shared_inboxes = ( - queryset.filter(shared_inbox__isnull=False) - .values_list("shared_inbox", flat=True) - .distinct() + # as above, we prefer shared inboxes if available + recipients.update( + queryset.filter(shared_inbox__isnull=False).values_list( + "shared_inbox", flat=True + ) ) - # but not everyone has a shared inbox - inboxes = queryset.filter(shared_inbox__isnull=True).values_list( - "inbox", flat=True + recipients.update( + queryset.filter(shared_inbox__isnull=True).values_list( + "inbox", flat=True + ) ) - recipients += list(shared_inboxes) + list(inboxes) - return list(set(recipients)) + return list(recipients) def to_activity_dataclass(self): """convert from a model to an activity""" diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index cc44fe2bf..0d1d0d839 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -107,14 +107,14 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): @property def recipients(self): """tagged users who definitely need to get this status in broadcast""" - mentions = [u for u in self.mention_users.all() if not u.local] + mentions = {u for u in self.mention_users.all() if not u.local} if ( hasattr(self, "reply_parent") and self.reply_parent and not self.reply_parent.user.local ): - mentions.append(self.reply_parent.user) - return list(set(mentions)) + mentions.add(self.reply_parent.user) + return list(mentions) @classmethod def ignore_activity( From 940274b1c22e08fc870e92cc95e5ae6a95f5297e Mon Sep 17 00:00:00 2001 From: Braden Solt Date: Fri, 26 Jan 2024 15:47:55 -0700 Subject: [PATCH 34/40] classes that fix widths --- bookwyrm/templates/confirm_email/confirm_email.html | 4 ++-- bookwyrm/templates/landing/invite.html | 4 ++-- bookwyrm/templates/landing/login.html | 12 +++++++----- bookwyrm/templates/landing/password_reset.html | 4 ++-- bookwyrm/templates/landing/reactivate.html | 12 +++++++----- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/bookwyrm/templates/confirm_email/confirm_email.html b/bookwyrm/templates/confirm_email/confirm_email.html index abdd3a734..49a1ebd2d 100644 --- a/bookwyrm/templates/confirm_email/confirm_email.html +++ b/bookwyrm/templates/confirm_email/confirm_email.html @@ -6,8 +6,8 @@ {% block content %}

    {% trans "Confirm your email address" %}

    -
    -
    +
    +

    {% trans "A confirmation code has been sent to the email address you used to register your account." %}

    diff --git a/bookwyrm/templates/landing/invite.html b/bookwyrm/templates/landing/invite.html index d56cad38c..3e3ddab85 100644 --- a/bookwyrm/templates/landing/invite.html +++ b/bookwyrm/templates/landing/invite.html @@ -6,8 +6,8 @@ {% block content %}

    {% trans "Create an Account" %}

    -
    -
    +
    +
    {% if valid %}
    diff --git a/bookwyrm/templates/landing/login.html b/bookwyrm/templates/landing/login.html index 369a72bd2..8ea828b74 100644 --- a/bookwyrm/templates/landing/login.html +++ b/bookwyrm/templates/landing/login.html @@ -6,7 +6,7 @@ {% block content %}

    {% trans "Log in" %}

    -
    +
    {% if login_form.non_field_errors %}

    {{ login_form.non_field_errors }}

    {% endif %} @@ -20,13 +20,15 @@
    - +
    - +
    {% include 'snippets/form_errors.html' with errors_list=login_form.password.errors id="desc_password" %} @@ -58,10 +60,10 @@ {% include 'snippets/about.html' %}

    - {% trans "More about this site" %} + {% trans "More about this site" %}

    -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/bookwyrm/templates/landing/password_reset.html b/bookwyrm/templates/landing/password_reset.html index 786eaa0ab..2f41c5505 100644 --- a/bookwyrm/templates/landing/password_reset.html +++ b/bookwyrm/templates/landing/password_reset.html @@ -4,8 +4,8 @@ {% block title %}{% trans "Reset Password" %}{% endblock %} {% block content %} -
    -
    +
    +

    {% trans "Reset Password" %}

    diff --git a/bookwyrm/templates/landing/reactivate.html b/bookwyrm/templates/landing/reactivate.html index da9e0b050..adb41238f 100644 --- a/bookwyrm/templates/landing/reactivate.html +++ b/bookwyrm/templates/landing/reactivate.html @@ -6,7 +6,7 @@ {% block content %}

    {% trans "Reactivate Account" %}

    -
    +
    {% if login_form.non_field_errors %}

    {{ login_form.non_field_errors }}

    {% endif %} @@ -16,13 +16,15 @@
    - +
    - +
    {% include 'snippets/form_errors.html' with errors_list=login_form.password.errors id="desc_password" %} @@ -51,10 +53,10 @@ {% include 'snippets/about.html' %}

    - {% trans "More about this site" %} + {% trans "More about this site" %}

    -{% endblock %} +{% endblock %} \ No newline at end of file From b05621005e14818fd4d529c06b38b4c433a7832d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:10:13 +0000 Subject: [PATCH 35/40] Bump aiohttp from 3.9.0 to 3.9.2 Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.9.0 to 3.9.2. - [Release notes](https://github.com/aio-libs/aiohttp/releases) - [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst) - [Commits](https://github.com/aio-libs/aiohttp/compare/v3.9.0...v3.9.2) --- updated-dependencies: - dependency-name: aiohttp dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6509effc7..41b6bd16d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -aiohttp==3.9.0 +aiohttp==3.9.2 bleach==5.0.1 celery==5.2.7 colorthief==0.2.1 From 6d5752fb4ee72287ed15b84726872a4608842159 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 3 Feb 2024 07:40:23 -0800 Subject: [PATCH 36/40] Adds merge migration for page numbering fix --- bookwyrm/migrations/0193_merge_20240203_1539.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 bookwyrm/migrations/0193_merge_20240203_1539.py diff --git a/bookwyrm/migrations/0193_merge_20240203_1539.py b/bookwyrm/migrations/0193_merge_20240203_1539.py new file mode 100644 index 000000000..a88568ba1 --- /dev/null +++ b/bookwyrm/migrations/0193_merge_20240203_1539.py @@ -0,0 +1,13 @@ +# Generated by Django 3.2.23 on 2024-02-03 15:39 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0192_make_page_positions_text"), + ("bookwyrm", "0192_sitesettings_user_exports_enabled"), + ] + + operations = [] From a1ac9494b28ecd1a1674926d7aad8e82d2502dcf Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 3 Feb 2024 08:00:07 -0800 Subject: [PATCH 37/40] Allow admins to un-schedule tasks --- bookwyrm/templates/settings/schedules.html | 11 +++++++++++ bookwyrm/urls.py | 2 +- bookwyrm/views/admin/schedule.py | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/settings/schedules.html b/bookwyrm/templates/settings/schedules.html index fe096092d..20ced4b30 100644 --- a/bookwyrm/templates/settings/schedules.html +++ b/bookwyrm/templates/settings/schedules.html @@ -61,7 +61,18 @@ {{ task.interval.id }} + + {% if task.enabled %} + + {% endif %} {{ task.enabled|yesno }} + + {% if task.name != "celery.backend_cleanup" %} +
    + {% csrf_token %} + +
    + {% endif %} {% empty %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 64742347a..a40dcebea 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -360,7 +360,7 @@ urlpatterns = [ r"^settings/celery/ping/?$", views.celery_ping, name="settings-celery-ping" ), re_path( - r"^settings/schedules/?$", + r"^settings/schedules/(?P\d+)?$", views.ScheduledTasks.as_view(), name="settings-schedules", ), diff --git a/bookwyrm/views/admin/schedule.py b/bookwyrm/views/admin/schedule.py index ce5944ee5..c654dca9a 100644 --- a/bookwyrm/views/admin/schedule.py +++ b/bookwyrm/views/admin/schedule.py @@ -1,5 +1,6 @@ """ Scheduled celery tasks """ from django.contrib.auth.decorators import login_required, permission_required +from django.shortcuts import redirect from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View @@ -21,3 +22,10 @@ class ScheduledTasks(View): data["tasks"] = PeriodicTask.objects.all() data["schedules"] = IntervalSchedule.objects.all() return TemplateResponse(request, "settings/schedules.html", data) + + # pylint: disable=unused-argument + def post(self, request, task_id): + """un-schedule a task""" + task = PeriodicTask.objects.get(id=task_id) + task.delete() + return redirect("settings-schedules") From 4e2b8af1479bd35bf2b5c5973ff0ae2b4bb1a4fc Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 3 Feb 2024 08:02:51 -0800 Subject: [PATCH 38/40] Adds merge migration --- bookwyrm/migrations/0193_merge_20240203_1602.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 bookwyrm/migrations/0193_merge_20240203_1602.py diff --git a/bookwyrm/migrations/0193_merge_20240203_1602.py b/bookwyrm/migrations/0193_merge_20240203_1602.py new file mode 100644 index 000000000..e5f760539 --- /dev/null +++ b/bookwyrm/migrations/0193_merge_20240203_1602.py @@ -0,0 +1,13 @@ +# Generated by Django 3.2.23 on 2024-02-03 16:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0192_rename_version_sitesettings_available_version"), + ("bookwyrm", "0192_sitesettings_user_exports_enabled"), + ] + + operations = [] From 748c9349865f063689adcaa61e46a26fa3e3bcae Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 3 Feb 2024 08:20:12 -0800 Subject: [PATCH 39/40] Merge migrations upon merge migrations --- ...193_merge_20240203_1602.py => 0194_merge_20240203_1619.py} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename bookwyrm/migrations/{0193_merge_20240203_1602.py => 0194_merge_20240203_1619.py} (63%) diff --git a/bookwyrm/migrations/0193_merge_20240203_1602.py b/bookwyrm/migrations/0194_merge_20240203_1619.py similarity index 63% rename from bookwyrm/migrations/0193_merge_20240203_1602.py rename to bookwyrm/migrations/0194_merge_20240203_1619.py index e5f760539..a5c18e300 100644 --- a/bookwyrm/migrations/0193_merge_20240203_1602.py +++ b/bookwyrm/migrations/0194_merge_20240203_1619.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.23 on 2024-02-03 16:02 +# Generated by Django 3.2.23 on 2024-02-03 16:19 from django.db import migrations @@ -7,7 +7,7 @@ class Migration(migrations.Migration): dependencies = [ ("bookwyrm", "0192_rename_version_sitesettings_available_version"), - ("bookwyrm", "0192_sitesettings_user_exports_enabled"), + ("bookwyrm", "0193_merge_20240203_1539"), ] operations = [] From db629255dba0546e4a1a59cb89e12167b118a66d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 3 Feb 2024 18:27:21 -0800 Subject: [PATCH 40/40] Fixes version number mistakenly reverted --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ee6cdce3c..7486fdbc5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.1 +0.7.2