mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-03 16:35:10 +00:00
[Feature] 添加功能 RemoteApp (#2706)
* [Feature] RemoteApp添加Model * [Feature] RemoteApp添加ViewSet API * [Feature] RemoteApp添加获取connection-info API * [Feature] Perms模块修改目录结构 * [Feature] RemoteAppPermission添加Model * [Feature] RemoteAppPermission添加ViewSet API * [Feature] RemoteAppPermission添加用户/用户组获取被授权的RemoteApp API * [Feature] RemoteAppPermission添加校验用户对RemoteApp的权限 API * [Feature] RemoteAppPermission添加获取用户授权的RemoteApp树 API * [Feature] RemoteAppPermission添加<添加/移除>所授权的<用户/RemoteApp> API * [Feature] RemoteApp添加创建、更新、详情、删除、用户RemoteApp等页面 * [Feature] RemoteAppPermission添加创建、更新、详情、删除、授权用户、授权RemoteApp等页面 * [Feature] RemoteApp从assets模块迁移到新添加的applications模块 * [Feature] RemoteApp/RemoteAppPermission添加迁移文件 * [Feature] RemoteApp/RemoteAppPermission修改小细节 * [Feature] RemoteApp/RemoteAppPermission修改小细节2 * [Feature] RemoteApp/RemoteAppPermission修改小细节3 * [Feature] RemoteApp更新迁移文件 * [Feature] RemoteApp/RemoteAppPermission添加翻译信息 * [Feature] RemoteApp/RemoteAppPermission删除迁移文件 * [Feature] RemoteApp/RemoteAppPermission添加迁移文件 * [Feature] RemoteApp/RemoteAppPermission修改代码风格
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
#
|
||||
|
||||
|
||||
__all__ = [
|
||||
'AssetsFilterMixin', 'RemoteAppFilterMixin',
|
||||
]
|
||||
|
||||
|
||||
class AssetsFilterMixin(object):
|
||||
"""
|
||||
对资产进行过滤(查询,排序)
|
||||
@@ -34,3 +39,38 @@ class AssetsFilterMixin(object):
|
||||
|
||||
queryset = sort_assets(queryset, order_by=order_by, reverse=reverse)
|
||||
return queryset
|
||||
|
||||
|
||||
class RemoteAppFilterMixin(object):
|
||||
"""
|
||||
对RemoteApp进行过滤(查询,排序)
|
||||
"""
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
queryset = self.search_remote_apps(queryset)
|
||||
queryset = self.sort_remote_apps(queryset)
|
||||
return queryset
|
||||
|
||||
def search_remote_apps(self, queryset):
|
||||
value = self.request.query_params.get('search')
|
||||
if not value:
|
||||
return queryset
|
||||
queryset = [
|
||||
remote_app for remote_app in queryset if value in remote_app.name
|
||||
]
|
||||
return queryset
|
||||
|
||||
def sort_remote_apps(self, queryset):
|
||||
order_by = self.request.query_params.get('order')
|
||||
if not order_by:
|
||||
order_by = 'name'
|
||||
if order_by.startswith('-'):
|
||||
order_by = order_by.lstrip('-')
|
||||
reverse = True
|
||||
else:
|
||||
reverse = False
|
||||
|
||||
queryset = sorted(
|
||||
queryset, key=lambda x: getattr(x, order_by), reverse=reverse
|
||||
)
|
||||
return queryset
|
||||
|
Reference in New Issue
Block a user