[Update] 修改一些bug

pull/2874/head
ibuler 2019-07-01 20:01:47 +08:00
parent 034fee0f75
commit 4d3856975b
5 changed files with 7 additions and 28 deletions

View File

@ -130,7 +130,9 @@ class NodeChildrenAsTreeApi(generics.ListAPIView):
include_assets = self.request.query_params.get('assets', '0') == '1'
if not include_assets:
return queryset
assets = self.node.get_assets()
assets = self.node.get_assets().prefetch_related("protocols").only(
"id", "hostname", "ip", 'platform', "os", "org_id",
)
for asset in assets:
queryset.append(asset.as_tree_node(self.node))
return queryset

View File

@ -138,30 +138,6 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
return instance
# class AssetAsNodeSerializer(serializers.ModelSerializer):
# protocols = ProtocolSerializer(many=True)
#
# class Meta:
# model = Asset
# fields = ['id', 'hostname', 'ip', 'platform', 'protocols']
# class MyAssetGrantedSerializer(AssetGrantedSerializer):
# """
# 普通用户获取授权的资产定义的数据结构
# """
# protocols = ProtocolSerializer(many=True)
#
# class Meta:
# model = Asset
# fields = (
# "id", "hostname", "system_users_granted",
# "is_active", "system_users_join", "org_name",
# "os", "platform", "comment", "org_id", "protocols"
# )
class AssetSimpleSerializer(serializers.ModelSerializer):
class Meta:

View File

@ -155,7 +155,9 @@ class AssetPermissionViewSet(viewsets.ModelViewSet):
return queryset
def get_queryset(self):
return self.queryset.all()
return self.queryset.all().prefetch_related(
"nodes", "assets", "users", "user_groups", "system_users"
)
class AssetPermissionRemoveUserApi(RetrieveUpdateAPIView):

View File

@ -1,7 +1,6 @@
# ~*~ coding: utf-8 ~*~
from __future__ import absolute_import, unicode_literals
from functools import reduce
from django import forms
from django.utils.translation import ugettext_lazy as _

View File

@ -48,7 +48,7 @@
{% bootstrap_field form.system_users layout="horizontal" %}
<div class="hr-line-dashed"></div>
<h3>{% trans 'Action' %}</h3>
{% bootstrap_field form.action layout="horizontal" %}
{% bootstrap_field form.actions layout="horizontal" %}
<div class="hr-line-dashed"></div>
<h3>{% trans 'Other' %}</h3>
<div class="form-group">