mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-11 06:12:16 -06:00
Fixes #2857: Add display_name to DeviceType API serializer; fix DeviceType list for bulk device edit
This commit is contained in:
@@ -100,7 +100,7 @@ class NestedDeviceTypeSerializer(WritableNestedSerializer):
|
||||
|
||||
class Meta:
|
||||
model = DeviceType
|
||||
fields = ['id', 'url', 'manufacturer', 'model', 'slug']
|
||||
fields = ['id', 'url', 'manufacturer', 'model', 'slug', 'display_name']
|
||||
|
||||
|
||||
class NestedRearPortTemplateSerializer(WritableNestedSerializer):
|
||||
|
||||
@@ -180,8 +180,8 @@ class DeviceTypeSerializer(TaggitSerializer, CustomFieldModelSerializer):
|
||||
class Meta:
|
||||
model = DeviceType
|
||||
fields = [
|
||||
'id', 'manufacturer', 'model', 'slug', 'part_number', 'u_height', 'is_full_depth', 'subdevice_role',
|
||||
'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'instance_count',
|
||||
'id', 'manufacturer', 'model', 'slug', 'display_name', 'part_number', 'u_height', 'is_full_depth',
|
||||
'subdevice_role', 'comments', 'tags', 'custom_fields', 'created', 'last_updated', 'instance_count',
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -1599,7 +1599,8 @@ class DeviceBulkEditForm(BootstrapMixin, AddRemoveTagsForm, CustomFieldBulkEditF
|
||||
required=False,
|
||||
label='Type',
|
||||
widget=APISelect(
|
||||
api_url="/api/dcim/device-types/"
|
||||
api_url="/api/dcim/device-types/",
|
||||
display_field='display_name'
|
||||
)
|
||||
)
|
||||
device_role = forms.ModelChoiceField(
|
||||
|
||||
@@ -980,7 +980,7 @@ class DeviceType(ChangeLoggedModel, CustomFieldModel):
|
||||
})
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
def display_name(self):
|
||||
return '{} {}'.format(self.manufacturer.name, self.model)
|
||||
|
||||
@property
|
||||
|
||||
@@ -517,7 +517,7 @@ class DeviceTable(BaseTable):
|
||||
device_role = tables.TemplateColumn(DEVICE_ROLE, verbose_name='Role')
|
||||
device_type = tables.LinkColumn(
|
||||
'dcim:devicetype', args=[Accessor('device_type.pk')], verbose_name='Type',
|
||||
text=lambda record: record.device_type.full_name
|
||||
text=lambda record: record.device_type.display_name
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
|
||||
Reference in New Issue
Block a user