Set updated date on list when item is added

This commit is contained in:
Mouse Reeve 2021-03-30 10:28:50 -07:00
parent 9b949d9845
commit f7b0a282a7
2 changed files with 6 additions and 1 deletions

View file

@ -1,6 +1,7 @@
""" make a list of books!! """ """ make a list of books!! """
from django.apps import apps from django.apps import apps
from django.db import models from django.db import models
from django.utils import timezone
from bookwyrm import activitypub from bookwyrm import activitypub
from bookwyrm.settings import DOMAIN from bookwyrm.settings import DOMAIN
@ -79,6 +80,10 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
""" create a notification too """ """ create a notification too """
created = not bool(self.id) created = not bool(self.id)
super().save(*args, **kwargs) 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 list_owner = self.book_list.user
# create a notification if somoene ELSE added to a local user's list # create a notification if somoene ELSE added to a local user's list
if created and list_owner.local and list_owner != self.user: if created and list_owner.local and list_owner != self.user:

View file

@ -32,7 +32,7 @@ class Lists(View):
item_count=Count("listitem", filter=Q(listitem__approved=True)) item_count=Count("listitem", filter=Q(listitem__approved=True))
).filter( ).filter(
item_count__gt=0 item_count__gt=0
).distinct().all() ).order_by("-updated_date").distinct().all()
lists = privacy_filter( lists = privacy_filter(
request.user, lists, privacy_levels=["public", "followers"] request.user, lists, privacy_levels=["public", "followers"]