1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

ipam.VLAN: Added description field, extended name to 64 chars

This commit is contained in:
Jeremy Stretch
2016-07-25 14:58:49 -04:00
parent c466dc5999
commit d241cce502
8 changed files with 51 additions and 6 deletions

View File

@ -102,7 +102,7 @@ class VLANSerializer(serializers.ModelSerializer):
class Meta:
model = VLAN
fields = ['id', 'site', 'group', 'vid', 'name', 'status', 'role', 'display_name']
fields = ['id', 'site', 'group', 'vid', 'name', 'status', 'role', 'description', 'display_name']
class VLANNestedSerializer(VLANSerializer):

View File

@ -474,7 +474,7 @@ class VLANForm(forms.ModelForm, BootstrapMixin):
class Meta:
model = VLAN
fields = ['site', 'group', 'vid', 'name', 'status', 'role']
fields = ['site', 'group', 'vid', 'name', 'description', 'status', 'role']
help_texts = {
'site': "The site at which this VLAN exists",
'group': "VLAN group (optional)",
@ -511,7 +511,7 @@ class VLANFromCSVForm(forms.ModelForm):
class Meta:
model = VLAN
fields = ['site', 'group', 'vid', 'name', 'status_name', 'role']
fields = ['site', 'group', 'vid', 'name', 'status_name', 'role', 'description']
def save(self, *args, **kwargs):
m = super(VLANFromCSVForm, self).save(commit=False)
@ -532,6 +532,7 @@ class VLANBulkEditForm(forms.Form, BootstrapMixin):
group = forms.ModelChoiceField(queryset=VLANGroup.objects.all(), required=False)
status = forms.ChoiceField(choices=FORM_VLAN_STATUS_CHOICES, required=False)
role = forms.ModelChoiceField(queryset=Role.objects.all(), required=False)
description = forms.CharField(max_length=100, required=False)
class VLANBulkDeleteForm(ConfirmationForm):

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-07-25 18:42
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ipam', '0004_ipam_vlangroup_uniqueness'),
]
operations = [
migrations.AddField(
model_name='vlan',
name='description',
field=models.CharField(blank=True, max_length=100),
),
migrations.AlterField(
model_name='vlan',
name='name',
field=models.CharField(max_length=64),
),
]

View File

@ -406,7 +406,8 @@ class VLAN(CreatedUpdatedModel):
MinValueValidator(1),
MaxValueValidator(4094)
])
name = models.CharField(max_length=30)
name = models.CharField(max_length=64)
description = models.CharField(max_length=100, blank=True)
status = models.PositiveSmallIntegerField('Status', choices=VLAN_STATUS_CHOICES, default=1)
role = models.ForeignKey('Role', related_name='vlans', on_delete=models.SET_NULL, blank=True, null=True)
@ -434,10 +435,12 @@ class VLAN(CreatedUpdatedModel):
def to_csv(self):
return ','.join([
self.site.name,
self.group.name if self.group else '',
str(self.vid),
self.name,
self.get_status_display(),
self.role.name if self.role else '',
self.description,
])
@property

View File

@ -565,7 +565,7 @@ class VLANBulkEditView(PermissionRequiredMixin, BulkEditView):
def update_objects(self, pk_list, form):
fields_to_update = {}
for field in ['site', 'group', 'status', 'role']:
for field in ['site', 'group', 'status', 'role', 'description']:
if form.cleaned_data[field]:
fields_to_update[field] = form.cleaned_data[field]

View File

@ -69,6 +69,16 @@
<td>Name</td>
<td>{{ vlan.name }}</td>
</tr>
<tr>
<td>Description</td>
<td>
{% if vlan.description %}
{{ vlan.description }}
{% else %}
<span class="text-muted">None</span>
{% endif %}
</td>
</tr>
<tr>
<td>Status</td>
<td>

View File

@ -11,6 +11,7 @@
<td>{{ vlan.site }}</td>
<td>{{ vlan.status }}</td>
<td>{{ vlan.role }}</td>
<td>{{ vlan.description }}</td>
</tr>
{% endfor %}
{% endblock %}

View File

@ -58,10 +58,15 @@
<td>Functional role (optional)</td>
<td>Security</td>
</tr>
<tr>
<td>Description</td>
<td>Short description (optional)</td>
<td>Security team only</td>
</tr>
</tbody>
</table>
<h4>Example</h4>
<pre>LAS2,Backend Network,1400,Cameras,Active,Security</pre>
<pre>LAS2,Backend Network,1400,Cameras,Active,Security,Security team only</pre>
</div>
</div>
{% endblock %}