From a085ee0ccbc15f3b4ecd4b92d15576b13eb0ece8 Mon Sep 17 00:00:00 2001 From: jiayuan929 <252461528@qq.com> Date: Tue, 13 Aug 2024 15:18:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=91=E5=8E=9F?= =?UTF-8?q?=E7=94=9F=E5=BA=94=E7=94=A8=E9=83=A8=E7=BD=B2=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E9=87=8D=E5=A4=8D=E8=AE=B0=E5=BD=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paasng/paasng/misc/audit/handlers.py | 24 ++++++++++--------- .../platform/engine/deploy/archive/base.py | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apiserver/paasng/paasng/misc/audit/handlers.py b/apiserver/paasng/paasng/misc/audit/handlers.py index 7487beacc5..879eb60522 100644 --- a/apiserver/paasng/paasng/misc/audit/handlers.py +++ b/apiserver/paasng/paasng/misc/audit/handlers.py @@ -30,6 +30,7 @@ from paasng.misc.audit import constants from paasng.misc.audit.models import AppLatestOperationRecord, AppOperationRecord from paasng.misc.audit.service import DataDetail, add_app_audit_record +from paasng.platform.applications.constants import ApplicationType from paasng.platform.applications.models import Application, ModuleEnvironment from paasng.platform.engine.constants import JobStatus from paasng.platform.engine.models import Deployment @@ -102,17 +103,18 @@ def on_model_post_save(sender, instance, created, raw, using, update_fields, *ar def on_deploy_finished(sender: ModuleEnvironment, deployment: Deployment, **kwargs): """当普通应用部署完成后,记录操作审计记录""" application = deployment.app_environment.application - result_code = JOB_STATUS_TO_RESULT_CODE.get(deployment.status, constants.ResultCode.ONGOING) - add_app_audit_record( - app_code=application.code, - user=deployment.operator, - action_id=AppAction.BASIC_DEVELOP, - operation=constants.OperationEnum.DEPLOY, - target=constants.OperationTarget.APP, - module_name=deployment.app_environment.module.name, - environment=deployment.app_environment.environment, - result_code=result_code, - ) + if application.type == ApplicationType.DEFAULT: + result_code = JOB_STATUS_TO_RESULT_CODE.get(deployment.status, constants.ResultCode.ONGOING) + add_app_audit_record( + app_code=application.code, + user=deployment.operator, + action_id=AppAction.BASIC_DEVELOP, + operation=constants.OperationEnum.DEPLOY, + target=constants.OperationTarget.APP, + module_name=deployment.app_environment.module.name, + environment=deployment.app_environment.environment, + result_code=result_code, + ) @receiver(post_cnative_env_deploy) diff --git a/apiserver/paasng/paasng/platform/engine/deploy/archive/base.py b/apiserver/paasng/paasng/platform/engine/deploy/archive/base.py index 9aff06897a..fcd775e39a 100644 --- a/apiserver/paasng/paasng/platform/engine/deploy/archive/base.py +++ b/apiserver/paasng/paasng/platform/engine/deploy/archive/base.py @@ -127,7 +127,7 @@ def finish_archive(self, operation_id: str, status: ReleaseStatus, error_detail: action_id=AppAction.BASIC_DEVELOP, operation=OperationEnum.OFFLINE, target=OperationTarget.APP, - module_name=offline_op.app_environmenv.module.name, + module_name=offline_op.app_environment.module.name, environment=offline_op.app_environment.environment, result_code=result_code, ) From 7dc81dd9e577b83cf5e34fe8bd88491d362433c0 Mon Sep 17 00:00:00 2001 From: jiayuan929 <252461528@qq.com> Date: Tue, 13 Aug 2024 15:27:21 +0800 Subject: [PATCH 2/3] fix: minor --- .../paasng/paasng/misc/audit/handlers.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/apiserver/paasng/paasng/misc/audit/handlers.py b/apiserver/paasng/paasng/misc/audit/handlers.py index 879eb60522..a02897e490 100644 --- a/apiserver/paasng/paasng/misc/audit/handlers.py +++ b/apiserver/paasng/paasng/misc/audit/handlers.py @@ -103,18 +103,19 @@ def on_model_post_save(sender, instance, created, raw, using, update_fields, *ar def on_deploy_finished(sender: ModuleEnvironment, deployment: Deployment, **kwargs): """当普通应用部署完成后,记录操作审计记录""" application = deployment.app_environment.application - if application.type == ApplicationType.DEFAULT: - result_code = JOB_STATUS_TO_RESULT_CODE.get(deployment.status, constants.ResultCode.ONGOING) - add_app_audit_record( - app_code=application.code, - user=deployment.operator, - action_id=AppAction.BASIC_DEVELOP, - operation=constants.OperationEnum.DEPLOY, - target=constants.OperationTarget.APP, - module_name=deployment.app_environment.module.name, - environment=deployment.app_environment.environment, - result_code=result_code, - ) + if application.type != ApplicationType.DEFAULT: + return + result_code = JOB_STATUS_TO_RESULT_CODE.get(deployment.status, constants.ResultCode.ONGOING) + add_app_audit_record( + app_code=application.code, + user=deployment.operator, + action_id=AppAction.BASIC_DEVELOP, + operation=constants.OperationEnum.DEPLOY, + target=constants.OperationTarget.APP, + module_name=deployment.app_environment.module.name, + environment=deployment.app_environment.environment, + result_code=result_code, + ) @receiver(post_cnative_env_deploy) From b93b8539751960bfbd1f9c39cf008aa063b5c503 Mon Sep 17 00:00:00 2001 From: jiayuan929 <252461528@qq.com> Date: Tue, 13 Aug 2024 15:35:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apiserver/paasng/locale/en/LC_MESSAGES/django.po | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/apiserver/paasng/locale/en/LC_MESSAGES/django.po b/apiserver/paasng/locale/en/LC_MESSAGES/django.po index a19674e627..73681346b5 100644 --- a/apiserver/paasng/locale/en/LC_MESSAGES/django.po +++ b/apiserver/paasng/locale/en/LC_MESSAGES/django.po @@ -809,10 +809,8 @@ msgstr "Delete" #: paasng/bk_plugins/pluginscenter/constants.py:147 #: paasng/misc/audit/constants.py:88 -#, fuzzy -#| msgid "已下架" msgid "下架" -msgstr "Archived" +msgstr "archive" #: paasng/bk_plugins/pluginscenter/constants.py:148 msgid "重新上架" @@ -1718,16 +1716,16 @@ msgstr "renew" msgid "部署" msgstr "Deploy" -#: paasng/misc/audit/models.py:103 -#, python-brace-format -msgid " {self.module_name} 模块{env}" -msgstr " {self.module_name} module {env}" - #: paasng/misc/audit/models.py:105 #, python-brace-format msgid " {self.module_name} 模块" msgstr " {self.module_name} module" +#: paasng/misc/audit/models.py:103 +#, python-brace-format +msgid " {self.module_name} 模块{env}" +msgstr " {self.module_name} module {env}" + #: paasng/misc/audit/models.py:107 #, python-brace-format msgid "{env}" @@ -1736,7 +1734,7 @@ msgstr "{env}" #: paasng/misc/audit/models.py:122 #, python-brace-format msgid "{user} {operation}{module_env_info}{result}" -msgstr "{user} {operation}{module_env_info}{result}" +msgstr "{user} {operation}{module_env_info} {result}" #: paasng/misc/audit/models.py:127 #, python-brace-format