From 9b949d9845ecd3cd521a4bc51b9164adda29cf57 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 30 Mar 2021 10:19:51 -0700 Subject: [PATCH 1/3] Merges display of lists to show all Rather than separating out "your lists" --- bookwyrm/templates/lists/list_items.html | 8 +++++++- bookwyrm/templates/lists/lists.html | 26 ++++++++---------------- bookwyrm/views/list.py | 16 ++++++--------- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/bookwyrm/templates/lists/list_items.html b/bookwyrm/templates/lists/list_items.html index 04e7f014..3e3e8bf4 100644 --- a/bookwyrm/templates/lists/list_items.html +++ b/bookwyrm/templates/lists/list_items.html @@ -14,7 +14,13 @@ {% endfor %}
- {% if list.description %}{{ list.description | to_markdown | safe | truncatewords_html:20 }}{% endif %} +
+ {% if list.description %} + {{ list.description|to_markdown|safe|truncatechars_html:30 }} + {% else %} +   + {% endif %} +

{% include 'lists/created_text.html' with list=list %}

diff --git a/bookwyrm/templates/lists/lists.html b/bookwyrm/templates/lists/lists.html index f7ab020a..a9258305 100644 --- a/bookwyrm/templates/lists/lists.html +++ b/bookwyrm/templates/lists/lists.html @@ -1,17 +1,19 @@ {% extends 'layout.html' %} +{% load bookwyrm_tags %} {% load i18n %} {% block title %}{% trans "Lists" %}{% endblock %} {% block content %} -
-

{% trans "Lists" %}

-
-{% if request.user.is_authenticated and not lists.has_previous %}
-

{% trans "Your lists" %}

+

+ {% trans "Lists" %} + {% if request.user.is_authenticated %} + Your lists + {% endif %} +

{% trans "Create List" as button_text %} @@ -23,23 +25,11 @@ {% include 'lists/create_form.html' with controls_text="create-list" %}
-
- {% if request.user.list_set.exists %} - {% include 'lists/list_items.html' with lists=request.user.list_set.all|slice:4 %} - {% endif %} - - {% if request.user.list_set.count > 4 %} - {% blocktrans with size=request.user.list_set.count %}See all {{ size }} lists{% endblocktrans %} - {% endif %} -
-{% endif %} - - {% if lists %}
-

{% trans "Recent Lists" %}

{% include 'lists/list_items.html' with lists=lists %}
+
{% include 'snippets/pagination.html' with page=lists path=path %}
diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py index 91475d48..5c88e189 100644 --- a/bookwyrm/views/list.py +++ b/bookwyrm/views/list.py @@ -27,17 +27,13 @@ class Lists(View): except ValueError: page = 1 - user = request.user if request.user.is_authenticated else None # hide lists with no approved books - lists = ( - models.List.objects.filter( - ~Q(user=user), - ) - .annotate(item_count=Count("listitem", filter=Q(listitem__approved=True))) - .filter(item_count__gt=0) - .distinct() - .all() - ) + lists = models.List.objects.annotate( + item_count=Count("listitem", filter=Q(listitem__approved=True)) + ).filter( + item_count__gt=0 + ).distinct().all() + lists = privacy_filter( request.user, lists, privacy_levels=["public", "followers"] ) From f7b0a282a7b756d2f180f76d30359442af463a84 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 30 Mar 2021 10:28:50 -0700 Subject: [PATCH 2/3] Set updated date on list when item is added --- bookwyrm/models/list.py | 5 +++++ bookwyrm/views/list.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/list.py b/bookwyrm/models/list.py index a05325f3..880c4122 100644 --- a/bookwyrm/models/list.py +++ b/bookwyrm/models/list.py @@ -1,6 +1,7 @@ """ make a list of books!! """ from django.apps import apps from django.db import models +from django.utils import timezone from bookwyrm import activitypub from bookwyrm.settings import DOMAIN @@ -79,6 +80,10 @@ class ListItem(CollectionItemMixin, BookWyrmModel): """ create a notification too """ created = not bool(self.id) super().save(*args, **kwargs) + # tick the updated date on the parent list + self.book_list.updated_date = timezone.now() + self.book_list.save(broadcast=False) + list_owner = self.book_list.user # create a notification if somoene ELSE added to a local user's list if created and list_owner.local and list_owner != self.user: diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py index 5c88e189..75ee72ba 100644 --- a/bookwyrm/views/list.py +++ b/bookwyrm/views/list.py @@ -32,7 +32,7 @@ class Lists(View): item_count=Count("listitem", filter=Q(listitem__approved=True)) ).filter( item_count__gt=0 - ).distinct().all() + ).order_by("-updated_date").distinct().all() lists = privacy_filter( request.user, lists, privacy_levels=["public", "followers"] From daea57f91c4df4e9ad885325953f437ca763880f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 30 Mar 2021 10:31:23 -0700 Subject: [PATCH 3/3] Updates python formatting --- bookwyrm/views/list.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py index 75ee72ba..7724cd13 100644 --- a/bookwyrm/views/list.py +++ b/bookwyrm/views/list.py @@ -28,11 +28,15 @@ class Lists(View): page = 1 # hide lists with no approved books - lists = models.List.objects.annotate( - item_count=Count("listitem", filter=Q(listitem__approved=True)) - ).filter( - item_count__gt=0 - ).order_by("-updated_date").distinct().all() + lists = ( + models.List.objects.annotate( + item_count=Count("listitem", filter=Q(listitem__approved=True)) + ) + .filter(item_count__gt=0) + .order_by("-updated_date") + .distinct() + .all() + ) lists = privacy_filter( request.user, lists, privacy_levels=["public", "followers"]