|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
# coding: utf-8
|
|
|
|
|
#
|
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
from django.db.models import Count
|
|
|
|
|
|
|
|
|
|
from common.serializers import AdaptedBulkListSerializer
|
|
|
|
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
|
|
|
@ -25,10 +26,21 @@ class RemoteAppPermissionSerializer(BulkOrgResourceModelSerializer):
|
|
|
|
|
]
|
|
|
|
|
m2m_fields = [
|
|
|
|
|
'users', 'user_groups', 'remote_apps', 'system_users',
|
|
|
|
|
'users_amount', 'user_groups_amount', 'remote_apps_amount',
|
|
|
|
|
'system_users_amount'
|
|
|
|
|
]
|
|
|
|
|
fields = small_fields + m2m_fields
|
|
|
|
|
read_only_fields = ['created_by', 'date_created']
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def setup_eager_loading(cls, queryset):
|
|
|
|
|
""" Perform necessary eager loading of data. """
|
|
|
|
|
queryset = queryset.annotate(
|
|
|
|
|
users_amount=Count('users'), user_groups_amount=Count('user_groups'),
|
|
|
|
|
remote_apps_amount=Count('remote_apps'), system_users_amount=Count('system_users')
|
|
|
|
|
)
|
|
|
|
|
return queryset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RemoteAppPermissionUpdateUserSerializer(serializers.ModelSerializer):
|
|
|
|
|
class Meta:
|
|
|
|
|