improve group removal flow

Use .save() twice, but with broadcast=False on the second update. This is more efficient than doing a query and update() and avoids the duplicate AP broadcast.
This commit is contained in:
Hugh Rundle 2021-10-16 16:38:02 +11:00
parent 6f13c0d808
commit afd00cc67a

View file

@ -58,7 +58,8 @@ class Lists(View):
book_list = form.save() book_list = form.save()
# list should not have a group if it is not group curated # list should not have a group if it is not group curated
if not book_list.curation == "group": if not book_list.curation == "group":
models.List.objects.filter(id=book_list.id).update(group=None) book_list.group = None
book_list.save(broadcast=False)
return redirect(book_list.local_path) return redirect(book_list.local_path)
@ -193,7 +194,9 @@ class List(View):
return redirect("list", book_list.id) return redirect("list", book_list.id)
book_list = form.save() book_list = form.save()
if not book_list.curation == "group": if not book_list.curation == "group":
models.List.objects.filter(id=book_list.id).update(group=None) book_list.group = None
book_list.save(broadcast=False)
return redirect(book_list.local_path) return redirect(book_list.local_path)