Merge pull request #4422 from normanjaeckel/FixCascadeAndAutoupdate

Fixed deletion of motions with change recommendations. Fixed #4415.
This commit is contained in:
Emanuel Schütze 2019-02-27 21:14:59 +01:00 committed by GitHub
commit 5c840893ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -225,8 +225,13 @@ def handle_changed_elements(elements: Iterable[Element]) -> None:
for element in elements: for element in elements:
if element.get("reload"): if element.get("reload"):
model = get_model_from_collection_string(element["collection_string"]) model = get_model_from_collection_string(element["collection_string"])
instance = model.objects.get(pk=element["id"]) try:
element["full_data"] = instance.get_full_data() 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. # Save histroy here using sync code.
history_instances = save_history(elements) history_instances = save_history(elements)

View File

@ -176,7 +176,7 @@ def CASCADE_AND_AUTOUODATE(
collector: Any, field: Any, sub_objs: Any, using: Any collector: Any, field: Any, sub_objs: Any, using: Any
) -> None: ) -> 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. root rest element of the also deleted instance.
""" """
if len(sub_objs) != 1: if len(sub_objs) != 1: