mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
20e3fdc782
* #9045 - remove legacy fields from Provider * Add safegaurd for legacy data to migration * 9045 remove fields from forms and tables * Update unrelated tests to use ASN model instead of Provider * Fix migrations collision Co-authored-by: jeremystretch <jstretch@ns1.com>
100 lines
2.3 KiB
Python
100 lines
2.3 KiB
Python
from django.contrib.contenttypes.fields import GenericRelation
|
|
from django.db import models
|
|
from django.urls import reverse
|
|
|
|
from dcim.fields import ASNField
|
|
from netbox.models import NetBoxModel
|
|
|
|
__all__ = (
|
|
'ProviderNetwork',
|
|
'Provider',
|
|
)
|
|
|
|
|
|
class Provider(NetBoxModel):
|
|
"""
|
|
Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model
|
|
stores information pertinent to the user's relationship with the Provider.
|
|
"""
|
|
name = models.CharField(
|
|
max_length=100,
|
|
unique=True
|
|
)
|
|
slug = models.SlugField(
|
|
max_length=100,
|
|
unique=True
|
|
)
|
|
asns = models.ManyToManyField(
|
|
to='ipam.ASN',
|
|
related_name='providers',
|
|
blank=True
|
|
)
|
|
account = models.CharField(
|
|
max_length=30,
|
|
blank=True,
|
|
verbose_name='Account number'
|
|
)
|
|
comments = models.TextField(
|
|
blank=True
|
|
)
|
|
|
|
# Generic relations
|
|
contacts = GenericRelation(
|
|
to='tenancy.ContactAssignment'
|
|
)
|
|
|
|
clone_fields = (
|
|
'account',
|
|
)
|
|
|
|
class Meta:
|
|
ordering = ['name']
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
def get_absolute_url(self):
|
|
return reverse('circuits:provider', args=[self.pk])
|
|
|
|
|
|
class ProviderNetwork(NetBoxModel):
|
|
"""
|
|
This represents a provider network which exists outside of NetBox, the details of which are unknown or
|
|
unimportant to the user.
|
|
"""
|
|
name = models.CharField(
|
|
max_length=100
|
|
)
|
|
provider = models.ForeignKey(
|
|
to='circuits.Provider',
|
|
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
|
|
)
|
|
comments = models.TextField(
|
|
blank=True
|
|
)
|
|
|
|
class Meta:
|
|
ordering = ('provider', 'name')
|
|
constraints = (
|
|
models.UniqueConstraint(
|
|
fields=('provider', 'name'),
|
|
name='%(app_label)s_%(class)s_unique_provider_name'
|
|
),
|
|
)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
def get_absolute_url(self):
|
|
return reverse('circuits:providernetwork', args=[self.pk])
|