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 = [
|
||||
path('', views.index, name='index'),
|
||||
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('devices/<int:device_id>/edit/', views.editdevice, name='editdevice'),
|
||||
path('devices/<int:device_id>/ping/', views.ping, name="ping"),
|
||||
|
|
|
@ -37,7 +37,7 @@ def is_staff(user):
|
|||
|
||||
@login_required
|
||||
def index(request):
|
||||
return redirect("/devices")
|
||||
return redirect("/devices/")
|
||||
|
||||
@csrf_exempt
|
||||
def heartbeat(request):
|
||||
|
@ -208,7 +208,7 @@ def editdevice(request, device_id):
|
|||
for organization in Organization.objects.filter(users=request.user):
|
||||
device = device or Device.objects.filter(id=device_id, organization=organization)
|
||||
if not device:
|
||||
return redirect("/")
|
||||
return redirect("/devices/")
|
||||
|
||||
for subnet in Network.objects.filter(organizations=device[0].organization):
|
||||
subnets.add(subnet)
|
||||
|
@ -248,7 +248,7 @@ def editdevice(request, device_id):
|
|||
device[0].changed = timezone.now()
|
||||
device[0].save()
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/devices/")
|
||||
|
||||
return render(request, "manager/edit.html",
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ def edituser(request, user_id):
|
|||
for organization in orgas:
|
||||
user = user or User.objects.filter(id=user_id, organization=organization)
|
||||
if not user:
|
||||
return redirect("/")
|
||||
return redirect("/users/")
|
||||
|
||||
if request.POST.get("form", ""):
|
||||
newfirst = request.POST.get("firstname", "")
|
||||
|
@ -304,7 +304,7 @@ def edituser(request, user_id):
|
|||
|
||||
user[0].save()
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/users/")
|
||||
|
||||
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)
|
||||
|
||||
if not wifi:
|
||||
return redirect("/")
|
||||
return redirect("/wifi/")
|
||||
|
||||
if request.POST.get("serial", ""):
|
||||
newserial = request.POST.get("serial", "")
|
||||
|
@ -344,7 +344,7 @@ def editwifi(request, wifi_id):
|
|||
|
||||
wifi[0].save()
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/wifi/")
|
||||
|
||||
return render(request, "manager/editwifi.html",
|
||||
{
|
||||
|
@ -382,7 +382,7 @@ def rebootdevice(request, device_id):
|
|||
device[0].reboot = True
|
||||
device[0].save()
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/devices/")
|
||||
|
||||
@user_passes_test(is_staff)
|
||||
def updatedevice(request, device_id):
|
||||
|
@ -396,7 +396,7 @@ def updatedevice(request, device_id):
|
|||
device[0].update = True
|
||||
device[0].save()
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/devices/")
|
||||
|
||||
@user_passes_test(is_superuser)
|
||||
def deletedevice(request, device_id):
|
||||
|
@ -414,7 +414,7 @@ def deletedevice(request, device_id):
|
|||
|
||||
device.delete()
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/devices/")
|
||||
|
||||
@user_passes_test(is_staff)
|
||||
def deletewifi(request, wifi_id):
|
||||
|
@ -425,7 +425,7 @@ def deletewifi(request, wifi_id):
|
|||
wifi.delete()
|
||||
break
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/wifi/")
|
||||
|
||||
@user_passes_test(is_staff)
|
||||
def makewifi(request):
|
||||
|
@ -448,7 +448,7 @@ def makewifi(request):
|
|||
organization = Organization.objects.filter(id=wifi_organization)[0]
|
||||
)
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/wifi/")
|
||||
|
||||
@user_passes_test(is_superuser)
|
||||
def makedevice(request):
|
||||
|
@ -462,7 +462,7 @@ def makedevice(request):
|
|||
device_model = request.POST.get("model", "")
|
||||
|
||||
if not request.user.is_superuser:
|
||||
return redirect("/")
|
||||
return redirect("/devices/")
|
||||
|
||||
if not device_serial:
|
||||
orga = Organization.objects.all()
|
||||
|
@ -506,7 +506,7 @@ def makedevice(request):
|
|||
vpnconfig = open(CONFIGDIR + "/files/" + device_serial + ".ovpn").read()
|
||||
)
|
||||
|
||||
return redirect("/")
|
||||
return redirect("/devices/")
|
||||
|
||||
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
|
||||
def createUserStatus(sender, instance, created, **kwargs):
|
||||
|
|
|
@ -96,7 +96,11 @@ function showusers() {
|
|||
$("#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() {
|
||||
device_id = this.id.split("-")[0];
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</select>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</select>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<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>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<input hidden value="sent" name="form"/>
|
||||
|
||||
<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 %}
|
||||
<a class="btn btn-info" href="/account/two_factor/" role="button">Two-Factor Settings</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<input type="text" class="form-control" id="key" name="key" value="{{ wifi.key }}"></input>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue