Only display WiFi selection in device editor if device model supports WWAN

This commit is contained in:
Kumi 2019-01-09 17:08:39 +01:00
parent 5a7ca7bead
commit 7095ce60be
3 changed files with 35 additions and 9 deletions

View file

@ -0,0 +1,23 @@
# Generated by Django 2.1.3 on 2019-01-09 15:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('manager', '0030_auto_20190103_1823'),
]
operations = [
migrations.AddField(
model_name='model',
name='wwan',
field=models.BooleanField(default=False, verbose_name='Supports WWAN (External WiFi)'),
),
migrations.AlterField(
model_name='device',
name='wifi',
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
),
]

View file

@ -26,6 +26,7 @@ class Model(models.Model):
extname = models.CharField("Manufacturer Model Name", max_length=100)
config = models.TextField("OpenWRT Compile Config", blank=True, null=True)
firmware = models.DateTimeField("Firmware Modification Date", auto_now=True)
wwan = models.BooleanField("Supports WWAN (External WiFi)", default=False)
def __str__(self):
return self.name

View file

@ -39,15 +39,17 @@
</select>
<small id="subnetHelp" class="form-text text-muted">A network change will require a reboot of the device to be applied.</small>
</div>
<div class="form-group">
<label for="wifi">Assigned WiFis</label>
<select multiple class="custom-select mr-sm-2" id="wifi" name="wifi">
{% for choice in wifis %}
<option {% if choice in curfis %} selected {% endif %} value="{{ choice.id }}">{{ choice }}</option>
{% endfor %}
</select>
<small id="subnetHelp" class="form-text text-muted">This feature is not yet available on all devices.</small>
</div>
{% if device.model.wwan %}
<div class="form-group">
<label for="wifi">Assigned WiFis</label>
<select multiple class="custom-select mr-sm-2" id="wifi" name="wifi">
{% for choice in wifis %}
<option {% if choice in curfis %} selected {% endif %} value="{{ choice.id }}">{{ choice }}</option>
{% endfor %}
</select>
<small id="subnetHelp" class="form-text text-muted">This feature is not yet available on all devices.</small>
</div>
{% endif %}
<div class="form-group form-check">
<input class="form-check-input" type="checkbox" value="True" {% if device.reboot %} checked {% endif %} id="reboot" name="reboot">