Introduce the Cloud model

This commit is contained in:
Jeremy Stretch
2021-03-18 11:10:48 -04:00
parent 433c48a1a3
commit 6ff8a267e9
17 changed files with 523 additions and 16 deletions

View File

@@ -15,6 +15,7 @@ __all__ = (
'Circuit',
'CircuitTermination',
'CircuitType',
'Cloud',
'Provider',
)
@@ -91,6 +92,59 @@ class Provider(PrimaryModel):
)
#
# Clouds
#
@extras_features('custom_fields', 'custom_links', 'export_templates', 'webhooks')
class Cloud(PrimaryModel):
name = models.CharField(
max_length=100
)
provider = models.ForeignKey(
to='circuits.Provider',
on_delete=models.PROTECT,
related_name='clouds'
)
description = models.CharField(
max_length=200,
blank=True
)
comments = models.TextField(
blank=True
)
csv_headers = [
'provider', 'name', 'description', 'comments',
]
objects = RestrictedQuerySet.as_manager()
class Meta:
ordering = ('provider', 'name')
constraints = (
models.UniqueConstraint(
fields=('provider', 'name'),
name='circuits_cloud_provider_name'
),
)
unique_together = ('provider', 'name')
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('circuits:cloud', args=[self.pk])
def to_csv(self):
return (
self.provider.name,
self.name,
self.description,
self.comments,
)
@extras_features('custom_fields', 'export_templates', 'webhooks')
class CircuitType(OrganizationalModel):
"""