mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-17 05:36:34 +00:00
use update() to remove orphaned groups on list edit
Using add() broadcasts the database change, which is unnecessary potentially broadcast AP messages twice.
This commit is contained in:
parent
d6a5794ac3
commit
18735bdd42
1 changed files with 2 additions and 5 deletions
|
@ -58,8 +58,7 @@ 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":
|
||||||
book_list.group = None
|
models.List.objects.filter(id=book_list.id).update(group=None)
|
||||||
book_list.save()
|
|
||||||
|
|
||||||
return redirect(book_list.local_path)
|
return redirect(book_list.local_path)
|
||||||
|
|
||||||
|
@ -184,7 +183,6 @@ class List(View):
|
||||||
return TemplateResponse(request, "lists/list.html", data)
|
return TemplateResponse(request, "lists/list.html", data)
|
||||||
|
|
||||||
@method_decorator(login_required, name="dispatch")
|
@method_decorator(login_required, name="dispatch")
|
||||||
# pylint: disable=unused-argument
|
|
||||||
def post(self, request, list_id):
|
def post(self, request, list_id):
|
||||||
"""edit a list"""
|
"""edit a list"""
|
||||||
book_list = get_object_or_404(models.List, id=list_id)
|
book_list = get_object_or_404(models.List, id=list_id)
|
||||||
|
@ -195,8 +193,7 @@ 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":
|
||||||
book_list.group = None
|
models.List.objects.filter(id=book_list.id).update(group=None)
|
||||||
book_list.save()
|
|
||||||
return redirect(book_list.local_path)
|
return redirect(book_list.local_path)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue