From 74573b5355b28d8d191440a0a181a36074dd1981 Mon Sep 17 00:00:00 2001 From: Joachim Date: Wed, 14 Apr 2021 20:07:51 +0200 Subject: [PATCH 1/3] Restrict list creation form to authenticated users When visiting the `/list` route on an instance while unauthenticated, the button to toggle the List creation form is shown. This PR aims to hide the button to unauthenticated visitors. --- bookwyrm/templates/lists/lists.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bookwyrm/templates/lists/lists.html b/bookwyrm/templates/lists/lists.html index 27e56f11a..c7d789d0a 100644 --- a/bookwyrm/templates/lists/lists.html +++ b/bookwyrm/templates/lists/lists.html @@ -15,10 +15,12 @@ {% endif %} + {% if request.user.is_authenticated %}
{% trans "Create List" as button_text %} {% include 'snippets/toggle/open_button.html' with controls_text="create-list" icon="plus" text=button_text focus="create-list-header" %}
+ {% endif %}
From 88d37736eea7d07580e1b9826416125b9a9a7728 Mon Sep 17 00:00:00 2001 From: Pablo Barton Date: Wed, 14 Apr 2021 21:57:34 -0400 Subject: [PATCH 2/3] 902 using get_page for Paginator instead of page --- bookwyrm/models/activitypub_mixin.py | 2 +- bookwyrm/views/books.py | 4 ++-- bookwyrm/views/directory.py | 2 +- bookwyrm/views/federation.py | 2 +- bookwyrm/views/feed.py | 4 ++-- bookwyrm/views/invite.py | 4 ++-- bookwyrm/views/list.py | 4 ++-- bookwyrm/views/shelf.py | 2 +- bookwyrm/views/user.py | 2 +- bookwyrm/views/user_admin.py | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bookwyrm/models/activitypub_mixin.py b/bookwyrm/models/activitypub_mixin.py index ce16460e6..719debff6 100644 --- a/bookwyrm/models/activitypub_mixin.py +++ b/bookwyrm/models/activitypub_mixin.py @@ -524,7 +524,7 @@ def to_ordered_collection_page( """ serialize and pagiante a queryset """ paginated = Paginator(queryset, PAGE_LENGTH) - activity_page = paginated.page(page) + activity_page = paginated.get_page(page) if id_only: items = [s.remote_id for s in activity_page.object_list] else: diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py index 731fc24c6..c3ac4f492 100644 --- a/bookwyrm/views/books.py +++ b/bookwyrm/views/books.py @@ -60,7 +60,7 @@ class Book(View): paginated = Paginator( reviews.exclude(Q(content__isnull=True) | Q(content="")), PAGE_LENGTH ) - reviews_page = paginated.page(page) + reviews_page = paginated.get_page(page) user_tags = readthroughs = user_shelves = other_edition_shelves = [] if request.user.is_authenticated: @@ -285,7 +285,7 @@ class Editions(View): paginated = Paginator(editions.filter(**filters).all(), PAGE_LENGTH) data = { - "editions": paginated.page(page), + "editions": paginated.get_page(page), "work": work, "languages": languages, "formats": set( diff --git a/bookwyrm/views/directory.py b/bookwyrm/views/directory.py index 9504734e8..2565f4ec5 100644 --- a/bookwyrm/views/directory.py +++ b/bookwyrm/views/directory.py @@ -39,7 +39,7 @@ class Directory(View): paginated = Paginator(users, 12) data = { - "users": paginated.page(page), + "users": paginated.get_page(page), } return TemplateResponse(request, "directory/directory.html", data) diff --git a/bookwyrm/views/federation.py b/bookwyrm/views/federation.py index db54cd7aa..3803e92e9 100644 --- a/bookwyrm/views/federation.py +++ b/bookwyrm/views/federation.py @@ -40,7 +40,7 @@ class Federation(View): paginated = Paginator(servers, PAGE_LENGTH) data = { - "servers": paginated.page(page), + "servers": paginated.get_page(page), "sort": sort, "form": forms.ServerForm(), } diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py index d5e644343..1286d797b 100644 --- a/bookwyrm/views/feed.py +++ b/bookwyrm/views/feed.py @@ -39,7 +39,7 @@ class Feed(View): **feed_page_data(request.user), **{ "user": request.user, - "activities": paginated.page(page), + "activities": paginated.get_page(page), "suggested_users": suggested_users, "tab": tab, "goal_form": forms.GoalForm(), @@ -82,7 +82,7 @@ class DirectMessage(View): ).order_by("-published_date") paginated = Paginator(activities, PAGE_LENGTH) - activity_page = paginated.page(page) + activity_page = paginated.get_page(page) data = { **feed_page_data(request.user), **{ diff --git a/bookwyrm/views/invite.py b/bookwyrm/views/invite.py index 61f031ef5..03b31b7b5 100644 --- a/bookwyrm/views/invite.py +++ b/bookwyrm/views/invite.py @@ -43,7 +43,7 @@ class ManageInvites(View): ) data = { - "invites": paginated.page(page), + "invites": paginated.get_page(page), "form": forms.CreateInviteForm(), } return TemplateResponse(request, "settings/manage_invites.html", data) @@ -136,7 +136,7 @@ class ManageInviteRequests(View): data = { "ignored": ignored, "count": paginated.count, - "requests": paginated.page(page), + "requests": paginated.get_page(page), "sort": sort, } return TemplateResponse(request, "settings/manage_invite_requests.html", data) diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py index 3d85280d3..27e36dc5f 100644 --- a/bookwyrm/views/list.py +++ b/bookwyrm/views/list.py @@ -44,7 +44,7 @@ class Lists(View): paginated = Paginator(lists, 12) data = { - "lists": paginated.page(page), + "lists": paginated.get_page(page), "list_form": forms.ListForm(), "path": "/list", } @@ -79,7 +79,7 @@ class UserLists(View): data = { "user": user, "is_self": request.user.id == user.id, - "lists": paginated.page(page), + "lists": paginated.get_page(page), "list_form": forms.ListForm(), "path": user.local_path + "/lists", } diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index 888999493..740439db6 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -70,7 +70,7 @@ class Shelf(View): "is_self": is_self, "shelves": shelves.all(), "shelf": shelf, - "books": paginated.page(page), + "books": paginated.get_page(page), } return TemplateResponse(request, "user/shelf.html", data) diff --git a/bookwyrm/views/user.py b/bookwyrm/views/user.py index d666f064e..26117a928 100644 --- a/bookwyrm/views/user.py +++ b/bookwyrm/views/user.py @@ -87,7 +87,7 @@ class User(View): "is_self": is_self, "shelves": shelf_preview, "shelf_count": shelves.count(), - "activities": paginated.page(page), + "activities": paginated.get_page(page), "goal": goal, } diff --git a/bookwyrm/views/user_admin.py b/bookwyrm/views/user_admin.py index a8c155a16..1eb6089f8 100644 --- a/bookwyrm/views/user_admin.py +++ b/bookwyrm/views/user_admin.py @@ -46,5 +46,5 @@ class UserAdmin(View): users = users.order_by(sort) paginated = Paginator(users, PAGE_LENGTH) - data = {"users": paginated.page(page), "sort": sort, "server": server} + data = {"users": paginated.get_page(page), "sort": sort, "server": server} return TemplateResponse(request, "settings/user_admin.html", data) From adaaf8da679420de879c023af473b444d021f135 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 15 Apr 2021 10:29:56 -0700 Subject: [PATCH 3/3] Fixes typo in populate streams command --- bookwyrm/management/commands/populate_streams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/management/commands/populate_streams.py b/bookwyrm/management/commands/populate_streams.py index 06ca5f075..4cd2036a0 100644 --- a/bookwyrm/management/commands/populate_streams.py +++ b/bookwyrm/management/commands/populate_streams.py @@ -17,7 +17,7 @@ def populate_streams(): ) for user in users: for stream in activitystreams.streams.values(): - stream.populate_stream(user) + stream.populate_streams(user) class Command(BaseCommand):