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.conf import settings
from macaddress.fields import MACAddressField
import uuid
def getRandom():
@ -68,6 +69,7 @@ class Device(models.Model):
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)
key = models.CharField("Broadcast WPA2 Key", max_length=64, blank=True, null=True)
mac = MACAddressField("Device MAC", null=True, blank=True)
def __str__(self):
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_ssid = request.POST.get("ssid", device_serial)
device_key = request.POST.get("key", "")
device_mac = request.POST.get("mac", "")
if not device_serial:
orga = Organization.objects.all()
@ -524,6 +525,7 @@ def makedevice(request):
network=Network.objects.filter(intip="No VPN")[0],
organization=Organization.objects.filter(id=device_organization)[0],
vpnconfig = open(CONFIGDIR + "/files/" + device_serial + ".ovpn").read(),
mac = device_mac,
changed = timezone.now()
)

View file

@ -12,6 +12,10 @@
<label for="name">Device Name</label>
<input type="text" class="form-control" name="name" id="name" placeholder="Enter Device Name (Optional)"></input>
</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">
<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>

View file

@ -26,6 +26,10 @@
<input type="text" class="form-control" id="password" disabled="disabled" value="{{ device.password }}"></input>
</div>
{% 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">
<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>