From 5b53cfb4dd2dcf02b0ab9777d43da741505644a0 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Tue, 29 May 2018 11:50:09 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E6=A0=91=E8=8A=82=E7=82=B9(=E6=95=B0=E9=87=8F)=E6=80=BB?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=AD=A4=E8=8A=82=E7=82=B9=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E8=B5=84=E4=BA=A7=E6=80=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/api/node.py | 9 +-------- apps/assets/serializers/node.py | 8 +------- apps/assets/templates/assets/_asset_list_modal.html | 2 +- apps/assets/templates/assets/asset_list.html | 7 +++---- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/apps/assets/api/node.py b/apps/assets/api/node.py index b0e974f5c..11f45cc8d 100644 --- a/apps/assets/api/node.py +++ b/apps/assets/api/node.py @@ -42,14 +42,7 @@ __all__ = [ class NodeViewSet(BulkModelViewSet): queryset = Node.objects.all() permission_classes = (IsSuperUser,) - # serializer_class = serializers.NodeSerializer - - def get_serializer_class(self): - show_current_asset = self.request.query_params.get('show_current_asset') - if show_current_asset: - return serializers.NodeCurrentSerializer - else: - return serializers.NodeSerializer + serializer_class = serializers.NodeSerializer def perform_create(self, serializer): child_key = Node.root().get_next_child_key() diff --git a/apps/assets/serializers/node.py b/apps/assets/serializers/node.py index 73639a100..6683a3027 100644 --- a/apps/assets/serializers/node.py +++ b/apps/assets/serializers/node.py @@ -9,7 +9,7 @@ from .asset import AssetGrantedSerializer __all__ = [ 'NodeSerializer', "NodeGrantedSerializer", "NodeAddChildrenSerializer", - "NodeAssetsSerializer", "NodeCurrentSerializer", + "NodeAssetsSerializer", ] @@ -77,12 +77,6 @@ class NodeSerializer(serializers.ModelSerializer): return fields -class NodeCurrentSerializer(NodeSerializer): - @staticmethod - def get_assets_amount(obj): - return obj.get_assets().count() - - class NodeAssetsSerializer(serializers.ModelSerializer): assets = serializers.PrimaryKeyRelatedField(many=True, queryset=Asset.objects.all()) diff --git a/apps/assets/templates/assets/_asset_list_modal.html b/apps/assets/templates/assets/_asset_list_modal.html index a0d96a7ef..faf569137 100644 --- a/apps/assets/templates/assets/_asset_list_modal.html +++ b/apps/assets/templates/assets/_asset_list_modal.html @@ -95,7 +95,7 @@ function initTree2() { }; var zNodes = []; - $.get("{% url 'api-assets:node-list' %}?show_current_asset=1", function(data, status){ + $.get("{% url 'api-assets:node-list' %}", function(data, status){ $.each(data, function (index, value) { value["pId"] = value["parent"]; {#value["open"] = true;#} diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index ab08f7b67..b5e53aaba 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -399,8 +399,7 @@ function initTree() { }; var zNodes = []; - var query_params = {'show_current_asset': getCookie('show_current_asset')}; - $.get("{% url 'api-assets:node-list' %}", query_params, function(data, status){ + $.get("{% url 'api-assets:node-list' %}", function(data, status){ $.each(data, function (index, value) { value["pId"] = value["parent"]; if (value["key"] === "0") { @@ -436,7 +435,7 @@ $(document).ready(function(){ initTable(); initTree(); - if(getCookie('show_current_asset') === 'yes'){ + if(getCookie('show_current_asset') === '1'){ $('#show_all_asset').css('display', 'inline-block'); } else{ @@ -564,7 +563,7 @@ $(document).ready(function(){ hideRMenu(); $(this).css('display', 'none'); $('#show_all_asset').css('display', 'inline-block'); - setCookie('show_current_asset', 'yes'); + setCookie('show_current_asset', '1'); location.reload(); }) .on('click', '.btn-show-all-asset', function(){