jeremystretch 2 سال پیش
والد
کامیت
9ce29f9edc
4فایلهای تغییر یافته به همراه12 افزوده شده و 5 حذف شده
  1. 4 0
      docs/models/dcim/devicetype.md
  2. 1 1
      netbox/dcim/api/views.py
  3. 3 1
      netbox/dcim/forms/bulk_import.py
  4. 4 3
      netbox/dcim/forms/model_forms.py

+ 4 - 0
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.

+ 1 - 1
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

+ 3 - 1
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:

+ 4 - 3
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={