2021-02-05 05:29:29 +00:00
|
|
|
from rest_framework.generics import ListAPIView
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
from common.utils import get_logger
|
2022-03-15 02:52:19 +00:00
|
|
|
from ..mixin import AssetRoleAdminMixin, AssetRoleUserMixin
|
2021-02-05 05:29:29 +00:00
|
|
|
from .mixin import (
|
|
|
|
UserAllGrantedAssetsQuerysetMixin, UserDirectGrantedAssetsQuerysetMixin, UserFavoriteGrantedAssetsMixin,
|
|
|
|
UserGrantedNodeAssetsMixin, AssetsSerializerFormatMixin, AssetsTreeFormatMixin,
|
|
|
|
)
|
|
|
|
|
|
|
|
__all__ = [
|
2022-09-13 07:41:39 +00:00
|
|
|
'UserDirectGrantedAssetsApi', 'MyDirectGrantedAssetsApi',
|
|
|
|
'UserFavoriteGrantedAssetsApi',
|
|
|
|
'MyFavoriteGrantedAssetsApi', 'UserDirectGrantedAssetsAsTreeApi',
|
2022-09-08 12:46:56 +00:00
|
|
|
'MyUngroupAssetsAsTreeApi',
|
|
|
|
'UserAllGrantedAssetsApi', 'MyAllGrantedAssetsApi', 'MyAllAssetsAsTreeApi',
|
2022-09-13 07:41:39 +00:00
|
|
|
'UserGrantedNodeAssetsApi',
|
2021-02-05 05:29:29 +00:00
|
|
|
'MyGrantedNodeAssetsApi',
|
|
|
|
]
|
|
|
|
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class UserDirectGrantedAssetsApi(
|
|
|
|
AssetRoleAdminMixin,
|
|
|
|
UserDirectGrantedAssetsQuerysetMixin, AssetsSerializerFormatMixin, ListAPIView
|
|
|
|
):
|
|
|
|
""" 直接授权给用户的资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class MyDirectGrantedAssetsApi(AssetRoleUserMixin, UserDirectGrantedAssetsApi):
|
|
|
|
""" 直接授权给我的资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class UserFavoriteGrantedAssetsApi(
|
|
|
|
AssetRoleAdminMixin,
|
|
|
|
UserFavoriteGrantedAssetsMixin, AssetsSerializerFormatMixin, ListAPIView
|
|
|
|
):
|
|
|
|
""" 用户收藏的授权资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class MyFavoriteGrantedAssetsApi(AssetRoleUserMixin, UserFavoriteGrantedAssetsApi):
|
|
|
|
""" 我收藏的授权资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class UserDirectGrantedAssetsAsTreeApi(AssetsTreeFormatMixin, UserDirectGrantedAssetsApi):
|
|
|
|
""" 用户直接授权的资产作为树 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class MyUngroupAssetsAsTreeApi(AssetRoleUserMixin, UserDirectGrantedAssetsAsTreeApi):
|
|
|
|
""" 我的未分组节点下的资产作为树 """
|
|
|
|
|
2021-02-05 05:29:29 +00:00
|
|
|
def get_queryset(self):
|
|
|
|
queryset = super().get_queryset()
|
|
|
|
if not settings.PERM_SINGLE_ASSET_TO_UNGROUP_NODE:
|
|
|
|
queryset = queryset.none()
|
|
|
|
return queryset
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class UserAllGrantedAssetsApi(
|
|
|
|
AssetRoleAdminMixin,
|
|
|
|
UserAllGrantedAssetsQuerysetMixin, AssetsSerializerFormatMixin, ListAPIView
|
|
|
|
):
|
|
|
|
""" 授权给用户的所有资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class MyAllGrantedAssetsApi(AssetRoleUserMixin, UserAllGrantedAssetsApi):
|
|
|
|
""" 授权给我的所有资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class MyAllAssetsAsTreeApi(AssetsTreeFormatMixin, MyAllGrantedAssetsApi):
|
|
|
|
""" 授权给我的所有资产作为树 """
|
2021-03-16 07:34:40 +00:00
|
|
|
pass
|
2021-02-05 05:29:29 +00:00
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class UserGrantedNodeAssetsApi(
|
|
|
|
AssetRoleAdminMixin, UserGrantedNodeAssetsMixin, AssetsSerializerFormatMixin, ListAPIView
|
|
|
|
):
|
|
|
|
""" 授权给用户的节点资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-09-13 07:41:39 +00:00
|
|
|
class MyGrantedNodeAssetsApi(AssetRoleUserMixin, UserGrantedNodeAssetsApi):
|
|
|
|
""" 授权给我的节点资产 """
|
2021-02-05 05:29:29 +00:00
|
|
|
pass
|