Closes #149: Added upstream_speed field to Circuit

This commit is contained in:
Jeremy Stretch 2016-08-08 16:51:19 -04:00
parent 5116db3344
commit d463161619
8 changed files with 50 additions and 14 deletions

View File

@ -21,8 +21,8 @@ class CircuitTypeAdmin(admin.ModelAdmin):
@admin.register(Circuit) @admin.register(Circuit)
class CircuitAdmin(admin.ModelAdmin): class CircuitAdmin(admin.ModelAdmin):
list_display = ['cid', 'provider', 'type', 'tenant', 'site', 'install_date', 'port_speed', 'commit_rate', list_display = ['cid', 'provider', 'type', 'tenant', 'site', 'install_date', 'port_speed_human',
'xconnect_id'] 'upstream_speed_human', 'commit_rate_human', 'xconnect_id']
list_filter = ['provider', 'type', 'tenant'] list_filter = ['provider', 'type', 'tenant']
exclude = ['interface'] exclude = ['interface']

View File

@ -53,7 +53,7 @@ class CircuitSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Circuit model = Circuit
fields = ['id', 'cid', 'provider', 'type', 'tenant', 'site', 'interface', 'install_date', 'port_speed', fields = ['id', 'cid', 'provider', 'type', 'tenant', 'site', 'interface', 'install_date', 'port_speed',
'commit_rate', 'xconnect_id', 'comments'] 'upstream_speed', 'commit_rate', 'xconnect_id', 'comments']
class CircuitNestedSerializer(CircuitSerializer): class CircuitNestedSerializer(CircuitSerializer):

View File

@ -102,7 +102,7 @@ class CircuitForm(forms.ModelForm, BootstrapMixin):
model = Circuit model = Circuit
fields = [ fields = [
'cid', 'type', 'provider', 'tenant', 'site', 'rack', 'device', 'livesearch', 'interface', 'install_date', 'cid', 'type', 'provider', 'tenant', 'site', 'rack', 'device', 'livesearch', 'interface', 'install_date',
'port_speed', 'commit_rate', 'xconnect_id', 'pp_info', 'comments' 'port_speed', 'upstream_speed', 'commit_rate', 'xconnect_id', 'pp_info', 'comments'
] ]
help_texts = { help_texts = {
'cid': "Unique circuit ID", 'cid': "Unique circuit ID",
@ -169,8 +169,8 @@ class CircuitFromCSVForm(forms.ModelForm):
class Meta: class Meta:
model = Circuit model = Circuit
fields = ['cid', 'provider', 'type', 'tenant', 'site', 'install_date', 'port_speed', 'commit_rate', fields = ['cid', 'provider', 'type', 'tenant', 'site', 'install_date', 'port_speed', 'upstream_speed',
'xconnect_id', 'pp_info'] 'commit_rate', 'xconnect_id', 'pp_info']
class CircuitImportForm(BulkImportForm, BootstrapMixin): class CircuitImportForm(BulkImportForm, BootstrapMixin):

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-08-08 20:24
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('circuits', '0004_circuit_add_tenant'),
]
operations = [
migrations.AddField(
model_name='circuit',
name='upstream_speed',
field=models.PositiveIntegerField(blank=True, help_text=b'Upstream speed, if different from port speed', null=True, verbose_name=b'Upstream speed (Kbps)'),
),
]

View File

@ -72,6 +72,8 @@ class Circuit(CreatedUpdatedModel):
interface = models.OneToOneField(Interface, related_name='circuit', blank=True, null=True) interface = models.OneToOneField(Interface, related_name='circuit', blank=True, null=True)
install_date = models.DateField(blank=True, null=True, verbose_name='Date installed') install_date = models.DateField(blank=True, null=True, verbose_name='Date installed')
port_speed = models.PositiveIntegerField(verbose_name='Port speed (Kbps)') port_speed = models.PositiveIntegerField(verbose_name='Port speed (Kbps)')
upstream_speed = models.PositiveIntegerField(blank=True, null=True, verbose_name='Upstream speed (Kbps)',
help_text='Upstream speed, if different from port speed')
commit_rate = models.PositiveIntegerField(blank=True, null=True, verbose_name='Commit rate (Kbps)') commit_rate = models.PositiveIntegerField(blank=True, null=True, verbose_name='Commit rate (Kbps)')
xconnect_id = models.CharField(max_length=50, blank=True, verbose_name='Cross-connect ID') xconnect_id = models.CharField(max_length=50, blank=True, verbose_name='Cross-connect ID')
pp_info = models.CharField(max_length=100, blank=True, verbose_name='Patch panel/port(s)') pp_info = models.CharField(max_length=100, blank=True, verbose_name='Patch panel/port(s)')
@ -96,6 +98,7 @@ class Circuit(CreatedUpdatedModel):
self.site.name, self.site.name,
self.install_date.isoformat() if self.install_date else '', self.install_date.isoformat() if self.install_date else '',
str(self.port_speed), str(self.port_speed),
str(self.upstream_speed),
str(self.commit_rate) if self.commit_rate else '', str(self.commit_rate) if self.commit_rate else '',
self.xconnect_id, self.xconnect_id,
self.pp_info, self.pp_info,
@ -116,12 +119,18 @@ class Circuit(CreatedUpdatedModel):
else: else:
return '{} Kbps'.format(speed) return '{} Kbps'.format(speed)
@property
def port_speed_human(self): def port_speed_human(self):
return self._humanize_speed(self.port_speed) return self._humanize_speed(self.port_speed)
port_speed_human.admin_order_field = 'port_speed'
def upstream_speed_human(self):
if not self.upstream_speed:
return ''
return self._humanize_speed(self.upstream_speed)
upstream_speed_human.admin_order_field = 'upstream_speed'
@property
def commit_rate_human(self): def commit_rate_human(self):
if not self.commit_rate: if not self.commit_rate:
return '' return ''
return self._humanize_speed(self.commit_rate) return self._humanize_speed(self.commit_rate)
commit_rate_human.admin_order_field = 'commit_rate'

View File

@ -82,12 +82,13 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Port Speed</td> <td>Speed</td>
<td> <td>
{% if circuit.port_speed %} {% if circuit.upstream_speed %}
{{ circuit.port_speed_human }} <i class="fa fa-arrow-down" title="Downstream"></i> {{ circuit.port_speed_human }} &nbsp;
<i class="fa fa-arrow-up" title="Upstream"></i> {{ circuit.upstream_speed_human }}
{% else %} {% else %}
<span class="text-muted">N/A</span> {{ circuit.port_speed_human }}
{% endif %} {% endif %}
</td> </td>
</tr> </tr>

View File

@ -19,6 +19,7 @@
<div class="panel-heading"><strong>Bandwidth</strong></div> <div class="panel-heading"><strong>Bandwidth</strong></div>
<div class="panel-body"> <div class="panel-body">
{% render_field form.port_speed %} {% render_field form.port_speed %}
{% render_field form.upstream_speed %}
{% render_field form.commit_rate %} {% render_field form.commit_rate %}
</div> </div>
</div> </div>

View File

@ -61,7 +61,12 @@
<tr> <tr>
<td>Port Speed</td> <td>Port Speed</td>
<td>Physical speed in Kbps</td> <td>Physical speed in Kbps</td>
<td>10000</td> <td>100000</td>
</tr>
<tr>
<td>Upstream Speed</td>
<td>Upstream speed in Kbps (optional)</td>
<td>20000</td>
</tr> </tr>
<tr> <tr>
<td>Commit rate</td> <td>Commit rate</td>
@ -81,7 +86,7 @@
</tbody> </tbody>
</table> </table>
<h4>Example</h4> <h4>Example</h4>
<pre>IC-603122,TeliaSonera,Transit,Strickland Propane,ASH-4,2016-02-23,10000,2000,937649,PP8371 ports 13/14</pre> <pre>IC-603122,TeliaSonera,Transit,Strickland Propane,ASH-4,2016-02-23,100000,,2000,937649,PP8371 ports 13/14</pre>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}