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
* [#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
* [#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
## 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)).
* Introduced `/api/extras/scripts/` endpoint for retrieving and executing custom scripts
* circuits.CircuitType: Added field `description`
* dcim.ConsolePort: Added field `type`
* dcim.ConsolePortTemplate: Added field `type`
* dcim.ConsoleServerPort: Added field `type`
* dcim.ConsoleServerPortTemplate: Added field `type`
* dcim.DeviceRole: Added field `description`
* dcim.PowerPort: Added field `type`
* dcim.PowerPortTemplate: Added field `type`
* dcim.PowerOutlet: 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`.
* ipam.Role: Added field `description`
* secrets.SecretRole: Added field `description`
* virtualization.Cluster: Added field `tenant`

View File

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

View File

@ -128,7 +128,7 @@ class CircuitTypeForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = CircuitType
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(
unique=True
)
description = models.CharField(
max_length=100,
blank=True,
)
csv_headers = ['name', 'slug']
csv_headers = ['name', 'slug', 'description']
class Meta:
ordering = ['name']
@ -114,6 +118,7 @@ class CircuitType(ChangeLoggedModel):
return (
self.name,
self.slug,
self.description,
)

View File

@ -50,12 +50,14 @@ class CircuitTypeTable(BaseTable):
name = tables.LinkColumn()
circuit_count = tables.Column(verbose_name='Circuits')
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):
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:
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):

View File

@ -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',
]

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

View File

@ -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')
#

View File

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

View File

@ -240,7 +240,7 @@ class RoleForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = Role
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(
default=1000
)
description = models.CharField(
max_length=100,
blank=True,
)
csv_headers = ['name', 'slug', 'weight']
csv_headers = ['name', 'slug', 'weight', 'description']
class Meta:
ordering = ['weight', 'name']
@ -274,6 +278,7 @@ class Role(ChangeLoggedModel):
self.name,
self.slug,
self.weight,
self.description,
)

View File

@ -288,11 +288,15 @@ class RoleTable(BaseTable):
orderable=False,
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):
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:
model = SecretRole
fields = ['id', 'name', 'slug', 'secret_count']
fields = ['id', 'name', 'slug', 'description', 'secret_count']
class SecretSerializer(TaggitSerializer, CustomFieldModelSerializer):

View File

@ -42,7 +42,7 @@ class SecretRoleForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = SecretRole
fields = [
'name', 'slug', 'users', 'groups',
'name', 'slug', 'description', 'users', 'groups',
]
widgets = {
'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(
unique=True
)
description = models.CharField(
max_length=100,
blank=True,
)
users = models.ManyToManyField(
to=User,
related_name='secretroles',
@ -281,7 +285,7 @@ class SecretRole(ChangeLoggedModel):
blank=True
)
csv_headers = ['name', 'slug']
csv_headers = ['name', 'slug', 'description']
class Meta:
ordering = ['name']
@ -296,6 +300,7 @@ class SecretRole(ChangeLoggedModel):
return (
self.name,
self.slug,
self.description,
)
def has_member(self, user):

View File

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