Delete WiFi from UI, fix #2
This commit is contained in:
parent
cc5ebc9234
commit
5a7ca7bead
4 changed files with 17 additions and 1 deletions
|
@ -46,7 +46,7 @@
|
|||
<tr>
|
||||
<td>{{ wifi.serial }}</td>
|
||||
<td>{{ wifi.ssid }}</td>
|
||||
<td><a href="/wifi/{{ wifi.id }}/edit"><i class="fas fa-edit" title="Edit WiFi"></i></a></td>
|
||||
<td><a href="/wifi/{{ wifi.id }}/edit"><i class="fas fa-edit" title="Edit WiFi"></i></a>{% if user.is_staff %} <a href="#"><i style="color: darkred;" onclick="askdeletewifi({{ wifi.id }});" class="fas fa-trash-alt" title="Delete WiFi"></i></a>{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
|
|
|
@ -16,5 +16,6 @@ urlpatterns = [
|
|||
path('makedevice/', views.makedevice, name="makedevice"),
|
||||
path('makewifi/', views.makewifi, name='makewifi'),
|
||||
path('wifi/<int:wifi_id>/edit/', views.editwifi, name='editwifi'),
|
||||
path('wifi/<int:wifi_id>/delete/', views.deletewifi, name='deletewifi'),
|
||||
path('update', views.update, name='update')
|
||||
]
|
||||
|
|
|
@ -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", "")
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue