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

Improved validation and workflow

This commit is contained in:
Jeremy Stretch
2018-03-08 13:25:51 -05:00
parent 7c043d9b4f
commit 70625a5cb0
4 changed files with 137 additions and 66 deletions

View File

@@ -1457,11 +1457,13 @@ class Interface(models.Model):
def save(self, *args, **kwargs):
# Remove untagged VLAN assignment for non-802.1Q interfaces
if self.mode is None:
self.untagged_vlan = None
self.tagged_vlans = []
elif self.mode is IFACE_MODE_ACCESS:
self.tagged_vlans = []
# Only "tagged" interfaces may have tagged VLANs assigned. ("tagged all" implies all VLANs are assigned.)
if self.mode is not IFACE_MODE_TAGGED:
self.tagged_vlans.clear()
return super(Interface, self).save(*args, **kwargs)