##// END OF EJS Templates
permissions: use same way of sorting of user_group permissions like user ones....
marcink -
r2060:2a7a5569 default
parent child Browse files
Show More
@@ -84,7 +84,7 b' PERMISSION_TYPE_SORT = {'
84 }
84 }
85
85
86
86
87 def display_sort(obj):
87 def display_user_sort(obj):
88 """
88 """
89 Sort function used to sort permissions in .permissions() function of
89 Sort function used to sort permissions in .permissions() function of
90 Repository, RepoGroup, UserGroup. Also it put the default user in front
90 Repository, RepoGroup, UserGroup. Also it put the default user in front
@@ -97,6 +97,17 b' def display_sort(obj):'
97 return prefix + obj.username
97 return prefix + obj.username
98
98
99
99
100 def display_user_group_sort(obj):
101 """
102 Sort function used to sort permissions in .permissions() function of
103 Repository, RepoGroup, UserGroup. Also it put the default user in front
104 of all other resources
105 """
106
107 prefix = PERMISSION_TYPE_SORT.get(obj.permission.split('.')[-1], '')
108 return prefix + obj.users_group_name
109
110
100 def _hash_key(k):
111 def _hash_key(k):
101 return md5_safe(k)
112 return md5_safe(k)
102
113
@@ -1351,7 +1362,7 b' class UserGroup(Base, BaseModel):'
1351 # filter the perm rows by 'default' first and then sort them by
1362 # filter the perm rows by 'default' first and then sort them by
1352 # admin,write,read,none permissions sorted again alphabetically in
1363 # admin,write,read,none permissions sorted again alphabetically in
1353 # each group
1364 # each group
1354 perm_rows = sorted(perm_rows, key=display_sort)
1365 perm_rows = sorted(perm_rows, key=display_user_sort)
1355
1366
1356 _admin_perm = 'usergroup.admin'
1367 _admin_perm = 'usergroup.admin'
1357 owner_row = []
1368 owner_row = []
@@ -1387,6 +1398,7 b' class UserGroup(Base, BaseModel):'
1387 usr.permission = _user_group.permission.permission_name
1398 usr.permission = _user_group.permission.permission_name
1388 perm_rows.append(usr)
1399 perm_rows.append(usr)
1389
1400
1401 perm_rows = sorted(perm_rows, key=display_user_group_sort)
1390 return perm_rows
1402 return perm_rows
1391
1403
1392 def _get_default_perms(self, user_group, suffix=''):
1404 def _get_default_perms(self, user_group, suffix=''):
@@ -1837,7 +1849,7 b' class Repository(Base, BaseModel):'
1837 # filter the perm rows by 'default' first and then sort them by
1849 # filter the perm rows by 'default' first and then sort them by
1838 # admin,write,read,none permissions sorted again alphabetically in
1850 # admin,write,read,none permissions sorted again alphabetically in
1839 # each group
1851 # each group
1840 perm_rows = sorted(perm_rows, key=display_sort)
1852 perm_rows = sorted(perm_rows, key=display_user_sort)
1841
1853
1842 _admin_perm = 'repository.admin'
1854 _admin_perm = 'repository.admin'
1843 owner_row = []
1855 owner_row = []
@@ -1874,6 +1886,7 b' class Repository(Base, BaseModel):'
1874 usr.permission = _user_group.permission.permission_name
1886 usr.permission = _user_group.permission.permission_name
1875 perm_rows.append(usr)
1887 perm_rows.append(usr)
1876
1888
1889 perm_rows = sorted(perm_rows, key=display_user_group_sort)
1877 return perm_rows
1890 return perm_rows
1878
1891
1879 def get_api_data(self, include_secrets=False):
1892 def get_api_data(self, include_secrets=False):
@@ -2489,7 +2502,7 b' class RepoGroup(Base, BaseModel):'
2489 # filter the perm rows by 'default' first and then sort them by
2502 # filter the perm rows by 'default' first and then sort them by
2490 # admin,write,read,none permissions sorted again alphabetically in
2503 # admin,write,read,none permissions sorted again alphabetically in
2491 # each group
2504 # each group
2492 perm_rows = sorted(perm_rows, key=display_sort)
2505 perm_rows = sorted(perm_rows, key=display_user_sort)
2493
2506
2494 _admin_perm = 'group.admin'
2507 _admin_perm = 'group.admin'
2495 owner_row = []
2508 owner_row = []
@@ -2525,6 +2538,7 b' class RepoGroup(Base, BaseModel):'
2525 usr.permission = _user_group.permission.permission_name
2538 usr.permission = _user_group.permission.permission_name
2526 perm_rows.append(usr)
2539 perm_rows.append(usr)
2527
2540
2541 perm_rows = sorted(perm_rows, key=display_user_group_sort)
2528 return perm_rows
2542 return perm_rows
2529
2543
2530 def get_api_data(self):
2544 def get_api_data(self):
General Comments 0
You need to be logged in to leave comments. Login now