Browse Source

fix: 应用授权按type 过滤报错

pull/6529/head
xinwen 3 years ago committed by Jiangjie.Bai
parent
commit
fee3715d30
  1. 7
      apps/applications/api/application.py
  2. 12
      apps/applications/filters.py
  3. 7
      apps/perms/api/application/application_permission.py
  4. 9
      apps/perms/api/application/user_permission/user_permission_applications.py

7
apps/applications/api/application.py

@ -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

12
apps/applications/filters.py

@ -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']

7
apps/perms/api/application/application_permission.py

@ -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'

9
apps/perms/api/application/user_permission/user_permission_applications.py

@ -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…
Cancel
Save