From 66b1fb0fadfd864253767d989f484811712fccf3 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Date: Thu, 3 Jan 2019 19:20:13 +0100 Subject: [PATCH] Improve network display --- manager/migrations/0027_auto_20190103_1710.py | 23 +++++++++++++++++++ manager/migrations/0028_auto_20190103_1718.py | 18 +++++++++++++++ manager/migrations/0029_auto_20190103_1809.py | 23 +++++++++++++++++++ manager/models.py | 4 ++-- manager/views.py | 3 ++- 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 manager/migrations/0027_auto_20190103_1710.py create mode 100644 manager/migrations/0028_auto_20190103_1718.py create mode 100644 manager/migrations/0029_auto_20190103_1809.py diff --git a/manager/migrations/0027_auto_20190103_1710.py b/manager/migrations/0027_auto_20190103_1710.py new file mode 100644 index 0000000..706fd90 --- /dev/null +++ b/manager/migrations/0027_auto_20190103_1710.py @@ -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'), + ), + ] diff --git a/manager/migrations/0028_auto_20190103_1718.py b/manager/migrations/0028_auto_20190103_1718.py new file mode 100644 index 0000000..aa22194 --- /dev/null +++ b/manager/migrations/0028_auto_20190103_1718.py @@ -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'), + ), + ] diff --git a/manager/migrations/0029_auto_20190103_1809.py b/manager/migrations/0029_auto_20190103_1809.py new file mode 100644 index 0000000..5d9cf3b --- /dev/null +++ b/manager/migrations/0029_auto_20190103_1809.py @@ -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'), + ), + ] diff --git a/manager/models.py b/manager/models.py index a55cb67..d88bf06 100644 --- a/manager/models.py +++ b/manager/models.py @@ -13,13 +13,13 @@ class Organization(models.Model): return self.name 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) intip = models.CharField("Internal/Private IP", max_length=15) organizations = models.ManyToManyField(Organization) 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): name = models.CharField("Model Name", max_length=100, unique=True) diff --git a/manager/views.py b/manager/views.py index b4b5fe5..57d82fd 100644 --- a/manager/views.py +++ b/manager/views.py @@ -238,6 +238,7 @@ def ping(request, device_id): ajax += ',\n "network": {' 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 }' @@ -294,7 +295,7 @@ def editdevice(request, device_id): return redirect("/") 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: device[0].name = request.POST.get("name", "")