Browse Source

perf(perms): 添加应用/应用授权API的type_display/category_display字段

pull/4886/head
Bai 4 years ago committed by 老广
parent
commit
abe32e6c79
  1. 6
      apps/applications/serializers/application.py
  2. 3
      apps/perms/api/application/application_permission.py
  3. 6
      apps/perms/serializers/application/permission.py

6
apps/applications/serializers/application.py

@ -1,6 +1,7 @@
# coding: utf-8
#
from rest_framework import serializers
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from .. import models
@ -11,10 +12,13 @@ __all__ = [
class ApplicationSerializer(BulkOrgResourceModelSerializer):
category_display = serializers.ReadOnlyField(source='get_category_display')
type_display = serializers.ReadOnlyField(source='get_type_display')
class Meta:
model = models.Application
fields = [
'id', 'name', 'category', 'type', 'get_type_display', 'attrs',
'id', 'name', 'category', 'category_display', 'type', 'type_display', 'attrs',
'domain', 'created_by', 'date_created', 'date_updated', 'comment'
]
read_only_fields = [

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

@ -12,7 +12,8 @@ class ApplicationPermissionViewSet(OrgBulkModelViewSet):
"""
model = ApplicationPermission
serializer_class = serializers.ApplicationPermissionSerializer
filter_fields = ['name']
filter_fields = ['name', 'category', 'type']
search_fields = filter_fields
permission_classes = (IsOrgAdmin,)
def get_queryset(self):

6
apps/perms/serializers/application/permission.py

@ -12,6 +12,8 @@ __all__ = [
class ApplicationPermissionSerializer(BulkOrgResourceModelSerializer):
category_display = serializers.ReadOnlyField(source='get_category_display')
type_display = serializers.ReadOnlyField(source='get_type_display')
is_valid = serializers.BooleanField(read_only=True)
is_expired = serializers.BooleanField(read_only=True)
@ -19,8 +21,8 @@ class ApplicationPermissionSerializer(BulkOrgResourceModelSerializer):
model = ApplicationPermission
mini_fields = ['id', 'name']
small_fields = mini_fields + [
'is_active', 'is_expired', 'is_valid', 'created_by', 'date_created',
'date_expired', 'date_start', 'comment'
'category', 'category_display', 'type', 'type_display', 'is_active', 'is_expired',
'is_valid', 'created_by', 'date_created', 'date_expired', 'date_start', 'comment'
]
m2m_fields = [
'users', 'user_groups', 'applications', 'system_users',

Loading…
Cancel
Save