Starting code base optimizations
This commit is contained in:
parent
5979e2cec5
commit
a251f07ed4
2 changed files with 6 additions and 14 deletions
|
@ -255,27 +255,19 @@ def ping(request, device_id):
|
|||
|
||||
@login_required
|
||||
def devices(request):
|
||||
user = request.user
|
||||
devices = set()
|
||||
wifis = set()
|
||||
users = set()
|
||||
|
||||
for organization in Organization.objects.filter(users=user):
|
||||
for device in Device.objects.filter(organization=organization):
|
||||
devices.add(device)
|
||||
for wifi in Wifi.objects.filter(organization=organization):
|
||||
wifis.add(wifi)
|
||||
if user.is_staff:
|
||||
for orgauser in User.objects.filter(organization=organization):
|
||||
orgauser.organizations = set()
|
||||
for orga in Organization.objects.filter(users=orgauser):
|
||||
orgauser.organizations.add(orga)
|
||||
users.add(orgauser)
|
||||
for organization in request.user.organization_set.all():
|
||||
devices = devices.union(organization.device_set.all())
|
||||
wifis = wifis.union(organization.wifi_set.all())
|
||||
users = users.union(organization.users.all()) if request.user.is_superuser else users
|
||||
|
||||
return render(request, "manager/index.html",
|
||||
{
|
||||
"title": "Device Administration",
|
||||
"user": user,
|
||||
"user": request.user,
|
||||
"devices": sorted(devices, key=lambda x: x.serial),
|
||||
"wifis": sorted(wifis, key=lambda x: x.serial),
|
||||
"users": sorted(users, key=lambda x: x.username)
|
||||
|
|
|
@ -7,7 +7,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
SECRET_KEY = '=go8&h#^kh6ksr11e2z-@4qqd6t%63$x#-!s#l_yhw@oyanrys'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ["admin360.kumi.host", "test360.kumi.host"]
|
||||
|
||||
|
|
Loading…
Reference in a new issue