diff --git a/apps/acls/models/base.py b/apps/acls/models/base.py index 98036ec92..43577d44c 100644 --- a/apps/acls/models/base.py +++ b/apps/acls/models/base.py @@ -56,14 +56,9 @@ class UserAssetAccountACLQuerySet(BaseACLQuerySet): queryset = queryset.filter(id__in=ids) return queryset - def filter_account(self, name=None, username=None): - q = Q() - if name: - q &= Q(accounts__name_group__contains=name) | \ - Q(accounts__name_group__contains='*') - if username: - q &= Q(accounts__username_group__contains=username) | \ - Q(accounts__username_group__contains='*') + def filter_account(self, username): + q = Q(accounts__username_group__contains=username) | \ + Q(accounts__username_group__contains='*') return self.filter(q) @@ -96,7 +91,7 @@ class UserAssetAccountBaseACL(BaseACL, OrgModelMixin): users = models.JSONField(verbose_name=_('User')) # name_group, address_group assets = models.JSONField(verbose_name=_('Asset')) - # name_group, username_group + # username_group accounts = models.JSONField(verbose_name=_('Account')) objects = ACLManager.from_queryset(UserAssetAccountACLQuerySet)() @@ -115,7 +110,7 @@ class UserAssetAccountBaseACL(BaseACL, OrgModelMixin): queryset = queryset.filter_asset(asset.name, asset.address) if account: org_id = account.org_id - queryset = queryset.filter_account(account.name, account.username) + queryset = queryset.filter_account(account.username) if account_username: queryset = queryset.filter_account(username=account_username) if org_id: diff --git a/apps/acls/serializers/command_filter.py b/apps/acls/serializers/command_filter.py index 934d38198..a8e62da41 100644 --- a/apps/acls/serializers/command_filter.py +++ b/apps/acls/serializers/command_filter.py @@ -11,12 +11,14 @@ __all__ = ["CommandFilterACLSerializer", "CommandGroupSerializer"] class CommandGroupSerializer(BulkOrgResourceModelSerializer): class Meta: model = CommandGroup - fields = ['id', 'name', 'type', 'content', 'comment'] + fields = ['id', 'name', 'type', 'content', 'ignore_case', 'comment'] class CommandFilterACLSerializer(BaseSerializer, BulkOrgResourceModelSerializer): - commands = ObjectRelatedField(queryset=CommandGroup.objects, many=True, required=False, label=_('Commands')) + command_groups = ObjectRelatedField( + queryset=CommandGroup.objects, many=True, required=False, label=_('Commands') + ) class Meta(BaseSerializer.Meta): model = CommandFilterACL - fields = BaseSerializer.Meta.fields + ['commands'] + fields = BaseSerializer.Meta.fields + ['command_groups']