Browse Source

Fixes #712: Corrected export of tenants which are not assigned to a group

Jeremy Stretch 8 years ago
parent
commit
e31fae5ec5

+ 8 - 2
netbox/templates/tenancy/tenant.html

@@ -8,7 +8,9 @@
     <div class="col-md-9">
         <ol class="breadcrumb">
             <li><a href="{% url 'tenancy:tenant_list' %}">Tenants</a></li>
-            <li><a href="{% url 'tenancy:tenant_list' %}?group={{ tenant.group.slug }}">{{ tenant.group }}</a></li>
+            {% if tenant.group %}
+                <li><a href="{% url 'tenancy:tenant_list' %}?group={{ tenant.group.slug }}">{{ tenant.group }}</a></li>
+            {% endif %}
             <li>{{ tenant }}</li>
         </ol>
     </div>
@@ -50,7 +52,11 @@
                 <tr>
                     <td>Group</td>
                     <td>
-                        <a href="{{ tenant.group.get_absolute_url }}">{{ tenant.group }}</a>
+                        {% if tenant.group %}
+                            <a href="{{ tenant.group.get_absolute_url }}">{{ tenant.group }}</a>
+                        {% else %}
+                            <span class="text-muted">None</span>
+                        {% endif %}
                     </td>
                 </tr>
                 <tr>

+ 1 - 1
netbox/templates/tenancy/tenant_import.html

@@ -40,7 +40,7 @@
 				</tr>
 				<tr>
 					<td>Group</td>
-					<td>Tenant group</td>
+					<td>Tenant group (optional)</td>
 					<td>Customers</td>
 				</tr>
 				<tr>

+ 1 - 1
netbox/tenancy/models.py

@@ -48,6 +48,6 @@ class Tenant(CreatedUpdatedModel, CustomFieldModel):
         return ','.join([
             self.name,
             self.slug,
-            self.group.name,
+            self.group.name if self.group else '',
             self.description,
         ])