diff --git a/apps/i18n/core/en/LC_MESSAGES/django.po b/apps/i18n/core/en/LC_MESSAGES/django.po index 894782267..5006b894a 100644 --- a/apps/i18n/core/en/LC_MESSAGES/django.po +++ b/apps/i18n/core/en/LC_MESSAGES/django.po @@ -6546,7 +6546,7 @@ msgid "Authentication success: {}" msgstr "" #: settings/ws.py:195 -msgid "Get ldap users is None" +msgid "No LDAP user was found" msgstr "" #: settings/ws.py:201 diff --git a/apps/i18n/core/ja/LC_MESSAGES/django.po b/apps/i18n/core/ja/LC_MESSAGES/django.po index 9307e31a6..85b96c1b0 100644 --- a/apps/i18n/core/ja/LC_MESSAGES/django.po +++ b/apps/i18n/core/ja/LC_MESSAGES/django.po @@ -6801,8 +6801,8 @@ msgid "Authentication success: {}" msgstr "認証成功: {}" #: settings/ws.py:198 -msgid "Get ldap users is None" -msgstr "Ldapユーザーを取得するにはNone" +msgid "No LDAP user was found" +msgstr "LDAPユーザーが取得されませんでした" #: settings/ws.py:204 msgid "Total {}, success {}, failure {}" diff --git a/apps/i18n/core/zh/LC_MESSAGES/django.po b/apps/i18n/core/zh/LC_MESSAGES/django.po index 27bbfc480..bca835822 100644 --- a/apps/i18n/core/zh/LC_MESSAGES/django.po +++ b/apps/i18n/core/zh/LC_MESSAGES/django.po @@ -6673,8 +6673,8 @@ msgid "Authentication success: {}" msgstr "认证成功: {}" #: settings/ws.py:198 -msgid "Get ldap users is None" -msgstr "获取 LDAP 用户为 None" +msgid "No LDAP user was found" +msgstr "没有获取到 LDAP 用户" #: settings/ws.py:204 msgid "Total {}, success {}, failure {}" diff --git a/apps/i18n/core/zh_Hant/LC_MESSAGES/django.po b/apps/i18n/core/zh_Hant/LC_MESSAGES/django.po index ea76cf31f..e2de97732 100644 --- a/apps/i18n/core/zh_Hant/LC_MESSAGES/django.po +++ b/apps/i18n/core/zh_Hant/LC_MESSAGES/django.po @@ -6676,8 +6676,8 @@ msgid "Authentication success: {}" msgstr "認證成功: {}" #: settings/ws.py:198 -msgid "Get ldap users is None" -msgstr "獲取 LDAP 用戶為 None" +msgid "No LDAP user was found" +msgstr "沒有取得到 LDAP 用戶" #: settings/ws.py:204 msgid "Total {}, success {}, failure {}" diff --git a/apps/settings/ws.py b/apps/settings/ws.py index fa2a4cf45..22fcb137a 100644 --- a/apps/settings/ws.py +++ b/apps/settings/ws.py @@ -8,6 +8,7 @@ from channels.generic.websocket import AsyncJsonWebsocketConsumer from django.core.cache import cache from django.conf import settings from django.utils.translation import gettext_lazy as _, activate +from django.utils import translation from common.db.utils import close_old_connections from common.utils import get_logger @@ -186,6 +187,11 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer): return ok, msg def run_import_user(self, data): + lang = getattr(self.scope['user'], 'lang', settings.LANGUAGE_CODE) + with translation.override(lang): + return self._run_import_user(data) + + def _run_import_user(self, data): ok = False org_ids = data.get('org_ids') username_list = data.get('username_list', []) @@ -193,15 +199,15 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer): try: users = self.get_ldap_users(username_list, cache_police) if users is None: - msg = _('Get ldap users is None') - - orgs = self.get_orgs(org_ids) - new_users, error_msg = LDAPImportUtil().perform_import(users, orgs) - ok = True - success_count = len(users) - len(error_msg) - msg = _('Total {}, success {}, failure {}').format( - len(users), success_count, len(error_msg) - ) + msg = _('No LDAP user was found') + else: + orgs = self.get_orgs(org_ids) + new_users, error_msg = LDAPImportUtil().perform_import(users, orgs) + ok = True + success_count = len(users) - len(error_msg) + msg = _('Total {}, success {}, failure {}').format( + len(users), success_count, len(error_msg) + ) except Exception as e: msg = str(e) return ok, msg