diff --git a/manager/urls.py b/manager/urls.py index 3ca3955..61e94af 100644 --- a/manager/urls.py +++ b/manager/urls.py @@ -20,6 +20,7 @@ urlpatterns = [ path('makeuser/', views.makeuser, name='makeuser'), path('wifi//edit/', views.editwifi, name='editwifi'), path('wifi//delete/', views.deletewifi, name='deletewifi'), - path('user//edit/', views.edituser, name='edituser'), + path('users//edit/', views.edituser, name='edituser'), + path('users//delete/', views.deleteuser, name='deleteuser'), path('update', views.update, name='update') ] diff --git a/manager/views.py b/manager/views.py index 29d922f..1c8e148 100644 --- a/manager/views.py +++ b/manager/views.py @@ -453,15 +453,16 @@ def deletedevice(request, device_id): @user_passes_test(is_staff) def deletewifi(request, wifi_id): - 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 - + wifi = get_object_or_404(Wifi, id=wifi_id, organization__in=request.user.organization_set.all()) + wifi.delete() return redirect("/wifi/") +@user_passes_test(is_superuser) +def deleteuser(request, user_id): + user = get_object_or_404(User, id=user_id) + user.delete() + return redirect("/users/") + @user_passes_test(is_staff) def makewifi(request): wifi_serial = request.POST.get("serial", "") diff --git a/static/js/devices.js b/static/js/devices.js index 9c779fc..9920930 100644 --- a/static/js/devices.js +++ b/static/js/devices.js @@ -51,15 +51,19 @@ function updateStatus(device_id) { }; function askdelete(device_id) { - if (confirm("Are you sure you want to delete this device?")) window.location.href = "/devices/" + device_id + "/delete"; + 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 askdeleteuser(user_id) { + if (confirm("Are you sure you want to delete this User?")) window.location.href = "/users/" + user_id + "/delete"; +}; + function askreboot(device_id) { - if (confirm("Are you sure you want to reboot this device?")) window.location.href = "/devices/" + device_id + "/reboot"; + if (confirm("Are you sure you want to reboot this Device?")) window.location.href = "/devices/" + device_id + "/reboot"; }; function downloadnotice() { @@ -76,7 +80,6 @@ function showdevices() { $("#linkusers").css("font-weight", "normal"); window.history.pushState("", "", "/devices/"); - return false; }; function showwifi() { @@ -89,7 +92,6 @@ function showwifi() { $("#linkusers").css("font-weight", "normal"); window.history.pushState("", "", "/wifi/"); - return false; }; function showusers() { @@ -102,7 +104,6 @@ function showusers() { $("#linkusers").css("font-weight", "bold"); window.history.pushState("", "", "/users/"); - return false; }; var page = document.location.pathname.substring(1, document.location.pathname.lastIndexOf('/')); diff --git a/templates/manager/index.html b/templates/manager/index.html index 4675a87..0ab2dff 100644 --- a/templates/manager/index.html +++ b/templates/manager/index.html @@ -4,7 +4,7 @@ {% block content %}

Organization: {% orgaString %}

-

User: {{ user.first_name }} {{ user.last_name }} ({{ user.username }})

+

User: {{ user.first_name }} {{ user.last_name }} ({{ user.username }})

Manage: DevicesWiFi{% if user.is_staff %} ‐ Users{% endif %}
@@ -87,7 +87,7 @@
{% if auser.is_staff %}{% endif %}{{ auser.username }}{% if auser.is_staff %}{% endif %}
{% if auser.is_staff %}{% endif %}{{ auser.first_name }} {{ auser.last_name }}{% if auser.is_staff %}{% endif %} {{ auser.userstatus.last_action }} - {% if auser.email %}{% endif %} + {% if auser.email %}{% endif %}{% if user.is_superuser %} {% endif %} {% endfor %}