From 18735bdd4228ab86323968d6ffa40dbf218e5ed4 Mon Sep 17 00:00:00 2001 From: Hugh Rundle <hugh@hughrundle.net> Date: Sun, 10 Oct 2021 12:04:03 +1100 Subject: [PATCH] use update() to remove orphaned groups on list edit Using add() broadcasts the database change, which is unnecessary potentially broadcast AP messages twice. --- bookwyrm/views/list.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py index 21c5d4cd..5dae128e 100644 --- a/bookwyrm/views/list.py +++ b/bookwyrm/views/list.py @@ -58,8 +58,7 @@ class Lists(View): book_list = form.save() # list should not have a group if it is not group curated if not book_list.curation == "group": - book_list.group = None - book_list.save() + models.List.objects.filter(id=book_list.id).update(group=None) return redirect(book_list.local_path) @@ -184,7 +183,6 @@ class List(View): return TemplateResponse(request, "lists/list.html", data) @method_decorator(login_required, name="dispatch") - # pylint: disable=unused-argument def post(self, request, list_id): """edit a list""" book_list = get_object_or_404(models.List, id=list_id) @@ -195,8 +193,7 @@ class List(View): return redirect("list", book_list.id) book_list = form.save() if not book_list.curation == "group": - book_list.group = None - book_list.save() + models.List.objects.filter(id=book_list.id).update(group=None) return redirect(book_list.local_path)