2020-06-16 08:12:59 +00:00
|
|
|
from rest_framework import generics
|
2020-08-16 15:08:58 +00:00
|
|
|
|
|
|
|
from assets.models import SystemUser
|
2020-06-16 08:12:59 +00:00
|
|
|
from common.permissions import IsValidUser
|
2021-02-05 05:29:29 +00:00
|
|
|
from perms.utils.asset.user_permission import get_user_all_asset_perm_ids
|
2020-06-16 08:12:59 +00:00
|
|
|
from .. import serializers
|
|
|
|
|
|
|
|
|
|
|
|
class SystemUserPermission(generics.ListAPIView):
|
|
|
|
permission_classes = (IsValidUser,)
|
|
|
|
serializer_class = serializers.SystemUserSerializer
|
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
user = self.request.user
|
2020-08-16 15:08:58 +00:00
|
|
|
|
2021-03-08 02:08:51 +00:00
|
|
|
asset_perm_ids = get_user_all_asset_perm_ids(user)
|
2020-08-16 15:08:58 +00:00
|
|
|
queryset = SystemUser.objects.filter(
|
2021-03-08 02:08:51 +00:00
|
|
|
granted_by_permissions__id__in=asset_perm_ids
|
2020-08-16 15:08:58 +00:00
|
|
|
).distinct()
|
|
|
|
|
|
|
|
return queryset
|