From 197ff7264c6bf287ea5b59509509fddedbd85cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 27 Feb 2019 20:16:51 +0100 Subject: [PATCH] Fixed deletion of motions with change recommendations. Fixed #4415. --- openslides/utils/autoupdate.py | 9 +++++++-- openslides/utils/models.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/openslides/utils/autoupdate.py b/openslides/utils/autoupdate.py index ac652efbf..399e381f7 100644 --- a/openslides/utils/autoupdate.py +++ b/openslides/utils/autoupdate.py @@ -225,8 +225,13 @@ def handle_changed_elements(elements: Iterable[Element]) -> None: for element in elements: if element.get("reload"): model = get_model_from_collection_string(element["collection_string"]) - instance = model.objects.get(pk=element["id"]) - element["full_data"] = instance.get_full_data() + try: + instance = model.objects.get(pk=element["id"]) + except model.DoesNotExist: + # The instance was deleted so we set full_data explicitly to None. + element["full_data"] = None + else: + element["full_data"] = instance.get_full_data() # Save histroy here using sync code. history_instances = save_history(elements) diff --git a/openslides/utils/models.py b/openslides/utils/models.py index eca3d5013..d997ed2aa 100644 --- a/openslides/utils/models.py +++ b/openslides/utils/models.py @@ -176,7 +176,7 @@ def CASCADE_AND_AUTOUODATE( collector: Any, field: Any, sub_objs: Any, using: Any ) -> None: """ - Like models.SET_NULL but also informs the autoupdate system about the + Like models.CASCADE but also informs the autoupdate system about the root rest element of the also deleted instance. """ if len(sub_objs) != 1: