Closes #10545: Standardize description & comment fields on primary models (#10834)

* Standardize description & comments fields on primary models

* Update REST API serializers

* Update forms

* Update tables

* Update templates
This commit is contained in:
Jeremy Stretch
2022-11-04 08:28:09 -04:00
committed by GitHub
parent 8ea0bb75c1
commit acc750ad70
105 changed files with 1014 additions and 534 deletions

View File

@@ -42,7 +42,7 @@ class WirelessLANSerializer(NetBoxModelSerializer):
model = WirelessLAN
fields = [
'id', 'url', 'display', 'ssid', 'description', 'group', 'vlan', 'tenant', 'auth_type', 'auth_cipher',
'auth_psk', 'description', 'tags', 'custom_fields', 'created', 'last_updated',
'auth_psk', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
]
@@ -59,5 +59,5 @@ class WirelessLinkSerializer(NetBoxModelSerializer):
model = WirelessLink
fields = [
'id', 'url', 'display', 'interface_a', 'interface_b', 'ssid', 'status', 'tenant', 'auth_type',
'auth_cipher', 'auth_psk', 'description', 'tags', 'custom_fields', 'created', 'last_updated',
'auth_cipher', 'auth_psk', 'description', 'comments', 'tags', 'custom_fields', 'created', 'last_updated',
]

View File

@@ -4,7 +4,7 @@ from dcim.choices import LinkStatusChoices
from ipam.models import VLAN
from netbox.forms import NetBoxModelBulkEditForm
from tenancy.models import Tenant
from utilities.forms import add_blank_choice, DynamicModelChoiceField
from utilities.forms import add_blank_choice, CommentField, DynamicModelChoiceField, SmallTextarea
from wireless.choices import *
from wireless.constants import SSID_MAX_LENGTH
from wireless.models import *
@@ -52,9 +52,6 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
queryset=Tenant.objects.all(),
required=False
)
description = forms.CharField(
required=False
)
auth_type = forms.ChoiceField(
choices=add_blank_choice(WirelessAuthTypeChoices),
required=False
@@ -67,6 +64,14 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
required=False,
label='Pre-shared key'
)
description = forms.CharField(
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = WirelessLAN
fieldsets = (
@@ -74,7 +79,7 @@ class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
)
nullable_fields = (
'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk',
'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
)
@@ -92,9 +97,6 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
queryset=Tenant.objects.all(),
required=False
)
description = forms.CharField(
required=False
)
auth_type = forms.ChoiceField(
choices=add_blank_choice(WirelessAuthTypeChoices),
required=False
@@ -107,6 +109,14 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
required=False,
label='Pre-shared key'
)
description = forms.CharField(
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
)
model = WirelessLink
fieldsets = (
@@ -114,5 +124,5 @@ class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
('Authentication', ('auth_type', 'auth_cipher', 'auth_psk'))
)
nullable_fields = (
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk',
'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
)

View File

@@ -60,7 +60,9 @@ class WirelessLANCSVForm(NetBoxModelCSVForm):
class Meta:
model = WirelessLAN
fields = ('ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk')
fields = (
'ssid', 'group', 'vlan', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description', 'comments',
)
class WirelessLinkCSVForm(NetBoxModelCSVForm):
@@ -94,5 +96,6 @@ class WirelessLinkCSVForm(NetBoxModelCSVForm):
class Meta:
model = WirelessLink
fields = (
'interface_a', 'interface_b', 'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk',
'interface_a', 'interface_b', 'ssid', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description',
'comments',
)

View File

@@ -2,7 +2,7 @@ from dcim.models import Device, Interface, Location, Region, Site, SiteGroup
from ipam.models import VLAN, VLANGroup
from netbox.forms import NetBoxModelForm
from tenancy.forms import TenancyForm
from utilities.forms import DynamicModelChoiceField, SlugField, StaticSelect
from utilities.forms import CommentField, DynamicModelChoiceField, SlugField, StaticSelect
from wireless.models import *
__all__ = (
@@ -82,6 +82,7 @@ class WirelessLANForm(TenancyForm, NetBoxModelForm):
'group_id': '$vlan_group',
}
)
comments = CommentField()
fieldsets = (
('Wireless LAN', ('ssid', 'group', 'description', 'tags')),
@@ -93,8 +94,8 @@ class WirelessLANForm(TenancyForm, NetBoxModelForm):
class Meta:
model = WirelessLAN
fields = [
'ssid', 'group', 'description', 'region', 'site_group', 'site', 'vlan_group', 'vlan', 'tenant_group',
'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'tags',
'ssid', 'group', 'region', 'site_group', 'site', 'vlan_group', 'vlan', 'tenant_group', 'tenant',
'auth_type', 'auth_cipher', 'auth_psk', 'description', 'comments', 'tags',
]
widgets = {
'auth_type': StaticSelect,
@@ -183,6 +184,7 @@ class WirelessLinkForm(TenancyForm, NetBoxModelForm):
disabled_indicator='_occupied',
label='Interface'
)
comments = CommentField()
fieldsets = (
('Side A', ('site_a', 'location_a', 'device_a', 'interface_a')),
@@ -196,7 +198,8 @@ class WirelessLinkForm(TenancyForm, NetBoxModelForm):
model = WirelessLink
fields = [
'site_a', 'location_a', 'device_a', 'interface_a', 'site_b', 'location_b', 'device_b', 'interface_b',
'status', 'ssid', 'tenant_group', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'tags',
'status', 'ssid', 'tenant_group', 'tenant', 'auth_type', 'auth_cipher', 'auth_psk', 'description',
'comments', 'tags',
]
widgets = {
'status': StaticSelect,

View File

@@ -0,0 +1,23 @@
# Generated by Django 4.1.2 on 2022-11-03 18:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wireless', '0006_unique_constraints'),
]
operations = [
migrations.AddField(
model_name='wirelesslan',
name='comments',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='wirelesslink',
name='comments',
field=models.TextField(blank=True),
),
]

View File

@@ -2,11 +2,11 @@ from django.apps import apps
from django.core.exceptions import ValidationError
from django.db import models
from django.urls import reverse
from mptt.models import MPTTModel, TreeForeignKey
from mptt.models import MPTTModel
from dcim.choices import LinkStatusChoices
from dcim.constants import WIRELESS_IFACE_TYPES
from netbox.models import NestedGroupModel, NetBoxModel
from netbox.models import NestedGroupModel, PrimaryModel
from .choices import *
from .constants import *
@@ -69,7 +69,7 @@ class WirelessLANGroup(NestedGroupModel):
return reverse('wireless:wirelesslangroup', args=[self.pk])
class WirelessLAN(WirelessAuthenticationBase, NetBoxModel):
class WirelessLAN(WirelessAuthenticationBase, PrimaryModel):
"""
A wireless network formed among an arbitrary number of access point and clients.
"""
@@ -98,10 +98,6 @@ class WirelessLAN(WirelessAuthenticationBase, NetBoxModel):
blank=True,
null=True
)
description = models.CharField(
max_length=200,
blank=True
)
clone_fields = ('ssid', 'group', 'tenant', 'description')
@@ -122,7 +118,7 @@ def get_wireless_interface_types():
return {'type__in': WIRELESS_IFACE_TYPES}
class WirelessLink(WirelessAuthenticationBase, NetBoxModel):
class WirelessLink(WirelessAuthenticationBase, PrimaryModel):
"""
A point-to-point connection between two wireless Interfaces.
"""
@@ -157,10 +153,6 @@ class WirelessLink(WirelessAuthenticationBase, NetBoxModel):
blank=True,
null=True
)
description = models.CharField(
max_length=200,
blank=True
)
# Cache the associated device for the A and B interfaces. This enables filtering of WirelessLinks by their
# associated Devices.

View File

@@ -21,6 +21,7 @@ class WirelessLANGroupTable(NetBoxTable):
url_params={'group_id': 'pk'},
verbose_name='Wireless LANs'
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='wireless:wirelesslangroup_list'
)
@@ -28,7 +29,8 @@ class WirelessLANGroupTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = WirelessLANGroup
fields = (
'pk', 'name', 'wirelesslan_count', 'description', 'slug', 'tags', 'created', 'last_updated', 'actions',
'pk', 'name', 'wirelesslan_count', 'slug', 'description', 'comments', 'tags', 'created', 'last_updated',
'actions',
)
default_columns = ('pk', 'name', 'wirelesslan_count', 'description')
@@ -43,6 +45,7 @@ class WirelessLANTable(TenancyColumnsMixin, NetBoxTable):
interface_count = tables.Column(
verbose_name='Interfaces'
)
comments = columns.MarkdownColumn()
tags = columns.TagColumn(
url_name='wireless:wirelesslan_list'
)
@@ -50,8 +53,8 @@ class WirelessLANTable(TenancyColumnsMixin, NetBoxTable):
class Meta(NetBoxTable.Meta):
model = WirelessLAN
fields = (
'pk', 'ssid', 'group', 'tenant', 'tenant_group', 'description', 'vlan', 'interface_count', 'auth_type',
'auth_cipher', 'auth_psk', 'tags', 'created', 'last_updated',
'pk', 'ssid', 'group', 'tenant', 'tenant_group', 'vlan', 'interface_count', 'auth_type', 'auth_cipher',
'auth_psk', 'description', 'comments', 'tags', 'created', 'last_updated',
)
default_columns = ('pk', 'ssid', 'group', 'description', 'vlan', 'auth_type', 'interface_count')