diff --git a/netbox/dcim/api/serializers_/devicetypes.py b/netbox/dcim/api/serializers_/devicetypes.py index 1ac453434..3abcfd86a 100644 --- a/netbox/dcim/api/serializers_/devicetypes.py +++ b/netbox/dcim/api/serializers_/devicetypes.py @@ -100,7 +100,7 @@ class ModuleTypeSerializer(NetBoxModelSerializer): model = ModuleType fields = [ 'id', 'url', 'display_url', 'display', 'profile', 'manufacturer', 'model', 'part_number', 'airflow', - 'weight', 'weight_unit', 'description', 'attributes', 'comments', 'tags', 'custom_fields', 'created', + 'weight', 'weight_unit', 'description', 'attribute_data', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', ] brief_fields = ('id', 'url', 'display', 'profile', 'manufacturer', 'model', 'description') diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index a0833b0be..a8fcfd8e8 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -408,7 +408,8 @@ class DeviceTypeForm(NetBoxModelForm): class ModuleTypeProfileForm(NetBoxModelForm): schema = JSONField( - label=_('Schema') + label=_('Schema'), + help_text=_("Enter a valid JSON schema to define supported attributes.") ) comments = CommentField() diff --git a/netbox/dcim/models/modules.py b/netbox/dcim/models/modules.py index 1881d045e..edc4f7cce 100644 --- a/netbox/dcim/models/modules.py +++ b/netbox/dcim/models/modules.py @@ -13,6 +13,7 @@ from extras.models import ConfigContextModel, CustomField from netbox.models import PrimaryModel from netbox.models.features import ImageAttachmentsMixin from netbox.models.mixins import WeightMixin +from utilities.string import title from .device_components import * __all__ = ( @@ -131,7 +132,7 @@ class ModuleType(ImageAttachmentsMixin, PrimaryModel, WeightMixin): return {} attrs = {} for name, options in self.profile.schema.get('properties', {}).items(): - key = options.get('title', name) + key = options.get('title', title(name)) attrs[key] = self.attribute_data.get(name) return dict(sorted(attrs.items())) diff --git a/netbox/dcim/tests/test_filtersets.py b/netbox/dcim/tests/test_filtersets.py index 5dd5534bc..4e8314897 100644 --- a/netbox/dcim/tests/test_filtersets.py +++ b/netbox/dcim/tests/test_filtersets.py @@ -1486,7 +1486,7 @@ class DeviceTypeTestCase(TestCase, ChangeLoggedFilterSetTests): class ModuleTypeTestCase(TestCase, ChangeLoggedFilterSetTests): queryset = ModuleType.objects.all() filterset = ModuleTypeFilterSet - ignore_fields = ['attributes'] + ignore_fields = ['attribute_data'] @classmethod def setUpTestData(cls): diff --git a/netbox/templates/dcim/moduletypeprofile.html b/netbox/templates/dcim/moduletypeprofile.html index 61d8daee8..87e576bda 100644 --- a/netbox/templates/dcim/moduletypeprofile.html +++ b/netbox/templates/dcim/moduletypeprofile.html @@ -7,7 +7,7 @@ {% block title %}{{ object.name }}{% endblock %} {% block content %} -
{{ object.schema|json }}