diff --git a/netbox/circuits/api/serializers.py b/netbox/circuits/api/serializers.py index 1b894afe02a..947aa9860bc 100644 --- a/netbox/circuits/api/serializers.py +++ b/netbox/circuits/api/serializers.py @@ -62,7 +62,8 @@ class CircuitSerializer(CustomFieldSerializer, serializers.ModelSerializer): class Meta: model = Circuit - fields = ['id', 'cid', 'provider', 'type', 'tenant', 'install_date', 'commit_rate', 'comments', 'terminations', 'custom_fields'] + fields = ['id', 'cid', 'provider', 'type', 'tenant', 'install_date', 'commit_rate', 'description', 'comments', + 'terminations', 'custom_fields'] class CircuitNestedSerializer(CircuitSerializer): diff --git a/netbox/circuits/filters.py b/netbox/circuits/filters.py index 117a106eafd..fa57a74dccc 100644 --- a/netbox/circuits/filters.py +++ b/netbox/circuits/filters.py @@ -98,5 +98,6 @@ def search(self, queryset, value): Q(cid__icontains=value) | Q(terminations__xconnect_id__icontains=value) | Q(terminations__pp_info__icontains=value) | + Q(description__icontains=value) | Q(comments__icontains=value) ).distinct() diff --git a/netbox/circuits/forms.py b/netbox/circuits/forms.py index dc59bc0c774..a1777bb16e3 100644 --- a/netbox/circuits/forms.py +++ b/netbox/circuits/forms.py @@ -86,7 +86,7 @@ class CircuitForm(BootstrapMixin, CustomFieldForm): class Meta: model = Circuit - fields = ['cid', 'type', 'provider', 'tenant', 'install_date', 'commit_rate', 'comments'] + fields = ['cid', 'type', 'provider', 'tenant', 'install_date', 'commit_rate', 'description', 'comments'] help_texts = { 'cid': "Unique circuit ID", 'install_date': "Format: YYYY-MM-DD", @@ -104,7 +104,7 @@ class CircuitFromCSVForm(forms.ModelForm): class Meta: model = Circuit - fields = ['cid', 'provider', 'type', 'tenant', 'install_date', 'commit_rate'] + fields = ['cid', 'provider', 'type', 'tenant', 'install_date', 'commit_rate', 'description'] class CircuitImportForm(BootstrapMixin, BulkImportForm): @@ -117,10 +117,11 @@ class CircuitBulkEditForm(BootstrapMixin, CustomFieldBulkEditForm): provider = forms.ModelChoiceField(queryset=Provider.objects.all(), required=False) tenant = forms.ModelChoiceField(queryset=Tenant.objects.all(), required=False) commit_rate = forms.IntegerField(required=False, label='Commit rate (Kbps)') + description = forms.CharField(max_length=100, required=False) comments = CommentField(widget=SmallTextarea) class Meta: - nullable_fields = ['tenant', 'commit_rate', 'comments'] + nullable_fields = ['tenant', 'commit_rate', 'description', 'comments'] class CircuitFilterForm(BootstrapMixin, CustomFieldFilterForm): diff --git a/netbox/circuits/migrations/0007_circuit_add_description.py b/netbox/circuits/migrations/0007_circuit_add_description.py new file mode 100644 index 00000000000..023e5890a5c --- /dev/null +++ b/netbox/circuits/migrations/0007_circuit_add_description.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-01-17 20:08 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('circuits', '0006_terminations'), + ] + + operations = [ + migrations.AddField( + model_name='circuit', + name='description', + field=models.CharField(blank=True, max_length=100), + ), + ] diff --git a/netbox/circuits/models.py b/netbox/circuits/models.py index d43778657c7..e0f42a78f13 100644 --- a/netbox/circuits/models.py +++ b/netbox/circuits/models.py @@ -97,6 +97,7 @@ class Circuit(CreatedUpdatedModel, CustomFieldModel): tenant = models.ForeignKey(Tenant, related_name='circuits', blank=True, null=True, on_delete=models.PROTECT) install_date = models.DateField(blank=True, null=True, verbose_name='Date installed') commit_rate = models.PositiveIntegerField(blank=True, null=True, verbose_name='Commit rate (Kbps)') + description = models.CharField(max_length=100, blank=True) comments = models.TextField(blank=True) custom_field_values = GenericRelation(CustomFieldValue, content_type_field='obj_type', object_id_field='obj_id') @@ -118,6 +119,7 @@ def to_csv(self): self.tenant.name if self.tenant else None, self.install_date.isoformat() if self.install_date else None, self.commit_rate, + self.description, ]) def _get_termination(self, side): diff --git a/netbox/circuits/tables.py b/netbox/circuits/tables.py index 34236d843af..ab877a8ce1f 100644 --- a/netbox/circuits/tables.py +++ b/netbox/circuits/tables.py @@ -60,9 +60,8 @@ class CircuitTable(BaseTable): args=[Accessor('termination_a.site.slug')]) z_side = tables.LinkColumn('dcim:site', accessor=Accessor('termination_z.site'), orderable=False, args=[Accessor('termination_z.site.slug')]) - commit_rate = tables.Column(accessor=Accessor('commit_rate_human'), order_by=Accessor('commit_rate'), - verbose_name='Commit Rate') + description = tables.Column(verbose_name='Description') class Meta(BaseTable.Meta): model = Circuit - fields = ('pk', 'cid', 'type', 'provider', 'tenant', 'a_side', 'z_side', 'commit_rate') + fields = ('pk', 'cid', 'type', 'provider', 'tenant', 'a_side', 'z_side', 'description') diff --git a/netbox/templates/circuits/circuit.html b/netbox/templates/circuits/circuit.html index 5591c64b964..ab54b45a513 100644 --- a/netbox/templates/circuits/circuit.html +++ b/netbox/templates/circuits/circuit.html @@ -92,6 +92,16 @@

{{ circuit.provider }} - {{ circuit.cid }}

{% endif %} + + Description + + {% if circuit.description %} + {{ circuit.description }} + {% else %} + N/A + {% endif %} + + {% with circuit.get_custom_fields as custom_fields %} diff --git a/netbox/templates/circuits/circuit_edit.html b/netbox/templates/circuits/circuit_edit.html index 67d18d1aea6..6b5e4497dae 100644 --- a/netbox/templates/circuits/circuit_edit.html +++ b/netbox/templates/circuits/circuit_edit.html @@ -11,6 +11,7 @@ {% render_field form.tenant %} {% render_field form.install_date %} {% render_field form.commit_rate %} + {% render_field form.description %} {% if form.custom_fields %} diff --git a/netbox/templates/circuits/circuit_import.html b/netbox/templates/circuits/circuit_import.html index fec364b601c..fec7ff65ee5 100644 --- a/netbox/templates/circuits/circuit_import.html +++ b/netbox/templates/circuits/circuit_import.html @@ -58,10 +58,15 @@

CSV Format

Commited rate in Kbps (optional) 2000 + + Description + Short description (optional) + Primary for voice +

Example

-
IC-603122,TeliaSonera,Transit,Strickland Propane,2016-02-23,2000
+
IC-603122,TeliaSonera,Transit,Strickland Propane,2016-02-23,2000,Primary for voice
{% endblock %}