1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Merge pull request #3750 from netbox-community/3655-role-descriptions

Add description field to organizational role models
This commit is contained in:
Jeremy Stretch
2019-12-10 13:29:44 -05:00
committed by GitHub
21 changed files with 145 additions and 29 deletions

View File

@ -136,19 +136,25 @@ PATCH) to maintain backward compatibility. This behavior will be discontinued be
* [#3455](https://github.com/digitalocean/netbox/issues/3455) - Add tenant assignment to cluster * [#3455](https://github.com/digitalocean/netbox/issues/3455) - Add tenant assignment to cluster
* [#3564](https://github.com/digitalocean/netbox/issues/3564) - Add list views for device components * [#3564](https://github.com/digitalocean/netbox/issues/3564) - Add list views for device components
* [#3538](https://github.com/digitalocean/netbox/issues/3538) - Introduce a REST API endpoint for executing custom scripts * [#3538](https://github.com/digitalocean/netbox/issues/3538) - Introduce a REST API endpoint for executing custom scripts
* [#3655](https://github.com/digitalocean/netbox/issues/3655) - Add `description` field to organizational models
* [#3731](https://github.com/digitalocean/netbox/issues/3731) - Change Graph.type to a ContentType foreign key field * [#3731](https://github.com/digitalocean/netbox/issues/3731) - Change Graph.type to a ContentType foreign key field
## API Changes ## API Changes
* Choice fields now use human-friendly strings for their values instead of integers (see [#3569](https://github.com/netbox-community/netbox/issues/3569)). * Choice fields now use human-friendly strings for their values instead of integers (see [#3569](https://github.com/netbox-community/netbox/issues/3569)).
* Introduced `/api/extras/scripts/` endpoint for retrieving and executing custom scripts * Introduced `/api/extras/scripts/` endpoint for retrieving and executing custom scripts
* circuits.CircuitType: Added field `description`
* dcim.ConsolePort: Added field `type` * dcim.ConsolePort: Added field `type`
* dcim.ConsolePortTemplate: Added field `type` * dcim.ConsolePortTemplate: Added field `type`
* dcim.ConsoleServerPort: Added field `type` * dcim.ConsoleServerPort: Added field `type`
* dcim.ConsoleServerPortTemplate: Added field `type` * dcim.ConsoleServerPortTemplate: Added field `type`
* dcim.DeviceRole: Added field `description`
* dcim.PowerPort: Added field `type` * dcim.PowerPort: Added field `type`
* dcim.PowerPortTemplate: Added field `type` * dcim.PowerPortTemplate: Added field `type`
* dcim.PowerOutlet: Added field `type` * dcim.PowerOutlet: Added field `type`
* dcim.PowerOutletTemplate: Added field `type` * dcim.PowerOutletTemplate: Added field `type`
* dcim.RackRole: Added field `description`
* extras.Graph: The `type` field has been changed to a content type foreign key. Models are specified as `<app>.<model>`; e.g. `dcim.site`. * extras.Graph: The `type` field has been changed to a content type foreign key. Models are specified as `<app>.<model>`; e.g. `dcim.site`.
* ipam.Role: Added field `description`
* secrets.SecretRole: Added field `description`
* virtualization.Cluster: Added field `tenant` * virtualization.Cluster: Added field `tenant`

View File

@ -36,7 +36,7 @@ class CircuitTypeSerializer(ValidatedModelSerializer):
class Meta: class Meta:
model = CircuitType model = CircuitType
fields = ['id', 'name', 'slug', 'circuit_count'] fields = ['id', 'name', 'slug', 'description', 'circuit_count']
class CircuitSerializer(TaggitSerializer, CustomFieldModelSerializer): class CircuitSerializer(TaggitSerializer, CustomFieldModelSerializer):

View File

@ -128,7 +128,7 @@ class CircuitTypeForm(BootstrapMixin, forms.ModelForm):
class Meta: class Meta:
model = CircuitType model = CircuitType
fields = [ fields = [
'name', 'slug', 'name', 'slug', 'description',
] ]

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.6 on 2019-12-10 18:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('circuits', '0016_3569_circuit_fields'),
]
operations = [
migrations.AddField(
model_name='circuittype',
name='description',
field=models.CharField(blank=True, max_length=100),
),
]

View File

@ -98,8 +98,12 @@ class CircuitType(ChangeLoggedModel):
slug = models.SlugField( slug = models.SlugField(
unique=True unique=True
) )
description = models.CharField(
max_length=100,
blank=True,
)
csv_headers = ['name', 'slug'] csv_headers = ['name', 'slug', 'description']
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
@ -114,6 +118,7 @@ class CircuitType(ChangeLoggedModel):
return ( return (
self.name, self.name,
self.slug, self.slug,
self.description,
) )

View File

@ -50,12 +50,14 @@ class CircuitTypeTable(BaseTable):
name = tables.LinkColumn() name = tables.LinkColumn()
circuit_count = tables.Column(verbose_name='Circuits') circuit_count = tables.Column(verbose_name='Circuits')
actions = tables.TemplateColumn( actions = tables.TemplateColumn(
template_code=CIRCUITTYPE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, verbose_name='' template_code=CIRCUITTYPE_ACTIONS,
attrs={'td': {'class': 'text-right noprint'}},
verbose_name=''
) )
class Meta(BaseTable.Meta): class Meta(BaseTable.Meta):
model = CircuitType model = CircuitType
fields = ('pk', 'name', 'circuit_count', 'slug', 'actions') fields = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions')
# #

View File

@ -108,7 +108,7 @@ class RackRoleSerializer(ValidatedModelSerializer):
class Meta: class Meta:
model = RackRole model = RackRole
fields = ['id', 'name', 'slug', 'color', 'rack_count'] fields = ['id', 'name', 'slug', 'color', 'description', 'rack_count']
class RackSerializer(TaggitSerializer, CustomFieldModelSerializer): class RackSerializer(TaggitSerializer, CustomFieldModelSerializer):
@ -301,7 +301,9 @@ class DeviceRoleSerializer(ValidatedModelSerializer):
class Meta: class Meta:
model = DeviceRole 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): class PlatformSerializer(ValidatedModelSerializer):

View File

@ -412,7 +412,7 @@ class RackRoleForm(BootstrapMixin, forms.ModelForm):
class Meta: class Meta:
model = RackRole model = RackRole
fields = [ fields = [
'name', 'slug', 'color', 'name', 'slug', 'color', 'description',
] ]
@ -1387,7 +1387,7 @@ class DeviceRoleForm(BootstrapMixin, forms.ModelForm):
class Meta: class Meta:
model = DeviceRole model = DeviceRole
fields = [ fields = [
'name', 'slug', 'color', 'vm_role', 'name', 'slug', 'color', 'vm_role', 'description',
] ]

View 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),
),
]

View File

@ -433,8 +433,12 @@ class RackRole(ChangeLoggedModel):
unique=True unique=True
) )
color = ColorField() color = ColorField()
description = models.CharField(
max_length=100,
blank=True,
)
csv_headers = ['name', 'slug', 'color'] csv_headers = ['name', 'slug', 'color', 'description']
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
@ -450,6 +454,7 @@ class RackRole(ChangeLoggedModel):
self.name, self.name,
self.slug, self.slug,
self.color, self.color,
self.description,
) )
@ -1412,8 +1417,12 @@ class DeviceRole(ChangeLoggedModel):
verbose_name='VM Role', verbose_name='VM Role',
help_text='Virtual machines may be assigned to this 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: class Meta:
ordering = ['name'] ordering = ['name']
@ -1427,6 +1436,7 @@ class DeviceRole(ChangeLoggedModel):
self.slug, self.slug,
self.color, self.color,
self.vm_role, self.vm_role,
self.description,
) )

View File

@ -272,16 +272,17 @@ class RackGroupTable(BaseTable):
class RackRoleTable(BaseTable): class RackRoleTable(BaseTable):
pk = ToggleColumn() pk = ToggleColumn()
name = tables.LinkColumn(verbose_name='Name')
rack_count = tables.Column(verbose_name='Racks') rack_count = tables.Column(verbose_name='Racks')
color = tables.TemplateColumn(COLOR_LABEL, verbose_name='Color') color = tables.TemplateColumn(COLOR_LABEL)
slug = tables.Column(verbose_name='Slug') actions = tables.TemplateColumn(
actions = tables.TemplateColumn(template_code=RACKROLE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, template_code=RACKROLE_ACTIONS,
verbose_name='') attrs={'td': {'class': 'text-right noprint'}},
verbose_name=''
)
class Meta(BaseTable.Meta): class Meta(BaseTable.Meta):
model = RackRole 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): class Meta(BaseTable.Meta):
model = DeviceRole 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')
# #

View File

@ -71,7 +71,7 @@ class RoleSerializer(ValidatedModelSerializer):
class Meta: class Meta:
model = Role model = Role
fields = ['id', 'name', 'slug', 'weight', 'prefix_count', 'vlan_count'] fields = ['id', 'name', 'slug', 'weight', 'description', 'prefix_count', 'vlan_count']
class VLANGroupSerializer(ValidatedModelSerializer): class VLANGroupSerializer(ValidatedModelSerializer):

View File

@ -240,7 +240,7 @@ class RoleForm(BootstrapMixin, forms.ModelForm):
class Meta: class Meta:
model = Role model = Role
fields = [ fields = [
'name', 'slug', 'weight', 'name', 'slug', 'weight', 'description',
] ]

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.6 on 2019-12-10 17:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ipam', '0031_3569_service_fields'),
]
operations = [
migrations.AddField(
model_name='role',
name='description',
field=models.CharField(blank=True, max_length=100),
),
]

View File

@ -260,8 +260,12 @@ class Role(ChangeLoggedModel):
weight = models.PositiveSmallIntegerField( weight = models.PositiveSmallIntegerField(
default=1000 default=1000
) )
description = models.CharField(
max_length=100,
blank=True,
)
csv_headers = ['name', 'slug', 'weight'] csv_headers = ['name', 'slug', 'weight', 'description']
class Meta: class Meta:
ordering = ['weight', 'name'] ordering = ['weight', 'name']
@ -274,6 +278,7 @@ class Role(ChangeLoggedModel):
self.name, self.name,
self.slug, self.slug,
self.weight, self.weight,
self.description,
) )

View File

@ -288,11 +288,15 @@ class RoleTable(BaseTable):
orderable=False, orderable=False,
verbose_name='VLANs' verbose_name='VLANs'
) )
actions = tables.TemplateColumn(template_code=ROLE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, verbose_name='') actions = tables.TemplateColumn(
template_code=ROLE_ACTIONS,
attrs={'td': {'class': 'text-right noprint'}},
verbose_name=''
)
class Meta(BaseTable.Meta): class Meta(BaseTable.Meta):
model = Role model = Role
fields = ('pk', 'name', 'prefix_count', 'vlan_count', 'slug', 'weight', 'actions') fields = ('pk', 'name', 'prefix_count', 'vlan_count', 'description', 'slug', 'weight', 'actions')
# #

View File

@ -18,7 +18,7 @@ class SecretRoleSerializer(ValidatedModelSerializer):
class Meta: class Meta:
model = SecretRole model = SecretRole
fields = ['id', 'name', 'slug', 'secret_count'] fields = ['id', 'name', 'slug', 'description', 'secret_count']
class SecretSerializer(TaggitSerializer, CustomFieldModelSerializer): class SecretSerializer(TaggitSerializer, CustomFieldModelSerializer):

View File

@ -42,7 +42,7 @@ class SecretRoleForm(BootstrapMixin, forms.ModelForm):
class Meta: class Meta:
model = SecretRole model = SecretRole
fields = [ fields = [
'name', 'slug', 'users', 'groups', 'name', 'slug', 'description', 'users', 'groups',
] ]
widgets = { widgets = {
'users': StaticSelect2Multiple(), 'users': StaticSelect2Multiple(),

View File

@ -0,0 +1,18 @@
# Generated by Django 2.2.6 on 2019-12-10 18:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('secrets', '0006_custom_tag_models'),
]
operations = [
migrations.AddField(
model_name='secretrole',
name='description',
field=models.CharField(blank=True, max_length=100),
),
]

View File

@ -270,6 +270,10 @@ class SecretRole(ChangeLoggedModel):
slug = models.SlugField( slug = models.SlugField(
unique=True unique=True
) )
description = models.CharField(
max_length=100,
blank=True,
)
users = models.ManyToManyField( users = models.ManyToManyField(
to=User, to=User,
related_name='secretroles', related_name='secretroles',
@ -281,7 +285,7 @@ class SecretRole(ChangeLoggedModel):
blank=True blank=True
) )
csv_headers = ['name', 'slug'] csv_headers = ['name', 'slug', 'description']
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
@ -296,6 +300,7 @@ class SecretRole(ChangeLoggedModel):
return ( return (
self.name, self.name,
self.slug, self.slug,
self.description,
) )
def has_member(self, user): def has_member(self, user):

View File

@ -19,16 +19,15 @@ SECRETROLE_ACTIONS = """
class SecretRoleTable(BaseTable): class SecretRoleTable(BaseTable):
pk = ToggleColumn() pk = ToggleColumn()
name = tables.LinkColumn(verbose_name='Name') name = tables.LinkColumn()
secret_count = tables.Column(verbose_name='Secrets') secret_count = tables.Column(verbose_name='Secrets')
slug = tables.Column(verbose_name='Slug')
actions = tables.TemplateColumn( actions = tables.TemplateColumn(
template_code=SECRETROLE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, verbose_name='' template_code=SECRETROLE_ACTIONS, attrs={'td': {'class': 'text-right noprint'}}, verbose_name=''
) )
class Meta(BaseTable.Meta): class Meta(BaseTable.Meta):
model = SecretRole model = SecretRole
fields = ('pk', 'name', 'secret_count', 'slug', 'actions') fields = ('pk', 'name', 'secret_count', 'description', 'slug', 'actions')
# #