summaryrefslogtreecommitdiffstats
path: root/ogcp
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp')
-rw-r--r--ogcp/views.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 7336142..9a88bbc 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -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)