diff --git a/apps/assets/api/asset/asset.py b/apps/assets/api/asset/asset.py index f6cc509b3..04da13061 100644 --- a/apps/assets/api/asset/asset.py +++ b/apps/assets/api/asset/asset.py @@ -6,8 +6,8 @@ from rest_framework.decorators import action from rest_framework.response import Response from assets import serializers -from assets.models import Asset from assets.filters import IpInFilterBackend, LabelFilterBackend, NodeFilterBackend +from assets.models import Asset from assets.tasks import ( push_accounts_to_assets, test_assets_connectivity_manual, update_assets_hardware_info_manual, verify_accounts_connectivity, @@ -24,6 +24,7 @@ __all__ = [ "AssetViewSet", "AssetTaskCreateApi", "AssetsTaskCreateApi", + 'AssetFilterSet' ] diff --git a/apps/perms/api/user_permission/assets/mixin.py b/apps/perms/api/user_permission/assets/mixin.py index e7a584ef4..e95ba7aa1 100644 --- a/apps/perms/api/user_permission/assets/mixin.py +++ b/apps/perms/api/user_permission/assets/mixin.py @@ -1,13 +1,14 @@ -from rest_framework.response import Response from rest_framework.request import Request +from rest_framework.response import Response -from common.utils import get_logger -from users.models import User +from assets.api.asset.asset import AssetFilterSet from assets.api.mixin import SerializeToTreeNodeMixin from assets.models import Asset, Node -from perms.pagination import NodeGrantedAssetPagination, AllGrantedAssetPagination +from common.utils import get_logger from perms import serializers +from perms.pagination import NodeGrantedAssetPagination, AllGrantedAssetPagination from perms.utils.user_permission import UserGrantedAssetsQueryUtils +from users.models import User logger = get_logger(__name__) @@ -32,7 +33,8 @@ class UserAllGrantedAssetsQuerysetMixin: only_fields = serializers.AssetGrantedSerializer.Meta.only_fields pagination_class = AllGrantedAssetPagination ordering_fields = ("name", "address") - ordering = ('name', ) + filterset_class = AssetFilterSet + ordering = ('name',) user: User