diff --git a/manager/templates/manager/index.html b/manager/templates/manager/index.html index fec7229..2c104a7 100644 --- a/manager/templates/manager/index.html +++ b/manager/templates/manager/index.html @@ -46,7 +46,7 @@ {{ wifi.serial }} {{ wifi.ssid }} - + {% if user.is_staff %} {% endif %} {% endfor %} diff --git a/manager/urls.py b/manager/urls.py index 24c11f4..b45e8b4 100644 --- a/manager/urls.py +++ b/manager/urls.py @@ -16,5 +16,6 @@ urlpatterns = [ path('makedevice/', views.makedevice, name="makedevice"), path('makewifi/', views.makewifi, name='makewifi'), path('wifi//edit/', views.editwifi, name='editwifi'), + path('wifi//delete/', views.deletewifi, name='deletewifi'), path('update', views.update, name='update') ] diff --git a/manager/views.py b/manager/views.py index e81c27c..9e1fb6e 100644 --- a/manager/views.py +++ b/manager/views.py @@ -410,6 +410,17 @@ def deletedevice(request, device_id): return redirect("/") +def deletewifi(request, wifi_id): + if request.user.is_staff: + wifi = get_object_or_404(Wifi, id=wifi_id) + + for organization in Organization.objects.filter(users=request.user): + if organization == wifi.organization: + wifi.delete() + break + + return redirect("/") + def makewifi(request): wifi_serial = request.POST.get("serial", "") wifi_ssid = request.POST.get("ssid", "") diff --git a/static/js/devices.js b/static/js/devices.js index df51d32..9a514dd 100644 --- a/static/js/devices.js +++ b/static/js/devices.js @@ -53,6 +53,10 @@ function askdelete(device_id) { if (confirm("Are you sure you want to delete this device?")) window.location.href = "/devices/" + device_id + "/delete"; }; +function askdeletewifi(wifi_id) { + if (confirm("Are you sure you want to delete this WiFi?")) window.location.href = "/wifi/" + wifi_id + "/delete"; +}; + function askreboot(device_id) { if (confirm("Are you sure you want to reboot this device?")) window.location.href = "/devices/" + device_id + "/reboot"; };