perf: 修改BasePermissionViewSet的custom_filter_fields

pull/5223/head
Bai 2020-12-11 16:18:03 +08:00 committed by Jiangjie.Bai
parent 2db9c90a74
commit 213221beae
3 changed files with 10 additions and 0 deletions

View File

@ -14,6 +14,9 @@ class ApplicationPermissionViewSet(BasePermissionViewSet):
serializer_class = serializers.ApplicationPermissionSerializer
filter_fields = ['name', 'category', 'type']
search_fields = filter_fields
custom_filter_fields = BasePermissionViewSet.custom_filter_fields + [
'application_id', 'application'
]
def get_queryset(self):
queryset = super().get_queryset().prefetch_related(

View File

@ -22,6 +22,9 @@ class AssetPermissionViewSet(BasePermissionViewSet):
model = AssetPermission
serializer_class = serializers.AssetPermissionSerializer
filter_fields = ['name']
custom_filter_fields = BasePermissionViewSet.custom_filter_fields + [
'node_id', 'node', 'asset_id', 'hostname', 'ip'
]
def get_queryset(self):
queryset = super().get_queryset().prefetch_related(

View File

@ -14,6 +14,10 @@ __all__ = [
class BasePermissionViewSet(OrgBulkModelViewSet):
custom_filter_fields = [
'user_id', 'username', 'search', 'system_user_id', 'system_user',
'user_group_id', 'user_group'
]
permission_classes = (IsOrgAdmin,)
def filter_valid(self, queryset):