Improve network display

This commit is contained in:
Kumi 2019-01-03 19:20:13 +01:00
parent bbec4fd961
commit 66b1fb0fad
5 changed files with 68 additions and 3 deletions

View file

@ -0,0 +1,23 @@
# Generated by Django 2.1.3 on 2019-01-03 17:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0026_auto_20181228_0836'),
]
operations = [
migrations.AddField(
model_name='network',
name='commonname',
field=models.CharField(default='Network', max_length=64, verbose_name='Common Name'),
),
migrations.AlterField(
model_name='device',
name='wifi',
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.3 on 2019-01-03 17:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0027_auto_20190103_1710'),
]
operations = [
migrations.AlterField(
model_name='device',
name='wifi',
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
),
]

View file

@ -0,0 +1,23 @@
# Generated by Django 2.1.3 on 2019-01-03 18:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0028_auto_20190103_1718'),
]
operations = [
migrations.AlterField(
model_name='device',
name='wifi',
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
),
migrations.AlterField(
model_name='network',
name='commonname',
field=models.CharField(blank=True, max_length=64, null=True, verbose_name='Common Name'),
),
]

View file

@ -13,13 +13,13 @@ class Organization(models.Model):
return self.name return self.name
class Network(models.Model): class Network(models.Model):
commonname = models.CharField("Common Name", max_length=64, default="Network") commonname = models.CharField("Common Name", max_length=64, blank=True, null=True)
extip = models.CharField("External/Public IP", max_length=15) extip = models.CharField("External/Public IP", max_length=15)
intip = models.CharField("Internal/Private IP", max_length=15) intip = models.CharField("Internal/Private IP", max_length=15)
organizations = models.ManyToManyField(Organization) organizations = models.ManyToManyField(Organization)
def __str__(self): def __str__(self):
return "%s (%s)" % (self.intip, self.commonname) return ("%s" % self.intip + (" (%s)" % self.commonname if self.commonname else ""))
class Model(models.Model): class Model(models.Model):
name = models.CharField("Model Name", max_length=100, unique=True) name = models.CharField("Model Name", max_length=100, unique=True)

View file

@ -238,6 +238,7 @@ def ping(request, device_id):
ajax += ',\n "network": {' ajax += ',\n "network": {'
ajax += '\n "intip": "%s"' % device[0].network.intip ajax += '\n "intip": "%s"' % device[0].network.intip
ajax += ',\n "extip": "%s"' % device[0].network.extip
ajax += ',\n "commonname": "%s"' % device[0].network.commonname ajax += ',\n "commonname": "%s"' % device[0].network.commonname
ajax += '\n }' ajax += '\n }'
@ -294,7 +295,7 @@ def editdevice(request, device_id):
return redirect("/") return redirect("/")
if request.POST.get("subnet", ""): if request.POST.get("subnet", ""):
subnet = Network.objects.filter(intip=request.POST.get("subnet", device[0].network.intip)) subnet = Network.objects.filter(intip=request.POST.get("subnet", device[0].network.intip if device[0].network else "No VPN"))
if subnet[0] in subnets: if subnet[0] in subnets:
device[0].name = request.POST.get("name", "") device[0].name = request.POST.get("name", "")