From 9ce29f9edca4ebde5ba7a2573879a84a115ddaf4 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 20 Mar 2023 15:57:08 -0400 Subject: [PATCH] #9653: Cleanup --- docs/models/dcim/devicetype.md | 4 ++++ netbox/dcim/api/views.py | 2 +- netbox/dcim/forms/bulk_import.py | 4 +++- netbox/dcim/forms/model_forms.py | 7 ++++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/models/dcim/devicetype.md b/docs/models/dcim/devicetype.md index 6dc4aa13e..fc177542c 100644 --- a/docs/models/dcim/devicetype.md +++ b/docs/models/dcim/devicetype.md @@ -21,6 +21,10 @@ The model number assigned to this device type by its manufacturer. Must be uniqu A unique URL-friendly representation of the model identifier. (This value can be used for filtering.) +### Default Platform + +If defined, devices instantiated from this type will automatically inherit the selected platform. (This assignment can be changed after the device has been created.) + ### Part Number An alternative part number to uniquely identify the device type. diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py index cd911f3cb..917debd14 100644 --- a/netbox/dcim/api/views.py +++ b/netbox/dcim/api/views.py @@ -280,7 +280,7 @@ class ManufacturerViewSet(NetBoxModelViewSet): # class DeviceTypeViewSet(NetBoxModelViewSet): - queryset = DeviceType.objects.prefetch_related('manufacturer', 'tags').annotate( + queryset = DeviceType.objects.prefetch_related('manufacturer', 'default_platform', 'tags').annotate( device_count=count_related(Device, 'device_type') ) serializer_class = serializers.DeviceTypeSerializer diff --git a/netbox/dcim/forms/bulk_import.py b/netbox/dcim/forms/bulk_import.py index d6e898b41..0c4f5fa60 100644 --- a/netbox/dcim/forms/bulk_import.py +++ b/netbox/dcim/forms/bulk_import.py @@ -280,12 +280,14 @@ class ManufacturerImportForm(NetBoxModelImportForm): class DeviceTypeImportForm(NetBoxModelImportForm): manufacturer = forms.ModelChoiceField( queryset=Manufacturer.objects.all(), - to_field_name='name' + to_field_name='name', + help_text=_('The manufacturer which produces this device type') ) default_platform = forms.ModelChoiceField( queryset=Platform.objects.all(), to_field_name='name', required=False, + help_text=_('The default platform for devices of this type (optional)') ) class Meta: diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index 13c58d02f..d5228d20a 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -283,7 +283,7 @@ class DeviceTypeForm(NetBoxModelForm): comments = CommentField() fieldsets = ( - ('Device Type', ('manufacturer', 'model', 'slug', 'description', 'tags', 'default_platform')), + ('Device Type', ('manufacturer', 'model', 'slug', 'default_platform', 'description', 'tags')), ('Chassis', ( 'u_height', 'is_full_depth', 'part_number', 'subdevice_role', 'airflow', 'weight', 'weight_unit', )), @@ -293,8 +293,9 @@ class DeviceTypeForm(NetBoxModelForm): class Meta: model = DeviceType fields = [ - 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role', 'airflow', - 'weight', 'weight_unit', 'front_image', 'rear_image', 'description', 'comments', 'tags', 'default_platform' + 'manufacturer', 'model', 'slug', 'default_platform', 'part_number', 'u_height', 'is_full_depth', + 'subdevice_role', 'airflow', 'weight', 'weight_unit', 'front_image', 'rear_image', 'description', + 'comments', 'tags', ] widgets = { 'front_image': ClearableFileInput(attrs={