diff --git a/manager/forms.py b/manager/forms.py new file mode 100644 index 0000000..f2be19d --- /dev/null +++ b/manager/forms.py @@ -0,0 +1,9 @@ +from django import forms + +from .models import Organization + +class NetworkForm(forms.Form): + name = forms.CharField(label="Common Name", max_length=64) + intip = forms.GenericIPAddressField(label="Internal IP Address", protocol="ipv4") + extip = forms.GenericIPAddressField(label="External IP Address", protocol="ipv4") + orgas = forms.MultipleChoiceField(label="Assigned Organizations", choices=[(orga.id, str(orga)) for orga in Organization.objects.all()]) diff --git a/manager/templatetags/manager.py b/manager/templatetags/manager.py index 3f64b99..4c8edd9 100644 --- a/manager/templatetags/manager.py +++ b/manager/templatetags/manager.py @@ -48,3 +48,7 @@ def userUsers(context): @register.simple_tag(takes_context=True) def userNets(context): return orgaObjects(Network, userOrgas(context)) + +@register.simple_tag +def netOrgaString(network): + return ", ".join(str(orga) for orga in network.organization.all()) diff --git a/manager/urls.py b/manager/urls.py index 3704848..13c908f 100644 --- a/manager/urls.py +++ b/manager/urls.py @@ -20,6 +20,7 @@ urlpatterns = [ path('makewifi/', views.makewifi, name='makewifi'), path('makeuser/', views.makeuser, name='makeuser'), path('makenet/', views.makenetwork, name='makenet'), + path('networks//delete', views.deletenetwork, name='deletenetwork'), path('wifi//edit/', views.editwifi, name='editwifi'), path('wifi//delete/', views.deletewifi, name='deletewifi'), path('users//edit/', views.edituser, name='edituser'), diff --git a/manager/views.py b/manager/views.py index 80f7420..6b06fc4 100644 --- a/manager/views.py +++ b/manager/views.py @@ -464,6 +464,12 @@ def deleteuser(request, user_id): user.delete() return redirect("/users/") +@user_passes_test(is_superuser) +def deletenetwork(request, network_id): + network = get_object_or_404(Network, id=network_id) + network.delete() + return redirect("/networks/") + @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 2ae67d0..96d89be 100644 --- a/static/js/devices.js +++ b/static/js/devices.js @@ -62,6 +62,10 @@ function askdeleteuser(user_id) { if (confirm("Are you sure you want to delete this User?")) window.location.href = "/users/" + user_id + "/delete"; }; +function askdeletenet(network_id) { + if (confirm("Are you sure you want to delete this Network?")) window.location.href = "/networks/" + network_id + "/delete"; +}; + function askreboot(device_id) { if (confirm("Are you sure you want to reboot this Device?")) window.location.href = "/devices/" + device_id + "/reboot"; }; diff --git a/templates/manager/form.html b/templates/manager/form.html new file mode 100644 index 0000000..5a163e4 --- /dev/null +++ b/templates/manager/form.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load bootstrap %} +{% block content %} + +
+ {% csrf_token %} + {{ form|bootstrap }} + + Cancel +
+ +{% endblock %} diff --git a/templates/manager/index.html b/templates/manager/index.html index 4d9faf2..219b6b0 100644 --- a/templates/manager/index.html +++ b/templates/manager/index.html @@ -112,10 +112,10 @@ {% userNets as networks %} {% for network in networks %} -
{{ network.name }}
+
{{ network.name }}
{{ network.intip }} {{ network.extip }} - + {% endfor %}