mirror of https://git.48k.eu/ogcp
views: Sort scopes tree alphanumerically
Sort tree that contain the scope information (centers, rooms, clients) so that they appear in sidebar in alphanumerical order.master
parent
3587806937
commit
01977dcd66
|
@ -236,6 +236,18 @@ def get_server_from_ip_port(str_ip_port):
|
|||
|
||||
raise Exception('Server with address ' + str_ip_port + 'is not configured')
|
||||
|
||||
def sort_scopes_recursive(ls_scopes):
|
||||
for scope in ls_scopes:
|
||||
if len(scope['scope']) != 0:
|
||||
sorted_ls = sort_scopes_recursive(scope['scope'])
|
||||
scope['scope'] = sorted_ls
|
||||
return sorted(ls_scopes, key=lambda s: s['name'].lower())
|
||||
|
||||
def sort_scopes(scopes):
|
||||
all_scopes={}
|
||||
ls = sort_scopes_recursive(scopes['scope'])
|
||||
all_scopes['scope'] = ls
|
||||
return all_scopes
|
||||
|
||||
def get_scopes(ips=set()):
|
||||
list_scopes = []
|
||||
|
@ -250,6 +262,7 @@ def get_scopes(ips=set()):
|
|||
server_scope.update(scopes)
|
||||
list_scopes.append(server_scope)
|
||||
all_scopes = {'scope': list_scopes}
|
||||
all_scopes = sort_scopes(all_scopes)
|
||||
if current_user.scopes:
|
||||
allowed_scopes = []
|
||||
get_allowed_scopes(all_scopes, allowed_scopes)
|
||||
|
|
Loading…
Reference in New Issue