dont fail without nodes

This commit is contained in:
j 2016-01-05 23:22:17 +05:30
parent 55ba49b631
commit 8aef4a62ef

View file

@ -87,12 +87,13 @@ def getUsers(data):
for u in models.User.query.filter(models.User.id!=settings.USER_ID).all():
users.append(u.json())
ids.add(u.id)
for id in state.nodes._local._nodes:
if id not in ids:
n = state.nodes._local._nodes[id].copy()
n['online'] = True
n['name'] = n['username']
users.append(n)
if state.nodes:
for id in state.nodes._local._nodes:
if id not in ids:
n = state.nodes._local._nodes[id].copy()
n['online'] = True
n['name'] = n['username']
users.append(n)
users.sort(key=lambda u: ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or '')))
return {
"users": users