Revert "clean up List db queries"

This reverts commit 41f27a4a66.

I forgot that update() can only be done on a query result, not on an object, so we will need to go back to querying in order to update rather than saving.
This commit is contained in:
Hugh Rundle
2021-10-16 06:59:07 +11:00
parent 1634c8774e
commit 2f38af4faa
2 changed files with 8 additions and 3 deletions

View File

@ -101,10 +101,15 @@ class List(OrderedCollectionMixin, BookWyrmModel):
def remove_from_group(cls, owner, user):
"""remove a list from a group"""
cls.objects.filter(group__user=owner, user=user).all().update(
memberships = GroupMember.objects.filter(group__user=owner, user=user).all()
for membership in memberships:
# remove this user's group-curated lists from the group
cls.objects.filter(group=membership.group, user=membership.user).update(
group=None, curation="closed"
)
class ListItem(CollectionItemMixin, BookWyrmModel):
"""ok"""