perf: i18n for ldap user import

pull/13984/head
Bai 2024-08-15 15:46:38 +08:00 committed by w940853815
parent 57f91d0973
commit 7c2e50435d
5 changed files with 22 additions and 16 deletions

View File

@ -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

View File

@ -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 {}"

View File

@ -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 {}"

View File

@ -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 {}"

View File

@ -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,8 +199,8 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer):
try:
users = self.get_ldap_users(username_list, cache_police)
if users is None:
msg = _('Get ldap users is None')
msg = _('No LDAP user was found')
else:
orgs = self.get_orgs(org_ids)
new_users, error_msg = LDAPImportUtil().perform_import(users, orgs)
ok = True