Use IP Address Fields for IP addresses
This commit is contained in:
parent
6b5819fb7f
commit
bcfaaf89ef
3 changed files with 60 additions and 4 deletions
23
manager/migrations/0047_auto_20190219_1519.py
Normal file
23
manager/migrations/0047_auto_20190219_1519.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 2.1.5 on 2019-02-19 15:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('manager', '0046_auto_20190219_1517'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='device',
|
||||
name='wifi',
|
||||
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='network',
|
||||
name='extip',
|
||||
field=models.GenericIPAddressField(protocol='ipv4', unique=True, verbose_name='External/Public IP'),
|
||||
),
|
||||
]
|
33
manager/migrations/0048_auto_20190219_1521.py
Normal file
33
manager/migrations/0048_auto_20190219_1521.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 2.1.5 on 2019-02-19 15:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('manager', '0047_auto_20190219_1519'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='device',
|
||||
name='curip',
|
||||
field=models.GenericIPAddressField(blank=True, null=True, protocol='ipv4', verbose_name='Current IP Address'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='device',
|
||||
name='wifi',
|
||||
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='network',
|
||||
name='intip',
|
||||
field=models.GenericIPAddressField(protocol='ipv4', unique=True, verbose_name='Internal/Private IP'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='wifi',
|
||||
name='ip',
|
||||
field=models.GenericIPAddressField(blank=True, null=True, protocol='ipv4', verbose_name='Configuration IP'),
|
||||
),
|
||||
]
|
|
@ -15,8 +15,8 @@ class Organization(models.Model):
|
|||
|
||||
class Network(models.Model):
|
||||
name = models.CharField("Common Name", max_length=64, blank=True, null=True)
|
||||
extip = models.CharField("External/Public IP", max_length=15, unique=True)
|
||||
intip = models.CharField("Internal/Private IP", max_length=15, unique=True)
|
||||
extip = models.GenericIPAddressField("External/Public IP", protocol='ipv4', unique=True)
|
||||
intip = models.GenericIPAddressField("Internal/Private IP", protocol='ipv4', unique=True)
|
||||
organization = models.ManyToManyField(Organization)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -38,7 +38,7 @@ class Wifi(models.Model):
|
|||
ssid = models.CharField("WiFi SSID", max_length=32)
|
||||
bssid = models.CharField("WiFi BSSID", max_length=64, blank=True, null=True)
|
||||
key = models.CharField("WiFi key", max_length=32)
|
||||
ip = models.CharField("Configuration IP", max_length=15, blank=True, null=True)
|
||||
ip = models.GenericIPAddressField("Configuration IP", protocol="ipv4", blank=True, null=True)
|
||||
user = models.CharField("Configuration User Name", max_length=32, blank=True, null=True)
|
||||
password = models.CharField("Configuration Password", max_length=32, blank=True, null=True)
|
||||
|
||||
|
@ -52,7 +52,7 @@ class Device(models.Model):
|
|||
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
|
||||
network = models.ForeignKey(Network, on_delete=models.SET_NULL, blank=True, null=True)
|
||||
wifi = models.ManyToManyField(Wifi, blank=True)
|
||||
curip = models.CharField("Current IP Address", max_length=15, blank=True, null=True)
|
||||
curip = models.GenericIPAddressField("Current IP Address", protocol="ipv4", blank=True, null=True)
|
||||
lasttime = models.DateTimeField("Last Received IP", blank=True, null=True, editable=False)
|
||||
lastbeat = models.DateTimeField("Last Received Timestamp", blank=True, null=True, editable=False)
|
||||
secret = models.CharField("Secret", default=getRandom, max_length=128)
|
||||
|
|
Loading…
Reference in a new issue