Add status field to WirelessLink

This commit is contained in:
jeremystretch
2021-10-13 14:31:30 -04:00
parent ec0560a2c5
commit 95ed07a95e
21 changed files with 80 additions and 37 deletions

View File

@@ -2,6 +2,7 @@ from django.core.exceptions import ValidationError
from django.db import models
from django.urls import reverse
from dcim.choices import LinkStatusChoices
from dcim.constants import WIRELESS_IFACE_TYPES
from extras.utils import extras_features
from netbox.models import BigIDModel, PrimaryModel
@@ -70,6 +71,11 @@ class WirelessLink(PrimaryModel):
blank=True,
verbose_name='SSID'
)
status = models.CharField(
max_length=50,
choices=LinkStatusChoices,
default=LinkStatusChoices.STATUS_CONNECTED
)
description = models.CharField(
max_length=200,
blank=True
@@ -94,6 +100,8 @@ class WirelessLink(PrimaryModel):
objects = RestrictedQuerySet.as_manager()
clone_fields = ('ssid', 'status')
class Meta:
ordering = ['pk']
unique_together = ('interface_a', 'interface_b')
@@ -104,6 +112,9 @@ class WirelessLink(PrimaryModel):
def get_absolute_url(self):
return reverse('wireless:wirelesslink', args=[self.pk])
def get_status_class(self):
return LinkStatusChoices.CSS_CLASSES.get(self.status)
def clean(self):
# Validate interface types