From f5fb5ae04572b1ea6175c954ceb9ca64055a9521 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 09:34:30 -0800 Subject: [PATCH 01/26] Removes instance config file I'd be happy to re-add this if it's useful, but I think it's confusing to have in addition to themes --- .css-config-sample/_instance-settings.scss | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .css-config-sample/_instance-settings.scss diff --git a/.css-config-sample/_instance-settings.scss b/.css-config-sample/_instance-settings.scss deleted file mode 100644 index e86c1ce0..00000000 --- a/.css-config-sample/_instance-settings.scss +++ /dev/null @@ -1,3 +0,0 @@ -@charset "utf-8"; - -// Copy this file to bookwyrm/static/css/ and set your instance custom styles. From 2d516812b4a445e3b4e6dc562b6582fa52cdec04 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 09:34:54 -0800 Subject: [PATCH 02/26] Fixes icons by moving import to theme --- bookwyrm/static/css/bookwyrm.scss | 2 -- bookwyrm/static/css/themes/bookwyrm-dark.scss | 1 + bookwyrm/static/css/themes/bookwyrm-light.scss | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/static/css/bookwyrm.scss b/bookwyrm/static/css/bookwyrm.scss index ee25b728..43779545 100644 --- a/bookwyrm/static/css/bookwyrm.scss +++ b/bookwyrm/static/css/bookwyrm.scss @@ -1,6 +1,4 @@ @charset "utf-8"; -@import "instance-settings"; @import "vendor/bulma/bulma.sass"; -@import "vendor/icons.css"; @import "bookwyrm/all.scss"; diff --git a/bookwyrm/static/css/themes/bookwyrm-dark.scss b/bookwyrm/static/css/themes/bookwyrm-dark.scss index 32e33907..b2a6f582 100644 --- a/bookwyrm/static/css/themes/bookwyrm-dark.scss +++ b/bookwyrm/static/css/themes/bookwyrm-dark.scss @@ -55,3 +55,4 @@ $family-primary: $family-sans-serif; $family-secondary: $family-sans-serif; @import "../bookwyrm.scss"; +@import "../vendor/icons.css"; diff --git a/bookwyrm/static/css/themes/bookwyrm-light.scss b/bookwyrm/static/css/themes/bookwyrm-light.scss index 08e6a291..02992bff 100644 --- a/bookwyrm/static/css/themes/bookwyrm-light.scss +++ b/bookwyrm/static/css/themes/bookwyrm-light.scss @@ -53,3 +53,4 @@ $family-primary: $family-sans-serif; $family-secondary: $family-sans-serif; @import "../bookwyrm.scss"; +@import "../vendor/icons.css"; From f54d4863fe968d0e28b32bb320bacc2fbfb5d5e3 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 09:37:51 -0800 Subject: [PATCH 03/26] Updates .gitignore for themes --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 92fc85bc..ec2a08f8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,8 @@ .env /images/ bookwyrm/static/css/bookwyrm.css -bookwyrm/static/css/_instance-settings.scss +bookwyrm/static/css/themes/ +!bookwyrm/static/css/themes/bookwyrm-*.scss # Testing .coverage From a00ee8a7062df15104fafeb4ce054e011d4e901b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 09:43:31 -0800 Subject: [PATCH 04/26] Adds link to set instance-wide theme --- bookwyrm/templates/settings/themes.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bookwyrm/templates/settings/themes.html b/bookwyrm/templates/settings/themes.html index 11c34405..e3035b2f 100644 --- a/bookwyrm/templates/settings/themes.html +++ b/bookwyrm/templates/settings/themes.html @@ -5,6 +5,12 @@ {% block header %}{% trans "Themes" %}{% endblock %} +{% block breadcrumbs %} + + {% trans "Set instance default theme" %} + +{% endblock %} + {% block panel %} {% if success %}
From 295d9c42d79c4a33a162fc0ddbc481eb857c9390 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 09:45:34 -0800 Subject: [PATCH 05/26] Adds theme to user settings form --- bookwyrm/forms.py | 1 + bookwyrm/templates/preferences/edit_user.html | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 01228b8e..0baaaa21 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -155,6 +155,7 @@ class EditUserForm(CustomForm): "discoverable", "preferred_timezone", "preferred_language", + "theme", ] help_texts = {f: None for f in fields} widgets = { diff --git a/bookwyrm/templates/preferences/edit_user.html b/bookwyrm/templates/preferences/edit_user.html index 642d177c..e55311ae 100644 --- a/bookwyrm/templates/preferences/edit_user.html +++ b/bookwyrm/templates/preferences/edit_user.html @@ -97,6 +97,12 @@ {{ form.preferred_language }}
+
+ +
+ {{ form.theme }} +
+
From 106ef2e3a49139ec8575529c0644caca7918cce1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 09:46:05 -0800 Subject: [PATCH 06/26] Fixes reference to theme in layout --- bookwyrm/templates/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index aaf21717..444241e5 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -9,7 +9,7 @@ {% block title %}BookWyrm{% endblock %} - {{ site.name }} {% with theme_path=user.get_theme %} - + {% endwith %} From c82042f5060ff5976d0814ae3c2ae15584fabd06 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 09:54:07 -0800 Subject: [PATCH 07/26] Delete themes --- bookwyrm/templates/settings/themes.html | 8 ++++++-- bookwyrm/urls.py | 5 +++++ bookwyrm/views/__init__.py | 2 +- bookwyrm/views/admin/themes.py | 11 +++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/settings/themes.html b/bookwyrm/templates/settings/themes.html index e3035b2f..d3dac804 100644 --- a/bookwyrm/templates/settings/themes.html +++ b/bookwyrm/templates/settings/themes.html @@ -123,8 +123,12 @@ {{ theme.name }} {{ theme.path }} -
- + + {% csrf_token %} +
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index bef6786d..415af912 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -87,6 +87,11 @@ urlpatterns = [ ), re_path(r"^settings/site-settings/?$", views.Site.as_view(), name="settings-site"), re_path(r"^settings/themes/?$", views.Themes.as_view(), name="settings-themes"), + re_path( + r"^settings/themes/(?P\d+)/delete/?$", + views.delete_theme, + name="settings-themes-delete", + ), re_path( r"^settings/announcements/?$", views.Announcements.as_view(), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 675221cb..957a0f6e 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -21,7 +21,7 @@ from .admin.reports import ( moderator_delete_user, ) from .admin.site import Site -from .admin.themes import Themes +from .admin.themes import Themes, delete_theme from .admin.user_admin import UserAdmin, UserAdminList # user preferences diff --git a/bookwyrm/views/admin/themes.py b/bookwyrm/views/admin/themes.py index c1eacf44..12b449af 100644 --- a/bookwyrm/views/admin/themes.py +++ b/bookwyrm/views/admin/themes.py @@ -2,9 +2,11 @@ from django.contrib.auth.decorators import login_required, permission_required from django.contrib.staticfiles.utils import get_files from django.contrib.staticfiles.storage import StaticFilesStorage +from django.shortcuts import get_object_or_404, redirect 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 bookwyrm import forms, models @@ -46,3 +48,12 @@ def get_view_data(): "choices": [c for c in choices if c not in current and c[-5:] == ".scss"], "theme_form": forms.ThemeForm(), } + + +@require_POST +@permission_required("bookwyrm.edit_instance_settings", raise_exception=True) +# pylint: disable=unused-argument +def delete_theme(request, theme_id): + """Remove a theme""" + get_object_or_404(models.Theme, id=theme_id).delete() + return redirect("settings-themes") From 202696f913e8cd4b2b347cb2e9b958e1d0f65866 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 10:03:24 -0800 Subject: [PATCH 08/26] Don't show lists a book is already on in add form --- bookwyrm/templates/book/book.html | 4 ++-- bookwyrm/views/books/books.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index 60e3d4fd..0e2fd5d3 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -352,7 +352,7 @@ {% endfor %} - {% if request.user.list_set.exists %} + {% if list_options.exists %}
{% csrf_token %} @@ -361,7 +361,7 @@
diff --git a/bookwyrm/views/books/books.py b/bookwyrm/views/books/books.py index e04230ba..ad7ee943 100644 --- a/bookwyrm/views/books/books.py +++ b/bookwyrm/views/books/books.py @@ -83,6 +83,7 @@ class Book(View): } if request.user.is_authenticated: + data["list_options"] = request.user.list_set.exclude(id__in=data["lists"]) data["file_link_form"] = forms.FileLinkForm() readthroughs = models.ReadThrough.objects.filter( user=request.user, From b2b3ba653e1d1139ac36e51d38541c0c9cd83a46 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 10:29:58 -0800 Subject: [PATCH 09/26] Refactors how success/failure messages how on list page --- bookwyrm/templates/lists/list.html | 25 ++++++++++++++++++------- bookwyrm/views/list/list.py | 23 ++++++++--------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html index 1c26733d..73ea7dba 100644 --- a/bookwyrm/templates/lists/list.html +++ b/bookwyrm/templates/lists/list.html @@ -30,13 +30,24 @@
- {% if request.GET.updated %} -
- {% if list.curation != "open" and request.user != list.user and not list.group|is_member:request.user %} - {% trans "You successfully suggested a book for this list!" %} - {% else %} - {% trans "You successfully added a book to this list!" %} - {% endif %} + {% if add_succeeded %} +
+ + + {% if list.curation != "open" and request.user != list.user and not list.group|is_member:request.user %} + {% trans "You successfully suggested a book for this list!" %} + {% else %} + {% trans "You successfully added a book to this list!" %} + {% endif %} + +
+ {% endif %} + {% if add_failed %} +
+ + + {% trans "That book is already on this list." %} +
{% endif %} diff --git a/bookwyrm/views/list/list.py b/bookwyrm/views/list/list.py index fbbbee9f..0b228200 100644 --- a/bookwyrm/views/list/list.py +++ b/bookwyrm/views/list/list.py @@ -1,11 +1,10 @@ """ book list views""" from typing import Optional -from urllib.parse import urlencode from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied from django.core.paginator import Paginator -from django.db import IntegrityError, transaction +from django.db import transaction from django.db.models import Avg, DecimalField, Q, Max from django.db.models.functions import Coalesce from django.http import HttpResponseBadRequest, HttpResponse @@ -26,7 +25,7 @@ from bookwyrm.views.helpers import is_api_request class List(View): """book list page""" - def get(self, request, list_id): + def get(self, request, list_id, add_failed=False, add_succeeded=True): """display a book list""" book_list = get_object_or_404(models.List, id=list_id) book_list.raise_visible_to_user(request.user) @@ -110,6 +109,8 @@ class List(View): {"direction": direction, "sort_by": sort_by} ), "embed_url": embed_url, + "add_failed": add_failed, + "add_succeeded": add_succeeded, } return TemplateResponse(request, "lists/list.html", data) @@ -179,8 +180,8 @@ def add_book(request): form = forms.ListItemForm(request.POST) if not form.is_valid(): - # this shouldn't happen, there aren't validated fields - raise Exception(form.errors) + return List().get(request, book_list.id, add_failed=True) + item = form.save(commit=False) if book_list.curation == "curated": @@ -196,17 +197,9 @@ def add_book(request): ) or 0 increment_order_in_reverse(book_list.id, order_max + 1) item.order = order_max + 1 + item.save() - try: - item.save() - except IntegrityError: - # if the book is already on the list, don't flip out - pass - - path = reverse("list", args=[book_list.id]) - params = request.GET.copy() - params["updated"] = True - return redirect(f"{path}?{urlencode(params)}") + return List().get(request, book_list.id, add_succeeded=True) @require_POST From 99fc3aaf25873eca683f8db6e2b3eee7c2448f2a Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 10:31:58 -0800 Subject: [PATCH 10/26] Avoid showing success and failure --- bookwyrm/templates/lists/list.html | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bookwyrm/templates/lists/list.html b/bookwyrm/templates/lists/list.html index 73ea7dba..1d5abd89 100644 --- a/bookwyrm/templates/lists/list.html +++ b/bookwyrm/templates/lists/list.html @@ -30,7 +30,14 @@
- {% if add_succeeded %} + {% if add_failed %} +
+ + + {% trans "That book is already on this list." %} + +
+ {% elif add_succeeded %}
@@ -42,14 +49,6 @@
{% endif %} - {% if add_failed %} -
- - - {% trans "That book is already on this list." %} - -
- {% endif %} {% if not items.object_list.exists %}

{% trans "This list is currently empty" %}

From 142cc5437ae6f874e2cebe26cf9dfa7e883f26c2 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 10:41:40 -0800 Subject: [PATCH 11/26] Move sorting to separate function --- bookwyrm/views/list/list.py | 67 ++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/bookwyrm/views/list/list.py b/bookwyrm/views/list/list.py index 0b228200..dc1843fa 100644 --- a/bookwyrm/views/list/list.py +++ b/bookwyrm/views/list/list.py @@ -25,7 +25,7 @@ from bookwyrm.views.helpers import is_api_request class List(View): """book list page""" - def get(self, request, list_id, add_failed=False, add_succeeded=True): + def get(self, request, list_id, add_failed=False, add_succeeded=False): """display a book list""" book_list = get_object_or_404(models.List, id=list_id) book_list.raise_visible_to_user(request.user) @@ -36,33 +36,10 @@ class List(View): query = request.GET.get("q") suggestions = None - # sort_by shall be "order" unless a valid alternative is given - sort_by = request.GET.get("sort_by", "order") - if sort_by not in ("order", "title", "rating"): - sort_by = "order" - - # direction shall be "ascending" unless a valid alternative is given - direction = request.GET.get("direction", "ascending") - if direction not in ("ascending", "descending"): - direction = "ascending" - - directional_sort_by = { - "order": "order", - "title": "book__title", - "rating": "average_rating", - }[sort_by] - if direction == "descending": - directional_sort_by = "-" + directional_sort_by - - items = book_list.listitem_set.prefetch_related("user", "book", "book__authors") - if sort_by == "rating": - items = items.annotate( - average_rating=Avg( - Coalesce("book__review__rating", 0.0), - output_field=DecimalField(), - ) - ) - items = items.filter(approved=True).order_by(directional_sort_by) + items = book_list.listitem_set.filter(approved=True).prefetch_related( + "user", "book", "book__authors" + ) + items = sort_list(request, items) paginated = Paginator(items, PAGE_LENGTH) @@ -105,9 +82,7 @@ class List(View): "suggested_books": suggestions, "list_form": forms.ListForm(instance=book_list), "query": query or "", - "sort_form": forms.SortListForm( - {"direction": direction, "sort_by": sort_by} - ), + "sort_form": forms.SortListForm(request.GET), "embed_url": embed_url, "add_failed": add_failed, "add_succeeded": add_succeeded, @@ -132,6 +107,36 @@ class List(View): return redirect(book_list.local_path) +def sort_list(request, items): + """helper to handle the surprisngly involved sorting""" + # sort_by shall be "order" unless a valid alternative is given + sort_by = request.GET.get("sort_by", "order") + if sort_by not in ("order", "title", "rating"): + sort_by = "order" + + # direction shall be "ascending" unless a valid alternative is given + direction = request.GET.get("direction", "ascending") + if direction not in ("ascending", "descending"): + direction = "ascending" + + directional_sort_by = { + "order": "order", + "title": "book__title", + "rating": "average_rating", + }[sort_by] + if direction == "descending": + directional_sort_by = "-" + directional_sort_by + + if sort_by == "rating": + items = items.annotate( + average_rating=Avg( + Coalesce("book__review__rating", 0.0), + output_field=DecimalField(), + ) + ) + return items.order_by(directional_sort_by) + + @require_POST @login_required def save_list(request, list_id): From 374dd24fa839fd1e6712e3d68936ebaf53a50423 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 10:47:08 -0800 Subject: [PATCH 12/26] Remove reviews from deleted users --- bookwyrm/models/status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 29b3ba9c..17fcd458 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -227,7 +227,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): @classmethod def privacy_filter(cls, viewer, privacy_levels=None): queryset = super().privacy_filter(viewer, privacy_levels=privacy_levels) - return queryset.filter(deleted=False) + return queryset.filter(deleted=False, user__is_active=True) @classmethod def direct_filter(cls, queryset, viewer): From 0f5fd6be155533000ca35ec12970cb1afc6144e9 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 11:05:12 -0800 Subject: [PATCH 13/26] Move translations to filter --- .../snippets/translated_shelf_name.html | 14 +++----------- bookwyrm/templatetags/shelf_tags.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/bookwyrm/templates/snippets/translated_shelf_name.html b/bookwyrm/templates/snippets/translated_shelf_name.html index 4da47e37..966135f5 100644 --- a/bookwyrm/templates/snippets/translated_shelf_name.html +++ b/bookwyrm/templates/snippets/translated_shelf_name.html @@ -1,12 +1,4 @@ {% load i18n %} -{% if shelf.identifier == 'all' %} - {% trans "All books" %} -{% elif shelf.identifier == 'to-read' %} - {% trans "To Read" %} -{% elif shelf.identifier == 'reading' %} - {% trans "Currently Reading" %} -{% elif shelf.identifier == 'read' %} - {% trans "Read" %} -{% else %} - {{ shelf.name }} -{% endif %} +{% load shelf_tags %} + +{{ shelf|translate_shelf_name }} diff --git a/bookwyrm/templatetags/shelf_tags.py b/bookwyrm/templatetags/shelf_tags.py index 6c4f59c3..a2788826 100644 --- a/bookwyrm/templatetags/shelf_tags.py +++ b/bookwyrm/templatetags/shelf_tags.py @@ -1,5 +1,6 @@ """ Filters and tags related to shelving books """ from django import template +from django.utils.translation import gettext_lazy as _ from bookwyrm import models from bookwyrm.utils import cache @@ -32,6 +33,23 @@ def get_next_shelf(current_shelf): return "to-read" +@register.filter(name="translate_shelf_name") +def get_translated_shelf_name(shelf): + """produced translated shelf nidentifierame""" + if not shelf: + return "" + identifier = shelf.identifier + if identifier == "all": + return _("All books") + if identifier == "to-read": + return _("To Read") + if identifier == "reading": + return _("Currently Reading") + if identifier == "read": + return _("Read") + return shelf.name + + @register.simple_tag(takes_context=True) def active_shelf(context, book): """check what shelf a user has a book on, if any""" From ffb4098cfb565423deeec5b2bf7e2e6ecef0ed63 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 11:07:12 -0800 Subject: [PATCH 14/26] Fixes translation of "remove from shelf" string --- bookwyrm/templates/snippets/shelf_selector.html | 4 +++- .../shelve_button/shelve_button_dropdown_options.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index 4b3ad4bd..a5f768a7 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -71,7 +71,9 @@ {% csrf_token %} - + {% endif %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html index 1fa26a88..75dad0c8 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -63,7 +63,7 @@ From 7d6032e1102956758c32fe7a7348abcb0beef0c7 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 11:17:52 -0800 Subject: [PATCH 15/26] Fixes calls to filter --- bookwyrm/templates/snippets/shelf_selector.html | 2 +- .../shelve_button/shelve_button_dropdown_options.html | 2 +- bookwyrm/templatetags/shelf_tags.py | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/snippets/shelf_selector.html b/bookwyrm/templates/snippets/shelf_selector.html index a5f768a7..2d1f2a83 100644 --- a/bookwyrm/templates/snippets/shelf_selector.html +++ b/bookwyrm/templates/snippets/shelf_selector.html @@ -72,7 +72,7 @@ diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html index 75dad0c8..2b87e21f 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -63,7 +63,7 @@ diff --git a/bookwyrm/templatetags/shelf_tags.py b/bookwyrm/templatetags/shelf_tags.py index a2788826..4c15786a 100644 --- a/bookwyrm/templatetags/shelf_tags.py +++ b/bookwyrm/templatetags/shelf_tags.py @@ -38,7 +38,8 @@ def get_translated_shelf_name(shelf): """produced translated shelf nidentifierame""" if not shelf: return "" - identifier = shelf.identifier + # support obj or dict + identifier = shelf["identifier"] if isinstance(shelf, dict) else shelf.identifier if identifier == "all": return _("All books") if identifier == "to-read": @@ -47,7 +48,7 @@ def get_translated_shelf_name(shelf): return _("Currently Reading") if identifier == "read": return _("Read") - return shelf.name + return shelf["name"] if isinstance(shelf, dict) else shelf.name @register.simple_tag(takes_context=True) From e90cb52f2339f3d6f70c1d323349573bcc49d130 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 28 Feb 2022 11:48:49 -0800 Subject: [PATCH 16/26] Add option to hide follows --- bookwyrm/activitypub/person.py | 1 + bookwyrm/forms.py | 1 + bookwyrm/migrations/0142_user_hide_follows.py | 19 +++++++++++++++++++ bookwyrm/models/user.py | 1 + bookwyrm/templates/preferences/edit_user.html | 6 ++++++ 5 files changed, 28 insertions(+) create mode 100644 bookwyrm/migrations/0142_user_hide_follows.py diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index 576e7f9a..61c15a57 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -39,4 +39,5 @@ class Person(ActivityObject): bookwyrmUser: bool = False manuallyApprovesFollowers: str = False discoverable: str = False + hideFollows: str = False type: str = "Person" diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 7ae4e446..33d453e6 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -153,6 +153,7 @@ class EditUserForm(CustomForm): "manually_approves_followers", "default_post_privacy", "discoverable", + "hide_follows", "preferred_timezone", "preferred_language", ] diff --git a/bookwyrm/migrations/0142_user_hide_follows.py b/bookwyrm/migrations/0142_user_hide_follows.py new file mode 100644 index 00000000..f052d7ef --- /dev/null +++ b/bookwyrm/migrations/0142_user_hide_follows.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.12 on 2022-02-28 19:44 + +import bookwyrm.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0141_alter_report_status"), + ] + + operations = [ + migrations.AddField( + model_name="user", + name="hide_follows", + field=bookwyrm.models.fields.BooleanField(default=False), + ), + ] diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 6367dcae..7ebe9b96 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -136,6 +136,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): updated_date = models.DateTimeField(auto_now=True) last_active_date = models.DateTimeField(default=timezone.now) manually_approves_followers = fields.BooleanField(default=False) + hide_follows = fields.BooleanField(default=False) # options to turn features on and off show_goal = models.BooleanField(default=True) diff --git a/bookwyrm/templates/preferences/edit_user.html b/bookwyrm/templates/preferences/edit_user.html index 642d177c..13cbd139 100644 --- a/bookwyrm/templates/preferences/edit_user.html +++ b/bookwyrm/templates/preferences/edit_user.html @@ -111,6 +111,12 @@ {% trans "Manually approve followers" %}
+
+ +