Show More
@@ -39,7 +39,7 b' from rhodecode.model.forms import UserGr' | |||||
39 | from rhodecode.model.permission import PermissionModel |
|
39 | from rhodecode.model.permission import PermissionModel | |
40 | from rhodecode.model.scm import UserGroupList |
|
40 | from rhodecode.model.scm import UserGroupList | |
41 | from rhodecode.model.db import ( |
|
41 | from rhodecode.model.db import ( | |
42 | or_, count, User, UserGroup, UserGroupMember) |
|
42 | or_, count, User, UserGroup, UserGroupMember, in_filter_generator) | |
43 | from rhodecode.model.meta import Session |
|
43 | from rhodecode.model.meta import Session | |
44 | from rhodecode.model.user_group import UserGroupModel |
|
44 | from rhodecode.model.user_group import UserGroupModel | |
45 | from rhodecode.model.db import true |
|
45 | from rhodecode.model.db import true | |
@@ -107,11 +107,17 b' class AdminUserGroupsView(BaseAppView, D' | |||||
107 | allowed_ids.append(user_group.users_group_id) |
|
107 | allowed_ids.append(user_group.users_group_id) | |
108 |
|
108 | |||
109 | user_groups_data_total_count = UserGroup.query()\ |
|
109 | user_groups_data_total_count = UserGroup.query()\ | |
110 | .filter(UserGroup.users_group_id.in_(allowed_ids))\ |
|
110 | .filter(or_( | |
|
111 | # generate multiple IN to fix limitation problems | |||
|
112 | *in_filter_generator(UserGroup.users_group_id, allowed_ids) | |||
|
113 | ))\ | |||
111 | .count() |
|
114 | .count() | |
112 |
|
115 | |||
113 | user_groups_data_total_inactive_count = UserGroup.query()\ |
|
116 | user_groups_data_total_inactive_count = UserGroup.query()\ | |
114 | .filter(UserGroup.users_group_id.in_(allowed_ids))\ |
|
117 | .filter(or_( | |
|
118 | # generate multiple IN to fix limitation problems | |||
|
119 | *in_filter_generator(UserGroup.users_group_id, allowed_ids) | |||
|
120 | ))\ | |||
115 | .filter(UserGroup.users_group_active != true()).count() |
|
121 | .filter(UserGroup.users_group_active != true()).count() | |
116 |
|
122 | |||
117 | member_count = count(UserGroupMember.user_id) |
|
123 | member_count = count(UserGroupMember.user_id) | |
@@ -123,11 +129,14 b' class AdminUserGroupsView(BaseAppView, D' | |||||
123 | UserGroup.group_data, |
|
129 | UserGroup.group_data, | |
124 | User, |
|
130 | User, | |
125 | member_count.label('member_count') |
|
131 | member_count.label('member_count') | |
126 | ) \ |
|
132 | ) \ | |
127 | .filter(UserGroup.users_group_id.in_(allowed_ids)) \ |
|
133 | .filter(or_( | |
128 | .outerjoin(UserGroupMember) \ |
|
134 | # generate multiple IN to fix limitation problems | |
129 | .join(User, User.user_id == UserGroup.user_id) \ |
|
135 | *in_filter_generator(UserGroup.users_group_id, allowed_ids) | |
130 | .group_by(UserGroup, User) |
|
136 | )) \ | |
|
137 | .outerjoin(UserGroupMember) \ | |||
|
138 | .join(User, User.user_id == UserGroup.user_id) \ | |||
|
139 | .group_by(UserGroup, User) | |||
131 |
|
140 | |||
132 | base_q_inactive = base_q.filter(UserGroup.users_group_active != true()) |
|
141 | base_q_inactive = base_q.filter(UserGroup.users_group_active != true()) | |
133 |
|
142 | |||
@@ -141,14 +150,16 b' class AdminUserGroupsView(BaseAppView, D' | |||||
141 | user_groups_data_total_filtered_count = base_q.count() |
|
150 | user_groups_data_total_filtered_count = base_q.count() | |
142 | user_groups_data_total_filtered_inactive_count = base_q_inactive.count() |
|
151 | user_groups_data_total_filtered_inactive_count = base_q_inactive.count() | |
143 |
|
152 | |||
|
153 | sort_defined = False | |||
144 | if order_by == 'members_total': |
|
154 | if order_by == 'members_total': | |
145 | sort_col = member_count |
|
155 | sort_col = member_count | |
|
156 | sort_defined = True | |||
146 | elif order_by == 'user_username': |
|
157 | elif order_by == 'user_username': | |
147 | sort_col = User.username |
|
158 | sort_col = User.username | |
148 | else: |
|
159 | else: | |
149 | sort_col = getattr(UserGroup, order_by, None) |
|
160 | sort_col = getattr(UserGroup, order_by, None) | |
150 |
|
161 | |||
151 |
if |
|
162 | if sort_defined or sort_col: | |
152 | if order_dir == 'asc': |
|
163 | if order_dir == 'asc': | |
153 | sort_col = sort_col.asc() |
|
164 | sort_col = sort_col.asc() | |
154 | else: |
|
165 | else: | |
@@ -162,7 +173,7 b' class AdminUserGroupsView(BaseAppView, D' | |||||
162 |
|
173 | |||
163 | user_groups_data = [] |
|
174 | user_groups_data = [] | |
164 | for user_gr in auth_user_group_list: |
|
175 | for user_gr in auth_user_group_list: | |
165 | user_groups_data.append({ |
|
176 | row = { | |
166 | "users_group_name": user_group_name(user_gr.users_group_name), |
|
177 | "users_group_name": user_group_name(user_gr.users_group_name), | |
167 | "name_raw": h.escape(user_gr.users_group_name), |
|
178 | "name_raw": h.escape(user_gr.users_group_name), | |
168 | "description": h.escape(user_gr.user_group_description), |
|
179 | "description": h.escape(user_gr.user_group_description), | |
@@ -175,7 +186,8 b' class AdminUserGroupsView(BaseAppView, D' | |||||
175 | "owner": user_profile(user_gr.User.username), |
|
186 | "owner": user_profile(user_gr.User.username), | |
176 | "action": user_group_actions( |
|
187 | "action": user_group_actions( | |
177 | user_gr.users_group_id, user_gr.users_group_name) |
|
188 | user_gr.users_group_id, user_gr.users_group_name) | |
178 |
} |
|
189 | } | |
|
190 | user_groups_data.append(row) | |||
179 |
|
191 | |||
180 | data = ({ |
|
192 | data = ({ | |
181 | 'draw': draw, |
|
193 | 'draw': draw, |
@@ -102,7 +102,7 b'' | |||||
102 | // filter |
|
102 | // filter | |
103 | $('#q_filter').on('keyup', |
|
103 | $('#q_filter').on('keyup', | |
104 | $.debounce(250, function() { |
|
104 | $.debounce(250, function() { | |
105 |
$ |
|
105 | $userGroupsListTable.DataTable().search( | |
106 | $('#q_filter').val() |
|
106 | $('#q_filter').val() | |
107 | ).draw(); |
|
107 | ).draw(); | |
108 | }) |
|
108 | }) |
General Comments 0
You need to be logged in to leave comments.
Login now