Set user variable in template tag

This commit is contained in:
Kumi 2019-02-01 14:38:37 +00:00
parent 60704455c6
commit 2c300ffc01
3 changed files with 6 additions and 7 deletions

View file

@ -21,3 +21,7 @@ def updateUserStatus(user, sec = False):
except Exception as e:
return "<!-- %s -->" % str(e)
return ""
@register.simple_tag(takes_context=True)
def setUser(context):
return context.request.user

View file

@ -255,12 +255,7 @@ def ping(request, device_id):
@login_required
def devices(request):
return render(request, "manager/index.html",
{
"title": "Device Administration",
"user": request.user
}
)
return render(request, "manager/index.html", {"title": "Device Administration"})
@login_required
def editdevice(request, device_id):
@ -318,7 +313,6 @@ def editdevice(request, device_id):
"title": "Edit Device",
"device": device[0],
"subnets": subnets,
"user": request.user,
"wifis": wifis,
"curfis": Wifi.objects.filter(device=device[0])
}

View file

@ -13,6 +13,7 @@
{% load static %}
{% load repo %}
{% load userstatus %}
{% setUser as user %}
{% updateUserStatus user %}
{% block header %}
{% endblock %}