mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #1484: Added individual "add VLAN" buttons on the VLAN groups list
This commit is contained in:
@ -512,6 +512,16 @@ class VLANGroup(models.Model):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return "{}?group_id={}".format(reverse('ipam:vlan_list'), self.pk)
|
return "{}?group_id={}".format(reverse('ipam:vlan_list'), self.pk)
|
||||||
|
|
||||||
|
def get_next_available_vid(self):
|
||||||
|
"""
|
||||||
|
Return the first available VLAN ID (1-4094) in the group.
|
||||||
|
"""
|
||||||
|
vids = [vlan['vid'] for vlan in self.vlans.order_by('vid').values('vid')]
|
||||||
|
for i in range(1, 4095):
|
||||||
|
if i not in vids:
|
||||||
|
return i
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class VLAN(CreatedUpdatedModel, CustomFieldModel):
|
class VLAN(CreatedUpdatedModel, CustomFieldModel):
|
||||||
|
@ -120,6 +120,13 @@ VLAN_ROLE_LINK = """
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
VLANGROUP_ACTIONS = """
|
VLANGROUP_ACTIONS = """
|
||||||
|
{% with next_vid=record.get_next_available_vid %}
|
||||||
|
{% if next_vid and perms.ipam.add_vlan %}
|
||||||
|
<a href="{% url 'ipam:vlan_add' %}?site={{ record.site_id }}&group={{ record.pk }}&vid={{ next_vid }}" title="Add VLAN" class="btn btn-xs btn-success">
|
||||||
|
<i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
{% if perms.ipam.change_vlangroup %}
|
{% if perms.ipam.change_vlangroup %}
|
||||||
<a href="{% url 'ipam:vlangroup_edit' pk=record.pk %}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
<a href="{% url 'ipam:vlangroup_edit' pk=record.pk %}" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-pencil" aria-hidden="true"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user