From aeb320ba30a2a2ee97856d55c7f669b0c6ad7658 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:15:06 +0800 Subject: [PATCH] perf: Lina translate (#13548) Co-authored-by: feng <1304903146@qq.com> --- apps/i18n/lina/en.json | 1 + apps/i18n/lina/zh.json | 1 + apps/users/serializers/user.py | 6 +++++- apps/users/signal_handlers.py | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/i18n/lina/en.json b/apps/i18n/lina/en.json index c6ebab89e..4565ebfb4 100644 --- a/apps/i18n/lina/en.json +++ b/apps/i18n/lina/en.json @@ -391,6 +391,7 @@ "DeleteSuccess": "Successfully deleted", "DeleteSuccessMsg": "Successfully deleted", "DeleteWarningMsg": "Are you sure you want to delete", + "RemoveWarningMsg": "Are you sure you want to remove", "Deploy": "Deployment", "Description": "Description", "DestinationIP": "Destination address", diff --git a/apps/i18n/lina/zh.json b/apps/i18n/lina/zh.json index d62ad1fac..4d8f0dddf 100644 --- a/apps/i18n/lina/zh.json +++ b/apps/i18n/lina/zh.json @@ -391,6 +391,7 @@ "DeleteSuccess": "删除成功", "DeleteSuccessMsg": "删除成功", "DeleteWarningMsg": "你确定要删除", + "RemoveWarningMsg": "你确定要移除", "Deploy": "部署", "Description": "描述", "DestinationIP": "目的地址", diff --git a/apps/users/serializers/user.py b/apps/users/serializers/user.py index c64d6638a..9343af38f 100644 --- a/apps/users/serializers/user.py +++ b/apps/users/serializers/user.py @@ -16,6 +16,7 @@ from common.serializers.fields import ( ) from common.utils import pretty_string, get_logger from common.validators import PhoneValidator +from jumpserver.utils import get_current_request from orgs.utils import current_org from rbac.builtin import BuiltinRole from rbac.models import OrgRoleBinding, SystemRoleBinding, Role @@ -353,7 +354,10 @@ class UserSerializer( attrs = self.check_disallow_self_update_fields(attrs) attrs = self.change_password_to_raw(attrs) attrs = self.clean_auth_fields(attrs) - attrs.pop("password_strategy", None) + password_strategy = attrs.pop("password_strategy", None) + request = get_current_request() + if request: + request.password_strategy = password_strategy return attrs def save_and_set_custom_m2m_fields(self, validated_data, save_handler, created): diff --git a/apps/users/signal_handlers.py b/apps/users/signal_handlers.py index b99a20c92..d950a5b89 100644 --- a/apps/users/signal_handlers.py +++ b/apps/users/signal_handlers.py @@ -110,7 +110,9 @@ def on_user_create(sender, user=None, **kwargs): logger.debug("Receive user `{}` create signal".format(user.name)) from .utils import send_user_created_mail logger.info(" - Sending welcome mail ...".format(user.name)) - if user.can_send_created_mail(): + request = get_current_request() + password_strategy = getattr(request, 'password_strategy', '') + if user.can_send_created_mail() and password_strategy == 'email': send_user_created_mail(user)