|
|
|
@ -2,7 +2,7 @@ from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
|
|
|
|
|
from acls.models.base import ActionChoices
|
|
|
|
|
from common.serializers.fields import LabeledChoiceField, ObjectRelatedField
|
|
|
|
|
from common.serializers.fields import JSONManyToManyField, ObjectRelatedField, LabeledChoiceField
|
|
|
|
|
from orgs.models import Organization
|
|
|
|
|
from users.models import User
|
|
|
|
|
|
|
|
|
@ -52,25 +52,9 @@ class ACLAccountsSerializer(serializers.Serializer):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BaseUserAssetAccountACLSerializerMixin(serializers.Serializer):
|
|
|
|
|
users = ACLUsersSerializer(label=_('User'))
|
|
|
|
|
assets = ACLAssestsSerializer(label=_('Asset'))
|
|
|
|
|
accounts = ACLAccountsSerializer(label=_('Account'))
|
|
|
|
|
users_username_group = serializers.ListField(
|
|
|
|
|
source='users.username_group', read_only=True, child=serializers.CharField(),
|
|
|
|
|
label=_('User (username)')
|
|
|
|
|
)
|
|
|
|
|
assets_name_group = serializers.ListField(
|
|
|
|
|
source='assets.name_group', read_only=True, child=serializers.CharField(),
|
|
|
|
|
label=_('Asset (name)')
|
|
|
|
|
)
|
|
|
|
|
assets_address_group = serializers.ListField(
|
|
|
|
|
source='assets.address_group', read_only=True, child=serializers.CharField(),
|
|
|
|
|
label=_('Asset (address)')
|
|
|
|
|
)
|
|
|
|
|
accounts_username_group = serializers.ListField(
|
|
|
|
|
source='accounts.username_group', read_only=True, child=serializers.CharField(),
|
|
|
|
|
label=_('Account (username)')
|
|
|
|
|
)
|
|
|
|
|
users = JSONManyToManyField(label=_('User'))
|
|
|
|
|
assets = JSONManyToManyField(label=_('Asset'))
|
|
|
|
|
accounts = JSONManyToManyField(label=_('Account'))
|
|
|
|
|
reviewers = ObjectRelatedField(
|
|
|
|
|
queryset=User.objects, many=True, required=False, label=_('Reviewers')
|
|
|
|
|
)
|
|
|
|
@ -84,8 +68,6 @@ class BaseUserAssetAccountACLSerializerMixin(serializers.Serializer):
|
|
|
|
|
class Meta:
|
|
|
|
|
fields_mini = ["id", "name"]
|
|
|
|
|
fields_small = fields_mini + [
|
|
|
|
|
'users_username_group', 'assets_address_group', 'assets_name_group',
|
|
|
|
|
'accounts_username_group',
|
|
|
|
|
"users", "accounts", "assets", "is_active",
|
|
|
|
|
"date_created", "date_updated", "priority",
|
|
|
|
|
"action", "comment", "created_by", "org_id",
|
|
|
|
|