From f7b0a282a7b756d2f180f76d30359442af463a84 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 30 Mar 2021 10:28:50 -0700 Subject: [PATCH] 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 a05325f3f..880c41229 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 5c88e1893..75ee72ba0 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"]