mirror of https://github.com/jumpserver/jumpserver
fix: 应用授权按type 过滤报错
parent
689bd093be
commit
fee3715d30
|
@ -5,7 +5,6 @@ from orgs.mixins.api import OrgBulkModelViewSet
|
|||
from ..hands import IsOrgAdminOrAppUser
|
||||
from .. import serializers
|
||||
from ..models import Application
|
||||
from applications.filters import ApplicationFilter
|
||||
|
||||
|
||||
__all__ = ['ApplicationViewSet']
|
||||
|
@ -13,7 +12,11 @@ __all__ = ['ApplicationViewSet']
|
|||
|
||||
class ApplicationViewSet(OrgBulkModelViewSet):
|
||||
model = Application
|
||||
filterset_class = ApplicationFilter
|
||||
filterset_fields = {
|
||||
'name': ['exact'],
|
||||
'category': ['exact'],
|
||||
'type': ['exact', 'in'],
|
||||
}
|
||||
search_fields = ('name', 'type', 'category')
|
||||
permission_classes = (IsOrgAdminOrAppUser,)
|
||||
serializer_class = serializers.ApplicationSerializer
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
from django_filters import rest_framework as filters
|
||||
|
||||
from .models import Application
|
||||
from applications import const
|
||||
|
||||
|
||||
class ApplicationFilter(filters.FilterSet):
|
||||
type = filters.MultipleChoiceFilter(choices=const.ApplicationTypeChoices.choices)
|
||||
|
||||
class Meta:
|
||||
model = Application
|
||||
fields = ['id', 'name', 'category', 'type', 'comment']
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
from applications.models import Application
|
||||
from applications.filters import ApplicationFilter
|
||||
from perms.models import ApplicationPermission
|
||||
from perms import serializers
|
||||
from ..base import BasePermissionViewSet
|
||||
|
@ -13,7 +12,11 @@ class ApplicationPermissionViewSet(BasePermissionViewSet):
|
|||
"""
|
||||
model = ApplicationPermission
|
||||
serializer_class = serializers.ApplicationPermissionSerializer
|
||||
filterset_class = ApplicationFilter
|
||||
filterset_fields = {
|
||||
'name': ['exact'],
|
||||
'category': ['exact'],
|
||||
'type': ['exact', 'in'],
|
||||
}
|
||||
search_fields = ['name', 'category', 'type']
|
||||
custom_filter_fields = BasePermissionViewSet.custom_filter_fields + [
|
||||
'application_id', 'application'
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from rest_framework.generics import ListAPIView
|
||||
from rest_framework.response import Response
|
||||
|
||||
from applications.filters import ApplicationFilter
|
||||
from common.mixins.api import CommonApiMixin
|
||||
from applications.api.mixin import (
|
||||
SerializeApplicationToTreeNodeMixin
|
||||
|
@ -26,7 +25,13 @@ __all__ = [
|
|||
class AllGrantedApplicationsMixin(CommonApiMixin, ListAPIView):
|
||||
only_fields = serializers.ApplicationGrantedSerializer.Meta.only_fields
|
||||
serializer_class = serializers.ApplicationGrantedSerializer
|
||||
filterset_class = ApplicationFilter
|
||||
filterset_fields = {
|
||||
'id': ['exact'],
|
||||
'name': ['exact'],
|
||||
'category': ['exact'],
|
||||
'type': ['exact', 'in'],
|
||||
'comment': ['exact'],
|
||||
}
|
||||
search_fields = ['name', 'comment']
|
||||
user: None
|
||||
|
||||
|
|
Loading…
Reference in New Issue