MAC address storage

This commit is contained in:
Kumi 2019-03-15 18:06:05 +00:00
parent 5e921ddfff
commit 84fe922b20
5 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,24 @@
# Generated by Django 2.1.5 on 2019-03-15 17:42
from django.db import migrations, models
import macaddress.fields
class Migration(migrations.Migration):
dependencies = [
('manager', '0051_auto_20190308_1548'),
]
operations = [
migrations.AddField(
model_name='device',
name='mac',
field=macaddress.fields.MACAddressField(blank=True, integer=True, null=True, verbose_name='Device MAC'),
),
migrations.AlterField(
model_name='device',
name='wifi',
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
),
]

View file

@ -1,5 +1,6 @@
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
from macaddress.fields import MACAddressField
import uuid import uuid
def getRandom(): def getRandom():
@ -68,6 +69,7 @@ class Device(models.Model):
wireless = models.DateTimeField("Last Update of Wireless Config", blank=True, null=True, editable=False) wireless = models.DateTimeField("Last Update of Wireless Config", blank=True, null=True, editable=False)
ssid = models.CharField("Broadcast SSID", max_length=32, blank=True, null=True) ssid = models.CharField("Broadcast SSID", max_length=32, blank=True, null=True)
key = models.CharField("Broadcast WPA2 Key", max_length=64, blank=True, null=True) key = models.CharField("Broadcast WPA2 Key", max_length=64, blank=True, null=True)
mac = MACAddressField("Device MAC", null=True, blank=True)
def __str__(self): def __str__(self):
return "%s%s" % (self.serial, " (%s)" % self.ssid if self.ssid else "") return "%s%s" % (self.serial, " (%s)" % self.ssid if self.ssid else "")

View file

@ -481,6 +481,7 @@ def makedevice(request):
device_model = request.POST.get("model", "") device_model = request.POST.get("model", "")
device_ssid = request.POST.get("ssid", device_serial) device_ssid = request.POST.get("ssid", device_serial)
device_key = request.POST.get("key", "") device_key = request.POST.get("key", "")
device_mac = request.POST.get("mac", "")
if not device_serial: if not device_serial:
orga = Organization.objects.all() orga = Organization.objects.all()
@ -524,6 +525,7 @@ def makedevice(request):
network=Network.objects.filter(intip="No VPN")[0], network=Network.objects.filter(intip="No VPN")[0],
organization=Organization.objects.filter(id=device_organization)[0], organization=Organization.objects.filter(id=device_organization)[0],
vpnconfig = open(CONFIGDIR + "/files/" + device_serial + ".ovpn").read(), vpnconfig = open(CONFIGDIR + "/files/" + device_serial + ".ovpn").read(),
mac = device_mac,
changed = timezone.now() changed = timezone.now()
) )

View file

@ -12,6 +12,10 @@
<label for="name">Device Name</label> <label for="name">Device Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)"></input> <input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)"></input>
</div> </div>
<div class="form-group">
<label for="mac">Device MAC</label>
<input type="text" class="form-control" name="mac" id="mac" placeholder="MAC Address"></input>
</div>
<div class="form-group"> <div class="form-group">
<label for="ssid">Broadcast SSID</label> <label for="ssid">Broadcast SSID</label>
<input type="text" class="form-control" name="ssid" id="ssid" placeholder="SSID to send, if different from Serial"></input> <input type="text" class="form-control" name="ssid" id="ssid" placeholder="SSID to send, if different from Serial"></input>

View file

@ -26,6 +26,10 @@
<input type="text" class="form-control" id="password" disabled="disabled" value="{{ device.password }}"></input> <input type="text" class="form-control" id="password" disabled="disabled" value="{{ device.password }}"></input>
</div> </div>
{% endif %} {% endif %}
<div class="form-group">
<label for="mac">Device MAC</label>
<input type="text" class="form-control" name="mac" id="mac" disabled="disabled" value="{{ device.mac }}"></input>
</div>
<div class="form-group"> <div class="form-group">
<label for="name">Device Name</label> <label for="name">Device Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)" {% if device.name %} value="{{ device.name }}" {% endif %}></input> <input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)" {% if device.name %} value="{{ device.name }}" {% endif %}></input>