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

Standardized declaration of csv_headers on models

This commit is contained in:
Jeremy Stretch
2018-02-02 14:26:16 -05:00
parent 60c03a646c
commit 12e6fe1d50
12 changed files with 153 additions and 73 deletions

View File

@@ -17,6 +17,8 @@ class TenantGroup(models.Model):
name = models.CharField(max_length=50, unique=True)
slug = models.SlugField(unique=True)
csv_headers = ['name', 'slug']
class Meta:
ordering = ['name']
@@ -26,6 +28,12 @@ class TenantGroup(models.Model):
def get_absolute_url(self):
return "{}?group={}".format(reverse('tenancy:tenant_list'), self.slug)
def to_csv(self):
return (
self.name,
self.slug,
)
@python_2_unicode_compatible
class Tenant(CreatedUpdatedModel, CustomFieldModel):
@@ -57,4 +65,5 @@ class Tenant(CreatedUpdatedModel, CustomFieldModel):
self.slug,
self.group.name if self.group else None,
self.description,
self.comments,
)