From 1939db1574913cbda0362ab208231360a83c99b9 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 26 Jul 2016 15:48:48 -0400 Subject: [PATCH] Added tenant to import/export of Circuits --- netbox/circuits/forms.py | 7 +++++-- netbox/circuits/models.py | 1 + netbox/templates/circuits/circuit_import.html | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/netbox/circuits/forms.py b/netbox/circuits/forms.py index 7d65ca192..f246bf130 100644 --- a/netbox/circuits/forms.py +++ b/netbox/circuits/forms.py @@ -2,6 +2,7 @@ from django import forms from django.db.models import Count from dcim.models import Site, Device, Interface, Rack, IFACE_FF_VIRTUAL +from tenancy.models import Tenant from utilities.forms import ( APISelect, BootstrapMixin, BulkImportForm, CommentField, CSVDataField, Livesearch, SmallTextarea, SlugField, ) @@ -160,13 +161,15 @@ class CircuitFromCSVForm(forms.ModelForm): error_messages={'invalid_choice': 'Provider not found.'}) type = forms.ModelChoiceField(CircuitType.objects.all(), to_field_name='name', error_messages={'invalid_choice': 'Invalid circuit type.'}) + tenant = forms.ModelChoiceField(Tenant.objects.all(), to_field_name='name', required=False, + error_messages={'invalid_choice': 'Tenant not found.'}) site = forms.ModelChoiceField(Site.objects.all(), to_field_name='name', error_messages={'invalid_choice': 'Site not found.'}) class Meta: model = Circuit - fields = ['cid', 'provider', 'type', 'site', 'install_date', 'port_speed', 'commit_rate', 'xconnect_id', - 'pp_info'] + fields = ['cid', 'provider', 'type', 'tenant', 'site', 'install_date', 'port_speed', 'commit_rate', + 'xconnect_id', 'pp_info'] class CircuitImportForm(BulkImportForm, BootstrapMixin): diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py index b3db5a6ae..15dbea216 100644 --- a/netbox/circuits/models.py +++ b/netbox/circuits/models.py @@ -92,6 +92,7 @@ class Circuit(CreatedUpdatedModel): self.cid, self.provider.name, self.type.name, + self.tenant.name if self.tenant else '', self.site.name, self.install_date.isoformat() if self.install_date else '', str(self.port_speed), diff --git a/netbox/templates/circuits/circuit_import.html b/netbox/templates/circuits/circuit_import.html index 516afbc0a..a6cd33ecd 100644 --- a/netbox/templates/circuits/circuit_import.html +++ b/netbox/templates/circuits/circuit_import.html @@ -43,6 +43,11 @@ Circuit type Transit + + Tenant + Name of tenant (optional) + Strickland Propane + Site Site name @@ -76,7 +81,7 @@

Example

-
IC-603122,TeliaSonera,Transit,ASH-4,2016-02-23,10000,2000,937649,PP8371 ports 13/14
+
IC-603122,TeliaSonera,Transit,Strickland Propane,ASH-4,2016-02-23,10000,2000,937649,PP8371 ports 13/14
{% endblock %}