Show More
@@ -211,6 +211,39 b' class HomeView(BaseAppView):' | |||||
211 | } |
|
211 | } | |
212 | for obj in acl_iter] |
|
212 | for obj in acl_iter] | |
213 |
|
213 | |||
|
214 | def _get_user_groups_list(self, name_contains=None, limit=20): | |||
|
215 | org_query = name_contains | |||
|
216 | if not name_contains: | |||
|
217 | return [] | |||
|
218 | ||||
|
219 | name_contains = re.compile('(?:user_group:)(.+)').findall(name_contains) | |||
|
220 | if len(name_contains) != 1: | |||
|
221 | return [] | |||
|
222 | name_contains = name_contains[0] | |||
|
223 | ||||
|
224 | query = UserGroup.query()\ | |||
|
225 | .order_by(func.length(UserGroup.users_group_name))\ | |||
|
226 | .order_by(UserGroup.users_group_name) | |||
|
227 | ||||
|
228 | if name_contains: | |||
|
229 | ilike_expression = u'%{}%'.format(safe_unicode(name_contains)) | |||
|
230 | query = query.filter( | |||
|
231 | UserGroup.users_group_name.ilike(ilike_expression)) | |||
|
232 | query = query.limit(limit) | |||
|
233 | ||||
|
234 | acl_iter = query | |||
|
235 | ||||
|
236 | return [ | |||
|
237 | { | |||
|
238 | 'id': obj.users_group_id, | |||
|
239 | 'value': org_query, | |||
|
240 | 'value_display': obj.users_group_name, | |||
|
241 | 'type': 'user_group', | |||
|
242 | 'url': h.route_path( | |||
|
243 | 'user_group_profile', user_group_name=obj.users_group_name) | |||
|
244 | } | |||
|
245 | for obj in acl_iter] | |||
|
246 | ||||
214 | def _get_hash_commit_list(self, auth_user, query): |
|
247 | def _get_hash_commit_list(self, auth_user, query): | |
215 | org_query = query |
|
248 | org_query = query | |
216 | if not query or len(query) < 3: |
|
249 | if not query or len(query) < 3: | |
@@ -309,6 +342,10 b' class HomeView(BaseAppView):' | |||||
309 | for serialized_user in users: |
|
342 | for serialized_user in users: | |
310 | res.append(serialized_user) |
|
343 | res.append(serialized_user) | |
311 |
|
344 | |||
|
345 | user_groups = self._get_user_groups_list(query) | |||
|
346 | for serialized_user_group in user_groups: | |||
|
347 | res.append(serialized_user_group) | |||
|
348 | ||||
312 | commits = self._get_hash_commit_list(c.auth_user, query) |
|
349 | commits = self._get_hash_commit_list(c.auth_user, query) | |
313 | if commits: |
|
350 | if commits: | |
314 | unique_repos = collections.OrderedDict() |
|
351 | unique_repos = collections.OrderedDict() |
@@ -404,9 +404,11 b' Enter name of repository, or repository ' | |||||
404 |
|
404 | |||
405 | Prefix query to allow special search: |
|
405 | Prefix query to allow special search: | |
406 |
|
406 | |||
407 | For usernames, e.g user:admin |
|
407 | user:admin, to search for usernames | |
408 |
|
408 | |||
409 | For commit hash/id, e.g commit:efced4 |
|
409 | user_group:devops, to search for user groups | |
|
410 | ||||
|
411 | commit:efced4, to search for commits | |||
410 |
|
412 | |||
411 | </div> |
|
413 | </div> | |
412 | </li> |
|
414 | </li> | |
@@ -544,6 +546,9 b' For commit hash/id, e.g commit:efced4' | |||||
544 | else if (searchType === 'repo_group') { |
|
546 | else if (searchType === 'repo_group') { | |
545 | icon += '<i class="icon-folder-close"></i> '; |
|
547 | icon += '<i class="icon-folder-close"></i> '; | |
546 | } |
|
548 | } | |
|
549 | else if (searchType === 'user_group') { | |||
|
550 | icon += '<i class="icon-group"></i> '; | |||
|
551 | } | |||
547 | else if (searchType === 'user') { |
|
552 | else if (searchType === 'user') { | |
548 | icon += '<img class="gravatar" src="{0}"/>'.format(data['icon_link']); |
|
553 | icon += '<img class="gravatar" src="{0}"/>'.format(data['icon_link']); | |
549 | } |
|
554 | } |
General Comments 0
You need to be logged in to leave comments.
Login now