mirror of
				https://github.com/netbox-community/netbox.git
				synced 2024-05-10 07:54:54 +00:00 
			
		
		
		
	Closes #783: Add a description field to the Circuit model
This commit is contained in:
		@@ -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):
 | 
			
		||||
 
 | 
			
		||||
@@ -98,5 +98,6 @@ class CircuitFilter(CustomFieldFilterSet, django_filters.FilterSet):
 | 
			
		||||
            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()
 | 
			
		||||
 
 | 
			
		||||
@@ -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):
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								netbox/circuits/migrations/0007_circuit_add_description.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								netbox/circuits/migrations/0007_circuit_add_description.py
									
									
									
									
									
										Normal file
									
								
							@@ -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),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -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 @@ class Circuit(CreatedUpdatedModel, CustomFieldModel):
 | 
			
		||||
            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):
 | 
			
		||||
 
 | 
			
		||||
@@ -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')
 | 
			
		||||
 
 | 
			
		||||
@@ -92,6 +92,16 @@
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
                <tr>
 | 
			
		||||
                    <td>Description</td>
 | 
			
		||||
                    <td>
 | 
			
		||||
                        {% if circuit.description %}
 | 
			
		||||
                            {{ circuit.description }}
 | 
			
		||||
                        {% else %}
 | 
			
		||||
                            <span class="text-muted">N/A</span>
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
            </table>
 | 
			
		||||
        </div>
 | 
			
		||||
        {% with circuit.get_custom_fields as custom_fields %}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@
 | 
			
		||||
            {% render_field form.tenant %}
 | 
			
		||||
            {% render_field form.install_date %}
 | 
			
		||||
            {% render_field form.commit_rate %}
 | 
			
		||||
            {% render_field form.description %}
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    {% if form.custom_fields %}
 | 
			
		||||
 
 | 
			
		||||
@@ -58,10 +58,15 @@
 | 
			
		||||
					<td>Commited rate in Kbps (optional)</td>
 | 
			
		||||
					<td>2000</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
				<tr>
 | 
			
		||||
					<td>Description</td>
 | 
			
		||||
					<td>Short description (optional)</td>
 | 
			
		||||
					<td>Primary for voice</td>
 | 
			
		||||
				</tr>
 | 
			
		||||
			</tbody>
 | 
			
		||||
		</table>
 | 
			
		||||
		<h4>Example</h4>
 | 
			
		||||
		<pre>IC-603122,TeliaSonera,Transit,Strickland Propane,2016-02-23,2000</pre>
 | 
			
		||||
		<pre>IC-603122,TeliaSonera,Transit,Strickland Propane,2016-02-23,2000,Primary for voice</pre>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user