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

Closes #7681: Add service_id field for provider networks

This commit is contained in:
jeremystretch
2021-12-23 13:50:01 -05:00
parent a03ae295f6
commit bffd22038b
12 changed files with 48 additions and 12 deletions

View File

@@ -37,8 +37,8 @@ class ProviderNetworkSerializer(PrimaryModelSerializer):
class Meta:
model = ProviderNetwork
fields = [
'id', 'url', 'display', 'provider', 'name', 'description', 'comments', 'tags', 'custom_fields', 'created',
'last_updated',
'id', 'url', 'display', 'provider', 'name', 'service_id', 'description', 'comments', 'tags',
'custom_fields', 'created', 'last_updated',
]

View File

@@ -98,13 +98,14 @@ class ProviderNetworkFilterSet(PrimaryModelFilterSet):
class Meta:
model = ProviderNetwork
fields = ['id', 'name']
fields = ['id', 'name', 'service_id']
def search(self, queryset, name, value):
if not value.strip():
return queryset
return queryset.filter(
Q(name__icontains=value) |
Q(service_id__icontains=value) |
Q(description__icontains=value) |
Q(comments__icontains=value)
).distinct()

View File

@@ -62,10 +62,14 @@ class ProviderNetworkBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditFor
queryset=Provider.objects.all(),
required=False
)
description = forms.CharField(
service_id = forms.CharField(
max_length=100,
required=False
)
description = forms.CharField(
max_length=200,
required=False
)
comments = CommentField(
widget=SmallTextarea,
label='Comments'
@@ -73,7 +77,7 @@ class ProviderNetworkBulkEditForm(AddRemoveTagsForm, CustomFieldModelBulkEditFor
class Meta:
nullable_fields = [
'description', 'comments',
'service_id', 'description', 'comments',
]

View File

@@ -32,7 +32,7 @@ class ProviderNetworkCSVForm(CustomFieldModelCSVForm):
class Meta:
model = ProviderNetwork
fields = [
'provider', 'name', 'description', 'comments',
'provider', 'name', 'service_id', 'description', 'comments',
]

View File

@@ -64,6 +64,10 @@ class ProviderNetworkFilterForm(CustomFieldModelFilterForm):
label=_('Provider'),
fetch_trigger='open'
)
service_id = forms.CharField(
max_length=100,
required=False
)
tag = TagFilterField(model)

View File

@@ -66,10 +66,10 @@ class ProviderNetworkForm(CustomFieldModelForm):
class Meta:
model = ProviderNetwork
fields = [
'provider', 'name', 'description', 'comments', 'tags',
'provider', 'name', 'service_id', 'description', 'comments', 'tags',
]
fieldsets = (
('Provider Network', ('provider', 'name', 'description', 'tags')),
('Provider Network', ('provider', 'name', 'service_id', 'description', 'tags')),
)

View File

@@ -0,0 +1,16 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('circuits', '0004_rename_cable_peer'),
]
operations = [
migrations.AddField(
model_name='providernetwork',
name='service_id',
field=models.CharField(blank=True, max_length=100),
),
]

View File

@@ -5,7 +5,6 @@ from django.urls import reverse
from dcim.fields import ASNField
from extras.utils import extras_features
from netbox.models import PrimaryModel
from utilities.querysets import RestrictedQuerySet
__all__ = (
'ProviderNetwork',
@@ -87,6 +86,11 @@ class ProviderNetwork(PrimaryModel):
on_delete=models.PROTECT,
related_name='networks'
)
service_id = models.CharField(
max_length=100,
blank=True,
verbose_name='Service ID'
)
description = models.CharField(
max_length=200,
blank=True

View File

@@ -69,8 +69,8 @@ class ProviderNetworkTable(BaseTable):
class Meta(BaseTable.Meta):
model = ProviderNetwork
fields = ('pk', 'id', 'name', 'provider', 'description', 'comments', 'tags')
default_columns = ('pk', 'name', 'provider', 'description')
fields = ('pk', 'id', 'name', 'provider', 'service_id', 'description', 'comments', 'tags')
default_columns = ('pk', 'name', 'provider', 'service_id', 'description')
#