From fea7926197573ddc5c0a57de955c5999b51f8859 Mon Sep 17 00:00:00 2001 From: Renato Almeida de Oliveira Zaroubin Date: Sun, 6 Apr 2025 18:41:03 +0000 Subject: [PATCH] Add DEFAULT_MIME_TE constant --- netbox/extras/constants.py | 3 +++ netbox/netbox/models/features.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/netbox/extras/constants.py b/netbox/extras/constants.py index 123b771f6..db378c8fa 100644 --- a/netbox/extras/constants.py +++ b/netbox/extras/constants.py @@ -4,6 +4,9 @@ from extras.choices import LogLevelChoices # Custom fields CUSTOMFIELD_EMPTY_VALUES = (None, '', []) +# Template Export +DEFAULT_MIME_TYPE = 'text/plain; charset=utf-8' + # Webhooks HTTP_CONTENT_TYPE_JSON = 'application/json' diff --git a/netbox/netbox/models/features.py b/netbox/netbox/models/features.py index 9173ae99e..bb5d40419 100644 --- a/netbox/netbox/models/features.py +++ b/netbox/netbox/models/features.py @@ -14,7 +14,7 @@ from taggit.managers import TaggableManager from core.choices import JobStatusChoices, ObjectChangeActionChoices from core.models import ObjectType from extras.choices import * -from extras.constants import CUSTOMFIELD_EMPTY_VALUES +from extras.constants import CUSTOMFIELD_EMPTY_VALUES, DEFAULT_MIME_TYPE from extras.utils import is_taggable, filename_from_model, filename_from_object from netbox.config import get_config from netbox.registry import registry @@ -362,7 +362,9 @@ class RenderMixin(models.Model): max_length=50, blank=True, verbose_name=_('MIME type'), - help_text=_('Defaults to text/plain; charset=utf-8') + help_text=_('Defaults to {default_mime_type}').format( + default_mime_type=DEFAULT_MIME_TYPE + ), ) file_name = models.CharField( max_length=200, @@ -404,7 +406,7 @@ class RenderMixin(models.Model): def render_to_response(self, context=None, queryset=None): output = self.render(context=context, queryset=queryset) - mime_type = self.mime_type or 'text/plain; charset=utf-8' + mime_type = self.mime_type or DEFAULT_MIME_TYPE # Build the response response = HttpResponse(output, content_type=mime_type)