Merge pull request #187 from jumpserver/search_sort

feat (sort search) 对搜索结果排序
pull/188/head^2
ibuler 2016-04-01 11:54:28 +08:00
commit e902fccd39
1 changed files with 3 additions and 3 deletions

View File

@ -438,8 +438,10 @@ class Nav(object):
self.user = user
self.search_result = None
self.user_perm = get_group_user_perm(self.user)
self.perm_assets = tuple(self.user_perm.get('asset', []))
self.perm_assets = sorted(self.user_perm.get('asset', []).keys(),
key=lambda x: [int(num) for num in x.ip.split('.') if num.isdigit()])
self.perm_asset_groups = self.user_perm.get('asset_group', [])
print self.perm_assets
@staticmethod
def print_nav():
@ -494,8 +496,6 @@ class Nav(object):
# 如果没有输入就展现所有
self.search_result = self.perm_assets
self.search_result = list(set(self.search_result))
def print_search_result(self):
color_print('[%-3s] %-12s %-15s %-5s %-10s %s' % ('ID', '主机名', 'IP', '端口', '系统用户', '备注'), 'title')
if hasattr(self.search_result, '__iter__'):