perf: 查看用户授权

pull/8931/head
feng626 2022-09-29 18:01:23 +08:00
parent ec0c334acc
commit b2991362f1
3 changed files with 5 additions and 5 deletions

View File

@ -57,7 +57,7 @@ class LoginAssetACLAccountsSerializer(serializers.Serializer):
class LoginAssetACLSerializer(BulkOrgResourceModelSerializer):
users = LoginAssetACLUsersSerializer()
assets = LoginAssetACLAssestsSerializer()
account = LoginAssetACLAccountsSerializer()
accounts = LoginAssetACLAccountsSerializer()
reviewers_amount = serializers.IntegerField(read_only=True, source='reviewers.count')
action_display = serializers.ReadOnlyField(source='get_action_display', label=_('Action'))

View File

@ -108,7 +108,6 @@ class AssetSerializer(JMSWritableNestedModelSerializer):
instance.nodes.set(nodes_to_set)
def validate_nodes(self, nodes):
print("Nodes: ", nodes)
if nodes:
return nodes
request = self.context.get('request')

View File

@ -32,8 +32,8 @@ class UserDirectGrantedAssetsQuerysetMixin:
class UserAllGrantedAssetsQuerysetMixin:
only_fields = serializers.AssetGrantedSerializer.Meta.only_fields
pagination_class = AllGrantedAssetPagination
ordering_fields = ("hostname", "address", "port", "cpu_cores")
ordering = ('hostname', )
ordering_fields = ("name", "address", "port", "cpu_cores")
ordering = ('name', )
user: User
@ -41,7 +41,8 @@ class UserAllGrantedAssetsQuerysetMixin:
if getattr(self, 'swagger_fake_view', False):
return Asset.objects.none()
queryset = UserGrantedAssetsQueryUtils(self.user).get_all_granted_assets()
queryset = queryset.prefetch_related('platform').only(*self.only_fields)
only_fields = [i for i in self.only_fields if i not in ['protocols']]
queryset = queryset.prefetch_related('platform', 'protocols').only(*only_fields)
return queryset