Browse Source

Added description to Tenant model

Jeremy Stretch 8 years ago
parent
commit
27c21237ff

+ 10 - 0
netbox/templates/tenancy/tenant.html

@@ -53,6 +53,16 @@
                     </td>
                 </tr>
                 <tr>
+                    <td>Description</td>
+                    <td>
+                        {% if tenant.description %}
+                            {{ tenant.description }}
+                        {% else %}
+                            <span class="text-muted">N/A</span>
+                        {% endif %}
+                    </td>
+                </tr>
+                <tr>
                     <td>Created</td>
                     <td>{{ tenant.created }}</td>
                 </tr>

+ 2 - 2
netbox/tenancy/forms.py

@@ -30,7 +30,7 @@ class TenantForm(forms.ModelForm, BootstrapMixin):
 
     class Meta:
         model = Tenant
-        fields = ['name', 'slug', 'group', 'comments']
+        fields = ['name', 'slug', 'group', 'description', 'comments']
 
 
 class TenantFromCSVForm(forms.ModelForm):
@@ -39,7 +39,7 @@ class TenantFromCSVForm(forms.ModelForm):
 
     class Meta:
         model = Tenant
-        fields = ['name', 'slug', 'group', 'comments']
+        fields = ['name', 'slug', 'group', 'description', 'comments']
 
 
 class TenantImportForm(BulkImportForm, BootstrapMixin):

+ 25 - 0
netbox/tenancy/migrations/0002_add_tenant_description.py

@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.8 on 2016-07-26 21:44
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('tenancy', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='tenant',
+            name='description',
+            field=models.CharField(blank=True, help_text=b'Long-form name (optional)', max_length=100),
+        ),
+        migrations.AlterField(
+            model_name='tenant',
+            name='name',
+            field=models.CharField(max_length=30, unique=True),
+        ),
+    ]

+ 2 - 1
netbox/tenancy/models.py

@@ -26,9 +26,10 @@ class Tenant(CreatedUpdatedModel):
     A Tenant represents an organization served by the NetBox owner. This is typically a customer or an internal
     department.
     """
-    name = models.CharField(max_length=50, unique=True)
+    name = models.CharField(max_length=30, unique=True)
     slug = models.SlugField(unique=True)
     group = models.ForeignKey('TenantGroup', related_name='tenants', on_delete=models.PROTECT)
+    description = models.CharField(max_length=100, blank=True, help_text="Long-form name (optional)")
     comments = models.TextField(blank=True)
 
     class Meta:

+ 2 - 1
netbox/tenancy/tables.py

@@ -37,7 +37,8 @@ class TenantTable(BaseTable):
     pk = ToggleColumn()
     name = tables.LinkColumn('tenancy:tenant', args=[Accessor('slug')], verbose_name='Name')
     group = tables.Column(verbose_name='Group')
+    description = tables.Column(verbose_name='Description')
 
     class Meta(BaseTable.Meta):
         model = Tenant
-        fields = ('pk', 'name', 'group')
+        fields = ('pk', 'name', 'group', 'description')