From a46cc959c7fb90286960870439d7c305853d50ed Mon Sep 17 00:00:00 2001 From: JoeyStk Date: Wed, 7 Aug 2024 21:19:29 +0200 Subject: [PATCH] Fix test --- integreat_cms/cms/views/regions/region_actions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integreat_cms/cms/views/regions/region_actions.py b/integreat_cms/cms/views/regions/region_actions.py index 344a1fd48a..ebb825838c 100644 --- a/integreat_cms/cms/views/regions/region_actions.py +++ b/integreat_cms/cms/views/regions/region_actions.py @@ -16,7 +16,7 @@ from linkcheck.listeners import disable_listeners from ...decorators import permission_required -from ...models import Page, PushNotification, Region +from ...models import Contact, Page, PushNotification, Region if TYPE_CHECKING: from typing import Any @@ -51,7 +51,7 @@ def delete_region( messages.error( request, format_html( - "{}", + "{}", _( "Region could not be deleted, because the following pages are mirrored in other regions:" ), @@ -96,6 +96,8 @@ def delete_region( region.events.update(location=None) # Prevent ProtectedError when media files get deleted before their usages as organization logo region.organizations.all().delete() + # Prevent ProtectedError when location gets deleted before their contacts + Contact.objects.filter(poi__region=region).delete() # Prevent IntegrityError when multiple feedback objects exist region.feedback.all().delete() # Disable linkchecking while deleting this region