diff --git a/apps/notifications/api/notifications.py b/apps/notifications/api/notifications.py index 335e7a0e0..eef4f6438 100644 --- a/apps/notifications/api/notifications.py +++ b/apps/notifications/api/notifications.py @@ -26,6 +26,14 @@ __all__ = ( ) +def _get_placeholder_context(contexts): + return { + item['name']: '{{ ' + item['name'] + ' }}' + for item in contexts + if item.get('name') + } + + class BackendListView(APIView): permission_classes = [IsValidUser] @@ -164,9 +172,10 @@ class TemplateViewSet(JMSGenericViewSet): item['content'] = f.read() item['source'] = 'data' else: - ctx = {x.get('name'): x.get('default') for x in item['contexts']} + ctx = _get_placeholder_context(item['contexts']) try: rendered = render_to_string(meta['template_name'], ctx) + item['template_content'] = rendered item['content'] = rendered item['source'] = 'original' except Exception as e: