mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add description field to RackRole and DeviceRole models (#3655)
This commit is contained in:
@ -108,7 +108,7 @@ class RackRoleSerializer(ValidatedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = RackRole
|
||||
fields = ['id', 'name', 'slug', 'color', 'rack_count']
|
||||
fields = ['id', 'name', 'slug', 'color', 'description', 'rack_count']
|
||||
|
||||
|
||||
class RackSerializer(TaggitSerializer, CustomFieldModelSerializer):
|
||||
@ -301,7 +301,9 @@ class DeviceRoleSerializer(ValidatedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = DeviceRole
|
||||
fields = ['id', 'name', 'slug', 'color', 'vm_role', 'device_count', 'virtualmachine_count']
|
||||
fields = [
|
||||
'id', 'name', 'slug', 'color', 'vm_role', 'description', 'device_count', 'virtualmachine_count',
|
||||
]
|
||||
|
||||
|
||||
class PlatformSerializer(ValidatedModelSerializer):
|
||||
|
@ -412,7 +412,7 @@ class RackRoleForm(BootstrapMixin, forms.ModelForm):
|
||||
class Meta:
|
||||
model = RackRole
|
||||
fields = [
|
||||
'name', 'slug', 'color',
|
||||
'name', 'slug', 'color', 'description',
|
||||
]
|
||||
|
||||
|
||||
@ -1387,7 +1387,7 @@ class DeviceRoleForm(BootstrapMixin, forms.ModelForm):
|
||||
class Meta:
|
||||
model = DeviceRole
|
||||
fields = [
|
||||
'name', 'slug', 'color', 'vm_role',
|
||||
'name', 'slug', 'color', 'vm_role', 'description',
|
||||
]
|
||||
|
||||
|
||||
|
23
netbox/dcim/migrations/0087_role_descriptions.py
Normal file
23
netbox/dcim/migrations/0087_role_descriptions.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 2.2.6 on 2019-12-10 17:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0086_device_name_nonunique'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='devicerole',
|
||||
name='description',
|
||||
field=models.CharField(blank=True, max_length=100),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='rackrole',
|
||||
name='description',
|
||||
field=models.CharField(blank=True, max_length=100),
|
||||
),
|
||||
]
|
@ -433,8 +433,12 @@ class RackRole(ChangeLoggedModel):
|
||||
unique=True
|
||||
)
|
||||
color = ColorField()
|
||||
description = models.CharField(
|
||||
max_length=100,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
csv_headers = ['name', 'slug', 'color']
|
||||
csv_headers = ['name', 'slug', 'color', 'description']
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
@ -450,6 +454,7 @@ class RackRole(ChangeLoggedModel):
|
||||
self.name,
|
||||
self.slug,
|
||||
self.color,
|
||||
self.description,
|
||||
)
|
||||
|
||||
|
||||
@ -1412,8 +1417,12 @@ class DeviceRole(ChangeLoggedModel):
|
||||
verbose_name='VM Role',
|
||||
help_text='Virtual machines may be assigned to this role'
|
||||
)
|
||||
description = models.CharField(
|
||||
max_length=100,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
csv_headers = ['name', 'slug', 'color', 'vm_role']
|
||||
csv_headers = ['name', 'slug', 'color', 'vm_role', 'description']
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
@ -1427,6 +1436,7 @@ class DeviceRole(ChangeLoggedModel):
|
||||
self.slug,
|
||||
self.color,
|
||||
self.vm_role,
|
||||
self.description,
|
||||
)
|
||||
|
||||
|
||||
|
@ -272,16 +272,17 @@ class RackGroupTable(BaseTable):
|
||||
|
||||
class RackRoleTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
name = tables.LinkColumn(verbose_name='Name')
|
||||
rack_count = tables.Column(verbose_name='Racks')
|
||||
color = tables.TemplateColumn(COLOR_LABEL, verbose_name='Color')
|
||||
slug = tables.Column(verbose_name='Slug')
|
||||
actions = tables.TemplateColumn(template_code=RACKROLE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}},
|
||||
verbose_name='')
|
||||
color = tables.TemplateColumn(COLOR_LABEL)
|
||||
actions = tables.TemplateColumn(
|
||||
template_code=RACKROLE_ACTIONS,
|
||||
attrs={'td': {'class': 'text-right noprint'}},
|
||||
verbose_name=''
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = RackRole
|
||||
fields = ('pk', 'name', 'rack_count', 'color', 'slug', 'actions')
|
||||
fields = ('pk', 'name', 'rack_count', 'color', 'description', 'slug', 'actions')
|
||||
|
||||
|
||||
#
|
||||
@ -614,7 +615,7 @@ class DeviceRoleTable(BaseTable):
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = DeviceRole
|
||||
fields = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'slug', 'actions')
|
||||
fields = ('pk', 'name', 'device_count', 'vm_count', 'color', 'vm_role', 'description', 'slug', 'actions')
|
||||
|
||||
|
||||
#
|
||||
|
Reference in New Issue
Block a user