Improve network display
This commit is contained in:
parent
bbec4fd961
commit
66b1fb0fad
5 changed files with 68 additions and 3 deletions
23
manager/migrations/0027_auto_20190103_1710.py
Normal file
23
manager/migrations/0027_auto_20190103_1710.py
Normal 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'),
|
||||
),
|
||||
]
|
18
manager/migrations/0028_auto_20190103_1718.py
Normal file
18
manager/migrations/0028_auto_20190103_1718.py
Normal 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'),
|
||||
),
|
||||
]
|
23
manager/migrations/0029_auto_20190103_1809.py
Normal file
23
manager/migrations/0029_auto_20190103_1809.py
Normal 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'),
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
|
|
@ -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", "")
|
||||
|
|
Loading…
Reference in a new issue