From ec1e64c29aef8ab8459b0645d1080c7fc53e8557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=A7=8B=E5=B9=B3?= <446105468@qq.com> Date: Mon, 20 Nov 2023 15:59:48 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=20=E6=8F=90=E4=BE=9B=20Agent=20?= =?UTF-8?q?=E5=8C=85=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20(closed=20#1683)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/node_man/handlers/meta.py | 4 ++++ apps/node_man/tests/test_views/test_package_manage_views.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/node_man/handlers/meta.py b/apps/node_man/handlers/meta.py index 5a96ceea1..e335fc7fa 100644 --- a/apps/node_man/handlers/meta.py +++ b/apps/node_man/handlers/meta.py @@ -21,6 +21,7 @@ from apps.node_man.handlers.cmdb import CmdbHandler from apps.node_man.handlers.install_channel import InstallChannelHandler from apps.node_man.models import GsePackages +from apps.node_man.permissions.package_manage import PackageManagePermission from apps.node_man.serializers.package_manage import FilterConditionPackageSerializer from apps.utils import APIModel @@ -473,6 +474,9 @@ def fetch_os_type_children(os_types: Tuple = constants.OsType): @staticmethod def fetch_agent_pkg_manager_children(): + if not PackageManagePermission().has_permission(None, None): + return {"message": "该用户不是管理员"} + version_set, tag_name_description_map, creator_set, is_ready_set = set(), dict(), set(), set() gse_packages = FilterConditionPackageSerializer(GsePackages.objects.all(), many=True).data for gse_package in gse_packages: diff --git a/apps/node_man/tests/test_views/test_package_manage_views.py b/apps/node_man/tests/test_views/test_package_manage_views.py index e1a0fc5ca..f865a957a 100644 --- a/apps/node_man/tests/test_views/test_package_manage_views.py +++ b/apps/node_man/tests/test_views/test_package_manage_views.py @@ -13,7 +13,7 @@ ) from apps.core.tag.models import Tag from apps.node_man.handlers.meta import MetaHandler -from apps.node_man.models import GsePackages, GsePackageDesc +from apps.node_man.models import GsePackageDesc, GsePackages from apps.node_man.tests.utils import create_gse_package @@ -31,7 +31,7 @@ def clear_agent_data(cls): def test_list(self): # 和之前的builder.make加起来100 - create_gse_package(99) + create_gse_package(99, start_id=1000) result = self.client.get(path="/api/agent/package/") self.assertEqual(result["result"], True)