mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 16:48:16 -06:00
9627 fixes
This commit is contained in:
parent
0411f0dc62
commit
8fd80d786c
@ -41,7 +41,7 @@ class VLANGroupSerializer(NetBoxModelSerializer):
|
||||
class Meta:
|
||||
model = VLANGroup
|
||||
fields = [
|
||||
'id', 'url', 'display', 'name', 'slug', 'scope_type', 'scope_id', 'scope', 'min_vid', 'max_vid',
|
||||
'id', 'url', 'display', 'name', 'slug', 'scope_type', 'scope_id', 'scope',
|
||||
'description', 'tags', 'custom_fields', 'created', 'last_updated', 'vlan_count', 'utilization'
|
||||
]
|
||||
brief_fields = ('id', 'url', 'display', 'name', 'slug', 'description', 'vlan_count')
|
||||
|
@ -915,7 +915,6 @@ class VLANGroupFilterSet(OrganizationalModelFilterSet):
|
||||
class Meta:
|
||||
model = VLANGroup
|
||||
fields = ('id', 'name', 'slug', 'description', 'scope_id')
|
||||
# fields = ('id', 'name', 'slug', 'min_vid', 'max_vid', 'description', 'scope_id')
|
||||
|
||||
def search(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
|
@ -408,18 +408,6 @@ class FHRPGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
|
||||
class VLANGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
min_vid = forms.IntegerField(
|
||||
min_value=VLAN_VID_MIN,
|
||||
max_value=VLAN_VID_MAX,
|
||||
required=False,
|
||||
label=_('Minimum child VLAN VID')
|
||||
)
|
||||
max_vid = forms.IntegerField(
|
||||
min_value=VLAN_VID_MIN,
|
||||
max_value=VLAN_VID_MAX,
|
||||
required=False,
|
||||
label=_('Maximum child VLAN VID')
|
||||
)
|
||||
description = forms.CharField(
|
||||
label=_('Description'),
|
||||
max_length=200,
|
||||
@ -486,7 +474,6 @@ class VLANGroupBulkEditForm(NetBoxModelBulkEditForm):
|
||||
|
||||
model = VLANGroup
|
||||
fieldsets = (
|
||||
# FieldSet('site', 'min_vid', 'max_vid', 'description'),
|
||||
FieldSet('site', 'description'),
|
||||
FieldSet(
|
||||
'scope_type', 'region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster', name=_('Scope')
|
||||
|
@ -411,22 +411,10 @@ class VLANGroupImportForm(NetBoxModelImportForm):
|
||||
required=False,
|
||||
label=_('Scope type (app & model)')
|
||||
)
|
||||
min_vid = forms.IntegerField(
|
||||
min_value=VLAN_VID_MIN,
|
||||
max_value=VLAN_VID_MAX,
|
||||
required=False,
|
||||
label=_('Minimum child VLAN VID (default: {minimum})').format(minimum=VLAN_VID_MIN)
|
||||
)
|
||||
max_vid = forms.IntegerField(
|
||||
min_value=VLAN_VID_MIN,
|
||||
max_value=VLAN_VID_MAX,
|
||||
required=False,
|
||||
label=_('Maximum child VLAN VID (default: {maximum})').format(maximum=VLAN_VID_MIN)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = VLANGroup
|
||||
fields = ('name', 'slug', 'scope_type', 'scope_id', 'min_vid', 'max_vid', 'description', 'tags')
|
||||
fields = ('name', 'slug', 'scope_type', 'scope_id', 'description', 'tags')
|
||||
labels = {
|
||||
'scope_id': 'Scope ID',
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ class VLANGroup(OrganizationalModel):
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self._total_vlan_ids = 0
|
||||
for vlan_range in vland_id_ranges:
|
||||
self._total_vlan_ids += vlan_range.upper - vlan_range.lower + 1
|
||||
for vlan_range in self.vlan_id_ranges:
|
||||
self._total_vlan_ids += int(vlan_range.upper) - int(vlan_range.lower) + 1
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@ -124,7 +124,7 @@ class VLANGroup(OrganizationalModel):
|
||||
|
||||
@property
|
||||
def vlan_ranges(self):
|
||||
return ','.join([f"{self.vlan_id_ranges.lower}-{self.vlan_id_ranges.upper}" for val in value])
|
||||
return ','.join([f"{vlan_range.lower}-{vlan_range.upper}" for vlan_range in self.vlan_id_ranges])
|
||||
|
||||
|
||||
class VLAN(PrimaryModel):
|
||||
|
@ -63,7 +63,7 @@ class VLANGroupQuerySet(RestrictedQuerySet):
|
||||
|
||||
return self.annotate(
|
||||
vlan_count=count_related(VLAN, 'group'),
|
||||
utilization=Round(F('vlan_count') / F('_total_vlan_ids') * 100, 2)
|
||||
utilization=Round(F('vlan_count') * 100 / F('_total_vlan_ids'), 2)
|
||||
)
|
||||
|
||||
|
||||
|
@ -154,9 +154,7 @@ class VLANGroupIndex(SearchIndex):
|
||||
('name', 100),
|
||||
('slug', 110),
|
||||
('description', 500),
|
||||
('max_vid', 2000),
|
||||
)
|
||||
# display_attrs = ('scope_type', 'min_vid', 'max_vid', 'description')
|
||||
display_attrs = ('scope_type', 'description')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user