We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Push notifications can be sent multiple times
### Describe the Bug
<!-- A clear and concise description of what the bug is. -->
It should not be possible to send push notifications multiple times to prevent the accidental re-sending of news.
Instead, only the "save" button should be enabled which can be used to update the messages that are delivered via the API endpoint.

### Steps to Reproduce

1. Go to News
2. Send new push notification
3. Send again

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
The news should only be sent the first time and only saved on all subsequent submissions

### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
The news is sent twice


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `integreat_cms/cms/views/push_notifications/push_notification_form_view.py`
Content:
```
1 import logging
2 
3 from datetime import datetime
4 
5 from django.contrib import messages
6 from django.core.exceptions import PermissionDenied
7 from django.shortcuts import render, redirect
8 from django.utils.decorators import method_decorator
9 from django.utils.translation import ugettext as _
10 from django.views.generic import TemplateView
11 from django.forms import modelformset_factory
12 
13 from .push_notification_sender import PushNotificationSender
14 from ...decorators import permission_required
15 from ...forms import (
16     PushNotificationForm,
17     PushNotificationTranslationForm,
18 )
19 from ...models import Language, PushNotification, PushNotificationTranslation
20 
21 logger = logging.getLogger(__name__)
22 
23 
24 @method_decorator(permission_required("cms.view_pushnotification"), name="dispatch")
25 @method_decorator(permission_required("cms.change_pushnotification"), name="post")
26 class PushNotificationFormView(TemplateView):
27     """
28     Class that handles HTTP POST and GET requests for editing push notifications
29     """
30 
31     #: The template to render (see :class:`~django.views.generic.base.TemplateResponseMixin`)
32     template_name = "push_notifications/push_notification_form.html"
33     #: The context dict passed to the template (see :class:`~django.views.generic.base.ContextMixin`)
34     extra_context = {"current_menu_item": "push_notifications_form"}
35 
36     def get(self, request, *args, **kwargs):
37         r"""
38         Open form for creating or editing a push notification
39 
40         :param request: Object representing the user call
41         :type request: ~django.http.HttpRequest
42 
43         :param \*args: The supplied arguments
44         :type \*args: list
45 
46         :param \**kwargs: The supplied keyword arguments
47         :type \**kwargs: dict
48 
49         :return: The rendered template response
50         :rtype: ~django.template.response.TemplateResponse
51         """
52 
53         region = request.region
54         language = region.get_language_or_404(
55             kwargs.get("language_slug"), only_active=True
56         )
57 
58         push_notification = PushNotification.objects.filter(
59             id=kwargs.get("push_notification_id")
60         ).first()
61         push_notification_translations = PushNotificationTranslation.objects.filter(
62             push_notification=push_notification
63         )
64 
65         push_notification_form = PushNotificationForm(instance=push_notification)
66 
67         num_languages = len(region.active_languages)
68         PNTFormset = modelformset_factory(
69             PushNotificationTranslation,
70             form=PushNotificationTranslationForm,
71             max_num=num_languages,
72             extra=num_languages - push_notification_translations.count(),
73         )
74         existing_languages = push_notification.languages if push_notification else []
75         pnt_formset = PNTFormset(
76             # Add queryset for all translations which exist already
77             queryset=push_notification_translations,
78             # Add initial data for all languages which do not yet have a translation
79             initial=[
80                 {"language": language}
81                 for language in region.active_languages
82                 if language not in existing_languages
83             ],
84         )
85 
86         return render(
87             request,
88             self.template_name,
89             {
90                 **self.get_context_data(**kwargs),
91                 "push_notification_form": push_notification_form,
92                 "pnt_formset": pnt_formset,
93                 "language": language,
94                 "languages": region.active_languages,
95             },
96         )
97 
98     # pylint: disable=too-many-branches,unused-argument
99     def post(self, request, *args, **kwargs):
100         r"""
101         Save and show form for creating or editing a push notification. Send push notification
102         if asked for by user.
103 
104         :param request: Object representing the user call
105         :type request: ~django.http.HttpRequest
106 
107         :param \*args: The supplied arguments
108         :type \*args: list
109 
110         :param \**kwargs: The supplied keyword arguments
111         :type \**kwargs: dict
112 
113         :raises ~django.core.exceptions.PermissionDenied: If user does not have the permission to send push notifications
114 
115         :return: The rendered template response
116         :rtype: ~django.template.response.TemplateResponse
117         """
118 
119         region = request.region
120         language = Language.objects.get(slug=kwargs.get("language_slug"))
121 
122         push_notification_instance = PushNotification.objects.filter(
123             id=kwargs.get("push_notification_id")
124         ).first()
125         push_notification_translations = PushNotificationTranslation.objects.filter(
126             push_notification=push_notification_instance
127         )
128 
129         if not request.user.has_perm("cms.change_pushnotification"):
130             logger.warning(
131                 "%r tried to edit %r",
132                 request.user,
133                 push_notification_instance,
134             )
135             raise PermissionDenied
136 
137         pn_form = PushNotificationForm(
138             data=request.POST,
139             instance=push_notification_instance,
140             additional_instance_attributes={
141                 "region": region,
142             },
143         )
144 
145         num_languages = len(region.active_languages)
146         PNTFormset = modelformset_factory(
147             PushNotificationTranslation,
148             form=PushNotificationTranslationForm,
149             max_num=num_languages,
150             extra=num_languages - push_notification_translations.count(),
151         )
152         existing_languages = (
153             push_notification_instance.languages if push_notification_instance else []
154         )
155         pnt_formset = PNTFormset(
156             data=request.POST,
157             # Add queryset for all translations which exist already
158             queryset=push_notification_translations,
159             # Add initial data for all languages which do not yet have a translation
160             initial=[
161                 {"language": language}
162                 for language in region.active_languages
163                 if language not in existing_languages
164             ],
165         )
166 
167         if not pn_form.is_valid() or not pnt_formset.is_valid():
168             # Add error messages
169             pn_form.add_error_messages(request)
170             for form in pnt_formset:
171                 form.add_error_messages(request)
172         else:
173             # Save forms
174             pn_form.save()
175             for form in pnt_formset:
176                 form.instance.push_notification = pn_form.instance
177             pnt_formset.save()
178 
179             # Add the success message
180             if not push_notification_instance:
181                 messages.success(
182                     request,
183                     _('News message "{}" was successfully created').format(
184                         pn_form.instance
185                     ),
186                 )
187             else:
188                 messages.success(
189                     request,
190                     _('News message "{}" was successfully saved').format(
191                         pn_form.instance
192                     ),
193                 )
194 
195             if "submit_send" in request.POST:
196                 if not request.user.has_perm("cms.send_push_notification"):
197                     logger.warning(
198                         "%r does not have the permission to send %r",
199                         request.user,
200                         push_notification_instance,
201                     )
202                     raise PermissionDenied
203                 push_sender = PushNotificationSender(pn_form.instance)
204                 if not push_sender.is_valid():
205                     messages.warning(
206                         request,
207                         _(
208                             "News message cannot be sent because required texts are missing"
209                         ),
210                     )
211                 else:
212                     if push_sender.send_all():
213                         messages.success(
214                             request, _("News message was successfully sent")
215                         )
216                         pn_form.instance.sent_date = datetime.now()
217                         pn_form.instance.save()
218                     else:
219                         messages.error(request, _("News message could not be sent"))
220 
221             # Redirect to the edit page
222             return redirect(
223                 "edit_push_notification",
224                 **{
225                     "push_notification_id": pn_form.instance.id,
226                     "region_slug": region.slug,
227                     "language_slug": language.slug,
228                 },
229             )
230 
231         return render(
232             request,
233             self.template_name,
234             {
235                 **self.get_context_data(**kwargs),
236                 "push_notification_form": pn_form,
237                 "pnt_formset": pnt_formset,
238                 "language": language,
239                 "languages": region.active_languages,
240             },
241         )
242
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/integreat_cms/cms/views/push_notifications/push_notification_form_view.py b/integreat_cms/cms/views/push_notifications/push_notification_form_view.py
--- a/integreat_cms/cms/views/push_notifications/push_notification_form_view.py
+++ b/integreat_cms/cms/views/push_notifications/push_notification_form_view.py
@@ -192,7 +192,7 @@
                     ),
                 )
 
-            if "submit_send" in request.POST:
+            if "submit_send" in request.POST and not pn_form.instance.sent_date:
                 if not request.user.has_perm("cms.send_push_notification"):
                     logger.warning(
                         "%r does not have the permission to send %r",

{"golden_diff": "diff --git a/integreat_cms/cms/views/push_notifications/push_notification_form_view.py b/integreat_cms/cms/views/push_notifications/push_notification_form_view.py\n--- a/integreat_cms/cms/views/push_notifications/push_notification_form_view.py\n+++ b/integreat_cms/cms/views/push_notifications/push_notification_form_view.py\n@@ -192,7 +192,7 @@\n                     ),\n                 )\n \n-            if \"submit_send\" in request.POST:\n+            if \"submit_send\" in request.POST and not pn_form.instance.sent_date:\n                 if not request.user.has_perm(\"cms.send_push_notification\"):\n                     logger.warning(\n                         \"%r does not have the permission to send %r\",\n", "issue": "Push notifications can be sent multiple times\n### Describe the Bug\r\n<!-- A clear and concise description of what the bug is. -->\r\nIt should not be possible to send push notifications multiple times to prevent the accidental re-sending of news.\r\nInstead, only the \"save\" button should be enabled which can be used to update the messages that are delivered via the API endpoint.\r\n\r\n### Steps to Reproduce\r\n\r\n1. Go to News\r\n2. Send new push notification\r\n3. Send again\r\n\r\n### Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\nThe news should only be sent the first time and only saved on all subsequent submissions\r\n\r\n### Actual Behavior\r\n<!-- A clear and concise description of what actually happened. -->\r\nThe news is sent twice\r\n\n", "before_files": [{"content": "import logging\n\nfrom datetime import datetime\n\nfrom django.contrib import messages\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import render, redirect\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import ugettext as _\nfrom django.views.generic import TemplateView\nfrom django.forms import modelformset_factory\n\nfrom .push_notification_sender import PushNotificationSender\nfrom ...decorators import permission_required\nfrom ...forms import (\n    PushNotificationForm,\n    PushNotificationTranslationForm,\n)\nfrom ...models import Language, PushNotification, PushNotificationTranslation\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(permission_required(\"cms.view_pushnotification\"), name=\"dispatch\")\n@method_decorator(permission_required(\"cms.change_pushnotification\"), name=\"post\")\nclass PushNotificationFormView(TemplateView):\n    \"\"\"\n    Class that handles HTTP POST and GET requests for editing push notifications\n    \"\"\"\n\n    #: The template to render (see :class:`~django.views.generic.base.TemplateResponseMixin`)\n    template_name = \"push_notifications/push_notification_form.html\"\n    #: The context dict passed to the template (see :class:`~django.views.generic.base.ContextMixin`)\n    extra_context = {\"current_menu_item\": \"push_notifications_form\"}\n\n    def get(self, request, *args, **kwargs):\n        r\"\"\"\n        Open form for creating or editing a push notification\n\n        :param request: Object representing the user call\n        :type request: ~django.http.HttpRequest\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n\n        region = request.region\n        language = region.get_language_or_404(\n            kwargs.get(\"language_slug\"), only_active=True\n        )\n\n        push_notification = PushNotification.objects.filter(\n            id=kwargs.get(\"push_notification_id\")\n        ).first()\n        push_notification_translations = PushNotificationTranslation.objects.filter(\n            push_notification=push_notification\n        )\n\n        push_notification_form = PushNotificationForm(instance=push_notification)\n\n        num_languages = len(region.active_languages)\n        PNTFormset = modelformset_factory(\n            PushNotificationTranslation,\n            form=PushNotificationTranslationForm,\n            max_num=num_languages,\n            extra=num_languages - push_notification_translations.count(),\n        )\n        existing_languages = push_notification.languages if push_notification else []\n        pnt_formset = PNTFormset(\n            # Add queryset for all translations which exist already\n            queryset=push_notification_translations,\n            # Add initial data for all languages which do not yet have a translation\n            initial=[\n                {\"language\": language}\n                for language in region.active_languages\n                if language not in existing_languages\n            ],\n        )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.get_context_data(**kwargs),\n                \"push_notification_form\": push_notification_form,\n                \"pnt_formset\": pnt_formset,\n                \"language\": language,\n                \"languages\": region.active_languages,\n            },\n        )\n\n    # pylint: disable=too-many-branches,unused-argument\n    def post(self, request, *args, **kwargs):\n        r\"\"\"\n        Save and show form for creating or editing a push notification. Send push notification\n        if asked for by user.\n\n        :param request: Object representing the user call\n        :type request: ~django.http.HttpRequest\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :raises ~django.core.exceptions.PermissionDenied: If user does not have the permission to send push notifications\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n\n        region = request.region\n        language = Language.objects.get(slug=kwargs.get(\"language_slug\"))\n\n        push_notification_instance = PushNotification.objects.filter(\n            id=kwargs.get(\"push_notification_id\")\n        ).first()\n        push_notification_translations = PushNotificationTranslation.objects.filter(\n            push_notification=push_notification_instance\n        )\n\n        if not request.user.has_perm(\"cms.change_pushnotification\"):\n            logger.warning(\n                \"%r tried to edit %r\",\n                request.user,\n                push_notification_instance,\n            )\n            raise PermissionDenied\n\n        pn_form = PushNotificationForm(\n            data=request.POST,\n            instance=push_notification_instance,\n            additional_instance_attributes={\n                \"region\": region,\n            },\n        )\n\n        num_languages = len(region.active_languages)\n        PNTFormset = modelformset_factory(\n            PushNotificationTranslation,\n            form=PushNotificationTranslationForm,\n            max_num=num_languages,\n            extra=num_languages - push_notification_translations.count(),\n        )\n        existing_languages = (\n            push_notification_instance.languages if push_notification_instance else []\n        )\n        pnt_formset = PNTFormset(\n            data=request.POST,\n            # Add queryset for all translations which exist already\n            queryset=push_notification_translations,\n            # Add initial data for all languages which do not yet have a translation\n            initial=[\n                {\"language\": language}\n                for language in region.active_languages\n                if language not in existing_languages\n            ],\n        )\n\n        if not pn_form.is_valid() or not pnt_formset.is_valid():\n            # Add error messages\n            pn_form.add_error_messages(request)\n            for form in pnt_formset:\n                form.add_error_messages(request)\n        else:\n            # Save forms\n            pn_form.save()\n            for form in pnt_formset:\n                form.instance.push_notification = pn_form.instance\n            pnt_formset.save()\n\n            # Add the success message\n            if not push_notification_instance:\n                messages.success(\n                    request,\n                    _('News message \"{}\" was successfully created').format(\n                        pn_form.instance\n                    ),\n                )\n            else:\n                messages.success(\n                    request,\n                    _('News message \"{}\" was successfully saved').format(\n                        pn_form.instance\n                    ),\n                )\n\n            if \"submit_send\" in request.POST:\n                if not request.user.has_perm(\"cms.send_push_notification\"):\n                    logger.warning(\n                        \"%r does not have the permission to send %r\",\n                        request.user,\n                        push_notification_instance,\n                    )\n                    raise PermissionDenied\n                push_sender = PushNotificationSender(pn_form.instance)\n                if not push_sender.is_valid():\n                    messages.warning(\n                        request,\n                        _(\n                            \"News message cannot be sent because required texts are missing\"\n                        ),\n                    )\n                else:\n                    if push_sender.send_all():\n                        messages.success(\n                            request, _(\"News message was successfully sent\")\n                        )\n                        pn_form.instance.sent_date = datetime.now()\n                        pn_form.instance.save()\n                    else:\n                        messages.error(request, _(\"News message could not be sent\"))\n\n            # Redirect to the edit page\n            return redirect(\n                \"edit_push_notification\",\n                **{\n                    \"push_notification_id\": pn_form.instance.id,\n                    \"region_slug\": region.slug,\n                    \"language_slug\": language.slug,\n                },\n            )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.get_context_data(**kwargs),\n                \"push_notification_form\": pn_form,\n                \"pnt_formset\": pnt_formset,\n                \"language\": language,\n                \"languages\": region.active_languages,\n            },\n        )\n", "path": "integreat_cms/cms/views/push_notifications/push_notification_form_view.py"}], "after_files": [{"content": "import logging\n\nfrom datetime import datetime\n\nfrom django.contrib import messages\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import render, redirect\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import ugettext as _\nfrom django.views.generic import TemplateView\nfrom django.forms import modelformset_factory\n\nfrom .push_notification_sender import PushNotificationSender\nfrom ...decorators import permission_required\nfrom ...forms import (\n    PushNotificationForm,\n    PushNotificationTranslationForm,\n)\nfrom ...models import Language, PushNotification, PushNotificationTranslation\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(permission_required(\"cms.view_pushnotification\"), name=\"dispatch\")\n@method_decorator(permission_required(\"cms.change_pushnotification\"), name=\"post\")\nclass PushNotificationFormView(TemplateView):\n    \"\"\"\n    Class that handles HTTP POST and GET requests for editing push notifications\n    \"\"\"\n\n    #: The template to render (see :class:`~django.views.generic.base.TemplateResponseMixin`)\n    template_name = \"push_notifications/push_notification_form.html\"\n    #: The context dict passed to the template (see :class:`~django.views.generic.base.ContextMixin`)\n    extra_context = {\"current_menu_item\": \"push_notifications_form\"}\n\n    def get(self, request, *args, **kwargs):\n        r\"\"\"\n        Open form for creating or editing a push notification\n\n        :param request: Object representing the user call\n        :type request: ~django.http.HttpRequest\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n\n        region = request.region\n        language = region.get_language_or_404(\n            kwargs.get(\"language_slug\"), only_active=True\n        )\n\n        push_notification = PushNotification.objects.filter(\n            id=kwargs.get(\"push_notification_id\")\n        ).first()\n        push_notification_translations = PushNotificationTranslation.objects.filter(\n            push_notification=push_notification\n        )\n\n        push_notification_form = PushNotificationForm(instance=push_notification)\n\n        num_languages = len(region.active_languages)\n        PNTFormset = modelformset_factory(\n            PushNotificationTranslation,\n            form=PushNotificationTranslationForm,\n            max_num=num_languages,\n            extra=num_languages - push_notification_translations.count(),\n        )\n        existing_languages = push_notification.languages if push_notification else []\n        pnt_formset = PNTFormset(\n            # Add queryset for all translations which exist already\n            queryset=push_notification_translations,\n            # Add initial data for all languages which do not yet have a translation\n            initial=[\n                {\"language\": language}\n                for language in region.active_languages\n                if language not in existing_languages\n            ],\n        )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.get_context_data(**kwargs),\n                \"push_notification_form\": push_notification_form,\n                \"pnt_formset\": pnt_formset,\n                \"language\": language,\n                \"languages\": region.active_languages,\n            },\n        )\n\n    # pylint: disable=too-many-branches,unused-argument\n    def post(self, request, *args, **kwargs):\n        r\"\"\"\n        Save and show form for creating or editing a push notification. Send push notification\n        if asked for by user.\n\n        :param request: Object representing the user call\n        :type request: ~django.http.HttpRequest\n\n        :param \\*args: The supplied arguments\n        :type \\*args: list\n\n        :param \\**kwargs: The supplied keyword arguments\n        :type \\**kwargs: dict\n\n        :raises ~django.core.exceptions.PermissionDenied: If user does not have the permission to send push notifications\n\n        :return: The rendered template response\n        :rtype: ~django.template.response.TemplateResponse\n        \"\"\"\n\n        region = request.region\n        language = Language.objects.get(slug=kwargs.get(\"language_slug\"))\n\n        push_notification_instance = PushNotification.objects.filter(\n            id=kwargs.get(\"push_notification_id\")\n        ).first()\n        push_notification_translations = PushNotificationTranslation.objects.filter(\n            push_notification=push_notification_instance\n        )\n\n        if not request.user.has_perm(\"cms.change_pushnotification\"):\n            logger.warning(\n                \"%r tried to edit %r\",\n                request.user,\n                push_notification_instance,\n            )\n            raise PermissionDenied\n\n        pn_form = PushNotificationForm(\n            data=request.POST,\n            instance=push_notification_instance,\n            additional_instance_attributes={\n                \"region\": region,\n            },\n        )\n\n        num_languages = len(region.active_languages)\n        PNTFormset = modelformset_factory(\n            PushNotificationTranslation,\n            form=PushNotificationTranslationForm,\n            max_num=num_languages,\n            extra=num_languages - push_notification_translations.count(),\n        )\n        existing_languages = (\n            push_notification_instance.languages if push_notification_instance else []\n        )\n        pnt_formset = PNTFormset(\n            data=request.POST,\n            # Add queryset for all translations which exist already\n            queryset=push_notification_translations,\n            # Add initial data for all languages which do not yet have a translation\n            initial=[\n                {\"language\": language}\n                for language in region.active_languages\n                if language not in existing_languages\n            ],\n        )\n\n        if not pn_form.is_valid() or not pnt_formset.is_valid():\n            # Add error messages\n            pn_form.add_error_messages(request)\n            for form in pnt_formset:\n                form.add_error_messages(request)\n        else:\n            # Save forms\n            pn_form.save()\n            for form in pnt_formset:\n                form.instance.push_notification = pn_form.instance\n            pnt_formset.save()\n\n            # Add the success message\n            if not push_notification_instance:\n                messages.success(\n                    request,\n                    _('News message \"{}\" was successfully created').format(\n                        pn_form.instance\n                    ),\n                )\n            else:\n                messages.success(\n                    request,\n                    _('News message \"{}\" was successfully saved').format(\n                        pn_form.instance\n                    ),\n                )\n\n            if \"submit_send\" in request.POST and not pn_form.instance.sent_date:\n                if not request.user.has_perm(\"cms.send_push_notification\"):\n                    logger.warning(\n                        \"%r does not have the permission to send %r\",\n                        request.user,\n                        push_notification_instance,\n                    )\n                    raise PermissionDenied\n                push_sender = PushNotificationSender(pn_form.instance)\n                if not push_sender.is_valid():\n                    messages.warning(\n                        request,\n                        _(\n                            \"News message cannot be sent because required texts are missing\"\n                        ),\n                    )\n                else:\n                    if push_sender.send_all():\n                        messages.success(\n                            request, _(\"News message was successfully sent\")\n                        )\n                        pn_form.instance.sent_date = datetime.now()\n                        pn_form.instance.save()\n                    else:\n                        messages.error(request, _(\"News message could not be sent\"))\n\n            # Redirect to the edit page\n            return redirect(\n                \"edit_push_notification\",\n                **{\n                    \"push_notification_id\": pn_form.instance.id,\n                    \"region_slug\": region.slug,\n                    \"language_slug\": language.slug,\n                },\n            )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                **self.get_context_data(**kwargs),\n                \"push_notification_form\": pn_form,\n                \"pnt_formset\": pnt_formset,\n                \"language\": language,\n                \"languages\": region.active_languages,\n            },\n        )\n", "path": "integreat_cms/cms/views/push_notifications/push_notification_form_view.py"}]}