diff --git a/bookwyrm/templates/book/book.html b/bookwyrm/templates/book/book.html index bd937a27c..d27c7ec54 100644 --- a/bookwyrm/templates/book/book.html +++ b/bookwyrm/templates/book/book.html @@ -215,10 +215,10 @@ {% endif %} - {% with work=book.parent_work %} + {% with work=book.parent_work editions_count=book.parent_work.editions.count %}

- {% blocktrans trimmed count counter=work.editions.count with count=work.editions.count|intcomma %} + {% blocktrans trimmed count counter=editions_count with count=editions_count|intcomma %} {{ count }} edition {% plural %} {{ count }} editions diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index e838ead12..1227e39c4 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -25,6 +25,7 @@ {% block body %}

diff --git a/bookwyrm/templates/settings/users/user_moderation_actions.html b/bookwyrm/templates/settings/users/user_moderation_actions.html index 72202f379..5bd007e0d 100644 --- a/bookwyrm/templates/settings/users/user_moderation_actions.html +++ b/bookwyrm/templates/settings/users/user_moderation_actions.html @@ -15,6 +15,12 @@

{% endif %} + {% if not user.is_active and user.deactivation_reason == "pending" %} +
+ {% csrf_token %} + +
+ {% endif %} {% if user.is_active or user.deactivation_reason == "pending" %}
{% csrf_token %} diff --git a/bookwyrm/templates/snippets/create_status/comment.html b/bookwyrm/templates/snippets/create_status/comment.html index 65b322699..1186cc71c 100644 --- a/bookwyrm/templates/snippets/create_status/comment.html +++ b/bookwyrm/templates/snippets/create_status/comment.html @@ -19,9 +19,9 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j {# Supplemental fields #}
{% active_shelf book as active_shelf %} - {% if active_shelf.shelf.identifier == 'reading' and book.latest_readthrough %} - + {% if active_shelf.shelf.identifier == 'reading' %} {% with readthrough=book.latest_readthrough %} + {% if readthrough %}
@@ -66,6 +66,7 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j

{% blocktrans with pages=book.pages %}of {{ pages }} pages{% endblocktrans %}

{% endif %}
+ {% endif %} {% endwith %} {% endif %}
diff --git a/bookwyrm/templates/snippets/status/headers/generatednote.html b/bookwyrm/templates/snippets/status/headers/generatednote.html index 6a34dcd11..398dc09db 100644 --- a/bookwyrm/templates/snippets/status/headers/generatednote.html +++ b/bookwyrm/templates/snippets/status/headers/generatednote.html @@ -4,11 +4,11 @@ {# Three day cache #} {% get_current_language as LANGUAGE_CODE %} {% cache 259200 generated_note_header LANGUAGE_CODE status.id %} -{% if status.content == 'wants to read' %} +{% if status.content == 'wants to read' or status.content == '

wants to read

' %} {% include 'snippets/status/headers/to_read.html' with book=status.mention_books.first %} -{% elif status.content == 'finished reading' %} +{% elif status.content == 'finished reading' or status.content == '

finished reading

' %} {% include 'snippets/status/headers/read.html' with book=status.mention_books.first %} -{% elif status.content == 'started reading' %} +{% elif status.content == 'started reading' or status.content == '

started reading

' %} {% include 'snippets/status/headers/reading.html' with book=status.mention_books.first %} {% else %} {{ status.content }} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 6f70280ec..5050e029a 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -145,6 +145,11 @@ urlpatterns = [ views.UserAdmin.as_view(), name="settings-user", ), + re_path( + r"^settings/users/(?P\d+)/activate/?$", + views.ActivateUserAdmin.as_view(), + name="settings-activate-user", + ), re_path( r"^settings/federation/(?P(federated|blocked))?/?$", views.Federation.as_view(), diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 0a431318c..b1ab977a7 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -31,7 +31,7 @@ from .admin.reports import ( ) from .admin.site import Site, Registration, RegistrationLimited from .admin.themes import Themes, delete_theme -from .admin.user_admin import UserAdmin, UserAdminList +from .admin.user_admin import UserAdmin, UserAdminList, ActivateUserAdmin # user preferences from .preferences.change_password import ChangePassword diff --git a/bookwyrm/views/admin/user_admin.py b/bookwyrm/views/admin/user_admin.py index 4611a388c..c793d3bff 100644 --- a/bookwyrm/views/admin/user_admin.py +++ b/bookwyrm/views/admin/user_admin.py @@ -1,7 +1,7 @@ """ manage user """ from django.contrib.auth.decorators import login_required, permission_required from django.core.paginator import Paginator -from django.shortcuts import get_object_or_404 +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 @@ -95,3 +95,19 @@ class UserAdmin(View): form.save(request) data = {"user": user, "group_form": form} return TemplateResponse(request, "settings/users/user.html", data) + + +@method_decorator(login_required, name="dispatch") +@method_decorator( + permission_required("bookwyrm.moderate_user", raise_exception=True), + name="dispatch", +) +class ActivateUserAdmin(View): + """activate a user manually""" + + # pylint: disable=unused-argument + def post(self, request, user): + """activate user""" + user = get_object_or_404(models.User, id=user) + user.reactivate() + return redirect("settings-user", user.id) diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index 6d7aeb239..17218b93e 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -237,16 +237,24 @@ def feed_page_data(user): def get_suggested_books(user, max_books=5): """helper to get a user's recent books""" book_count = 0 - preset_shelves = [("reading", max_books), ("read", 2), ("to-read", max_books)] + preset_shelves = {"reading": max_books, "read": 2, "to-read": max_books} suggested_books = [] - for (preset, shelf_max) in preset_shelves: + + user_shelves = { + shelf.identifier: shelf + for shelf in user.shelf_set.filter( + identifier__in=preset_shelves.keys() + ).exclude(books__isnull=True) + } + + for preset, shelf_max in preset_shelves.items(): limit = ( shelf_max if shelf_max < (max_books - book_count) else max_books - book_count ) - shelf = user.shelf_set.get(identifier=preset) - if not shelf.books.exists(): + shelf = user_shelves.get(preset, None) + if not shelf: continue shelf_preview = {