Use different URLs for administration frontend pages
This commit is contained in:
parent
ed21a6238e
commit
64a5dc1105
8 changed files with 26 additions and 20 deletions
|
@ -5,6 +5,8 @@ from . import views
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
path('devices/', views.devices, name='devices'),
|
path('devices/', views.devices, name='devices'),
|
||||||
|
path('wifi/', views.devices, name='wifi'),
|
||||||
|
path('users/', views.devices, name='users'),
|
||||||
path('hosts', views.hosts, name='hosts'),
|
path('hosts', views.hosts, name='hosts'),
|
||||||
path('devices/<int:device_id>/edit/', views.editdevice, name='editdevice'),
|
path('devices/<int:device_id>/edit/', views.editdevice, name='editdevice'),
|
||||||
path('devices/<int:device_id>/ping/', views.ping, name="ping"),
|
path('devices/<int:device_id>/ping/', views.ping, name="ping"),
|
||||||
|
|
|
@ -37,7 +37,7 @@ def is_staff(user):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index(request):
|
def index(request):
|
||||||
return redirect("/devices")
|
return redirect("/devices/")
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def heartbeat(request):
|
def heartbeat(request):
|
||||||
|
@ -208,7 +208,7 @@ def editdevice(request, device_id):
|
||||||
for organization in Organization.objects.filter(users=request.user):
|
for organization in Organization.objects.filter(users=request.user):
|
||||||
device = device or Device.objects.filter(id=device_id, organization=organization)
|
device = device or Device.objects.filter(id=device_id, organization=organization)
|
||||||
if not device:
|
if not device:
|
||||||
return redirect("/")
|
return redirect("/devices/")
|
||||||
|
|
||||||
for subnet in Network.objects.filter(organizations=device[0].organization):
|
for subnet in Network.objects.filter(organizations=device[0].organization):
|
||||||
subnets.add(subnet)
|
subnets.add(subnet)
|
||||||
|
@ -248,7 +248,7 @@ def editdevice(request, device_id):
|
||||||
device[0].changed = timezone.now()
|
device[0].changed = timezone.now()
|
||||||
device[0].save()
|
device[0].save()
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/devices/")
|
||||||
|
|
||||||
return render(request, "manager/edit.html",
|
return render(request, "manager/edit.html",
|
||||||
{
|
{
|
||||||
|
@ -269,7 +269,7 @@ def edituser(request, user_id):
|
||||||
for organization in orgas:
|
for organization in orgas:
|
||||||
user = user or User.objects.filter(id=user_id, organization=organization)
|
user = user or User.objects.filter(id=user_id, organization=organization)
|
||||||
if not user:
|
if not user:
|
||||||
return redirect("/")
|
return redirect("/users/")
|
||||||
|
|
||||||
if request.POST.get("form", ""):
|
if request.POST.get("form", ""):
|
||||||
newfirst = request.POST.get("firstname", "")
|
newfirst = request.POST.get("firstname", "")
|
||||||
|
@ -304,7 +304,7 @@ def edituser(request, user_id):
|
||||||
|
|
||||||
user[0].save()
|
user[0].save()
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/users/")
|
||||||
|
|
||||||
return render(request, "manager/edituser.html",
|
return render(request, "manager/edituser.html",
|
||||||
{
|
{
|
||||||
|
@ -324,7 +324,7 @@ def editwifi(request, wifi_id):
|
||||||
wifi = wifi or Wifi.objects.filter(id=wifi_id, organization=organization)
|
wifi = wifi or Wifi.objects.filter(id=wifi_id, organization=organization)
|
||||||
|
|
||||||
if not wifi:
|
if not wifi:
|
||||||
return redirect("/")
|
return redirect("/wifi/")
|
||||||
|
|
||||||
if request.POST.get("serial", ""):
|
if request.POST.get("serial", ""):
|
||||||
newserial = request.POST.get("serial", "")
|
newserial = request.POST.get("serial", "")
|
||||||
|
@ -344,7 +344,7 @@ def editwifi(request, wifi_id):
|
||||||
|
|
||||||
wifi[0].save()
|
wifi[0].save()
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/wifi/")
|
||||||
|
|
||||||
return render(request, "manager/editwifi.html",
|
return render(request, "manager/editwifi.html",
|
||||||
{
|
{
|
||||||
|
@ -382,7 +382,7 @@ def rebootdevice(request, device_id):
|
||||||
device[0].reboot = True
|
device[0].reboot = True
|
||||||
device[0].save()
|
device[0].save()
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/devices/")
|
||||||
|
|
||||||
@user_passes_test(is_staff)
|
@user_passes_test(is_staff)
|
||||||
def updatedevice(request, device_id):
|
def updatedevice(request, device_id):
|
||||||
|
@ -396,7 +396,7 @@ def updatedevice(request, device_id):
|
||||||
device[0].update = True
|
device[0].update = True
|
||||||
device[0].save()
|
device[0].save()
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/devices/")
|
||||||
|
|
||||||
@user_passes_test(is_superuser)
|
@user_passes_test(is_superuser)
|
||||||
def deletedevice(request, device_id):
|
def deletedevice(request, device_id):
|
||||||
|
@ -414,7 +414,7 @@ def deletedevice(request, device_id):
|
||||||
|
|
||||||
device.delete()
|
device.delete()
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/devices/")
|
||||||
|
|
||||||
@user_passes_test(is_staff)
|
@user_passes_test(is_staff)
|
||||||
def deletewifi(request, wifi_id):
|
def deletewifi(request, wifi_id):
|
||||||
|
@ -425,7 +425,7 @@ def deletewifi(request, wifi_id):
|
||||||
wifi.delete()
|
wifi.delete()
|
||||||
break
|
break
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/wifi/")
|
||||||
|
|
||||||
@user_passes_test(is_staff)
|
@user_passes_test(is_staff)
|
||||||
def makewifi(request):
|
def makewifi(request):
|
||||||
|
@ -448,7 +448,7 @@ def makewifi(request):
|
||||||
organization = Organization.objects.filter(id=wifi_organization)[0]
|
organization = Organization.objects.filter(id=wifi_organization)[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/wifi/")
|
||||||
|
|
||||||
@user_passes_test(is_superuser)
|
@user_passes_test(is_superuser)
|
||||||
def makedevice(request):
|
def makedevice(request):
|
||||||
|
@ -462,7 +462,7 @@ def makedevice(request):
|
||||||
device_model = request.POST.get("model", "")
|
device_model = request.POST.get("model", "")
|
||||||
|
|
||||||
if not request.user.is_superuser:
|
if not request.user.is_superuser:
|
||||||
return redirect("/")
|
return redirect("/devices/")
|
||||||
|
|
||||||
if not device_serial:
|
if not device_serial:
|
||||||
orga = Organization.objects.all()
|
orga = Organization.objects.all()
|
||||||
|
@ -506,7 +506,7 @@ def makedevice(request):
|
||||||
vpnconfig = open(CONFIGDIR + "/files/" + device_serial + ".ovpn").read()
|
vpnconfig = open(CONFIGDIR + "/files/" + device_serial + ".ovpn").read()
|
||||||
)
|
)
|
||||||
|
|
||||||
return redirect("/")
|
return redirect("/devices/")
|
||||||
|
|
||||||
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
|
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
|
||||||
def createUserStatus(sender, instance, created, **kwargs):
|
def createUserStatus(sender, instance, created, **kwargs):
|
||||||
|
|
|
@ -96,7 +96,11 @@ function showusers() {
|
||||||
$("#linkusers").css("font-weight", "bold");
|
$("#linkusers").css("font-weight", "bold");
|
||||||
};
|
};
|
||||||
|
|
||||||
showdevices();
|
var page = document.location.pathname.substring(1, document.location.pathname.lastIndexOf('/'));
|
||||||
|
console.log(page)
|
||||||
|
if (page == "users") showusers();
|
||||||
|
else if (page == "wifi") showwifi();
|
||||||
|
else showdevices();
|
||||||
|
|
||||||
$("div[id$='-indicator']").each(function() {
|
$("div[id$='-indicator']").each(function() {
|
||||||
device_id = this.id.split("-")[0];
|
device_id = this.id.split("-")[0];
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-success">Create Device</button>
|
<button type="submit" class="btn btn-success">Create Device</button>
|
||||||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
<a class="btn btn-danger" href="/devices/" role="button">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-success">Create WiFi</button>
|
<button type="submit" class="btn btn-success">Create WiFi</button>
|
||||||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
<a class="btn btn-danger" href="/wifi/" role="button">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button type="submit" class="btn btn-success">Apply Changes</button>
|
<button type="submit" class="btn btn-success">Apply Changes</button>
|
||||||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
<a class="btn btn-danger" href="/devices/" role="button">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<input hidden value="sent" name="form"/>
|
<input hidden value="sent" name="form"/>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-success">Apply Changes</button>
|
<button type="submit" class="btn btn-success">Apply Changes</button>
|
||||||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
<a class="btn btn-danger" href="/users/" role="button">Cancel</a>
|
||||||
{% if user == auser %}
|
{% if user == auser %}
|
||||||
<a class="btn btn-info" href="/account/two_factor/" role="button">Two-Factor Settings</a>
|
<a class="btn btn-info" href="/account/two_factor/" role="button">Two-Factor Settings</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<input type="text" class="form-control" id="key" name="key" value="{{ wifi.key }}"></input>
|
<input type="text" class="form-control" id="key" name="key" value="{{ wifi.key }}"></input>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-success">Apply Changes</button>
|
<button type="submit" class="btn btn-success">Apply Changes</button>
|
||||||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
<a class="btn btn-danger" href="/wifi/" role="button">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue