This commit is contained in:
Arthur
2026-04-16 09:10:45 -07:00
parent ba9d060803
commit 7f14434162
3 changed files with 4 additions and 4 deletions

View File

@@ -90,8 +90,8 @@ class RenderConfigMixin(ConfigTemplateRenderMixin):
# Check for an optional config_template_id override in the request data
if config_template_id := request.data.get('config_template_id'):
try:
configtemplate = ConfigTemplate.objects.get(pk=config_template_id)
except ConfigTemplate.DoesNotExist:
configtemplate = ConfigTemplate.objects.restrict(request.user, 'view').get(pk=config_template_id)
except (ConfigTemplate.DoesNotExist, ValueError):
return Response({
'error': f'Config template with ID {config_template_id} not found.'
}, status=HTTP_400_BAD_REQUEST)

View File

@@ -1273,7 +1273,7 @@ class ObjectRenderConfigView(generic.ObjectView):
error_message = ''
if config_template_id := request.GET.get('config_template_id'):
try:
config_template = ConfigTemplate.objects.get(pk=config_template_id)
config_template = ConfigTemplate.objects.restrict(request.user, 'view').get(pk=config_template_id)
except (ConfigTemplate.DoesNotExist, ValueError):
error_message = _("Config template with ID {id} not found.").format(id=config_template_id)
else:

View File

@@ -52,7 +52,7 @@
{% if error_message %}
<div class="alert alert-warning">
<h4 class="alert-title mb-1">{% trans "Error rendering template" %}</h4>
{% trans error_message %}
{{ error_message }}
</div>
{% elif config_template %}
{% if rendered_config %}