|
1 | 1 | import importlib |
2 | 2 | import logging |
3 | 3 |
|
| 4 | +from csp.decorators import csp_update |
4 | 5 | from django.conf import settings |
5 | 6 | from django.contrib import admin, messages |
6 | 7 | from django.http import HttpResponseRedirect |
|
10 | 11 | from django_ilmoitin.admin import NotificationTemplateAdmin |
11 | 12 | from django_ilmoitin.models import NotificationTemplate |
12 | 13 |
|
| 14 | +from palvelutarjotin.consts import CSP |
| 15 | + |
13 | 16 | from .notification_importer import ( |
14 | 17 | AbstractNotificationImporter, |
15 | 18 | NotificationImporterException, |
@@ -107,6 +110,16 @@ def _send_error_message(self, request, message): |
107 | 110 | logger.error(message) |
108 | 111 | self.message_user(request, message, messages.ERROR) |
109 | 112 |
|
| 113 | + # Acecpt CSP_UNSAFE_INLINE for the changeform view to allow |
| 114 | + # the preview template to work correctly. |
| 115 | + @csp_update( |
| 116 | + SCRIPT_SRC=settings.CSP_SCRIPT_SRC + [CSP.UNSAFE_INLINE], |
| 117 | + ) |
| 118 | + def changeform_view(self, request, object_id=None, form_url="", extra_context=None): |
| 119 | + return super().changeform_view( |
| 120 | + request, object_id, form_url, extra_context=extra_context |
| 121 | + ) |
| 122 | + |
110 | 123 |
|
111 | 124 | if hasattr(settings, "NOTIFICATIONS_IMPORTER"): |
112 | 125 | admin.site.unregister(NotificationTemplate) |
|
0 commit comments