mirror of https://github.com/jumpserver/jumpserver
perf: i18n for ldap user import
parent
57f91d0973
commit
7c2e50435d
|
@ -6546,7 +6546,7 @@ msgid "Authentication success: {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: settings/ws.py:195
|
#: settings/ws.py:195
|
||||||
msgid "Get ldap users is None"
|
msgid "No LDAP user was found"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: settings/ws.py:201
|
#: settings/ws.py:201
|
||||||
|
|
|
@ -6801,8 +6801,8 @@ msgid "Authentication success: {}"
|
||||||
msgstr "認証成功: {}"
|
msgstr "認証成功: {}"
|
||||||
|
|
||||||
#: settings/ws.py:198
|
#: settings/ws.py:198
|
||||||
msgid "Get ldap users is None"
|
msgid "No LDAP user was found"
|
||||||
msgstr "Ldapユーザーを取得するにはNone"
|
msgstr "LDAPユーザーが取得されませんでした"
|
||||||
|
|
||||||
#: settings/ws.py:204
|
#: settings/ws.py:204
|
||||||
msgid "Total {}, success {}, failure {}"
|
msgid "Total {}, success {}, failure {}"
|
||||||
|
|
|
@ -6673,8 +6673,8 @@ msgid "Authentication success: {}"
|
||||||
msgstr "认证成功: {}"
|
msgstr "认证成功: {}"
|
||||||
|
|
||||||
#: settings/ws.py:198
|
#: settings/ws.py:198
|
||||||
msgid "Get ldap users is None"
|
msgid "No LDAP user was found"
|
||||||
msgstr "获取 LDAP 用户为 None"
|
msgstr "没有获取到 LDAP 用户"
|
||||||
|
|
||||||
#: settings/ws.py:204
|
#: settings/ws.py:204
|
||||||
msgid "Total {}, success {}, failure {}"
|
msgid "Total {}, success {}, failure {}"
|
||||||
|
|
|
@ -6676,8 +6676,8 @@ msgid "Authentication success: {}"
|
||||||
msgstr "認證成功: {}"
|
msgstr "認證成功: {}"
|
||||||
|
|
||||||
#: settings/ws.py:198
|
#: settings/ws.py:198
|
||||||
msgid "Get ldap users is None"
|
msgid "No LDAP user was found"
|
||||||
msgstr "獲取 LDAP 用戶為 None"
|
msgstr "沒有取得到 LDAP 用戶"
|
||||||
|
|
||||||
#: settings/ws.py:204
|
#: settings/ws.py:204
|
||||||
msgid "Total {}, success {}, failure {}"
|
msgid "Total {}, success {}, failure {}"
|
||||||
|
|
|
@ -8,6 +8,7 @@ from channels.generic.websocket import AsyncJsonWebsocketConsumer
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext_lazy as _, activate
|
from django.utils.translation import gettext_lazy as _, activate
|
||||||
|
from django.utils import translation
|
||||||
|
|
||||||
from common.db.utils import close_old_connections
|
from common.db.utils import close_old_connections
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
|
@ -186,6 +187,11 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer):
|
||||||
return ok, msg
|
return ok, msg
|
||||||
|
|
||||||
def run_import_user(self, data):
|
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
|
ok = False
|
||||||
org_ids = data.get('org_ids')
|
org_ids = data.get('org_ids')
|
||||||
username_list = data.get('username_list', [])
|
username_list = data.get('username_list', [])
|
||||||
|
@ -193,8 +199,8 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer):
|
||||||
try:
|
try:
|
||||||
users = self.get_ldap_users(username_list, cache_police)
|
users = self.get_ldap_users(username_list, cache_police)
|
||||||
if users is None:
|
if users is None:
|
||||||
msg = _('Get ldap users is None')
|
msg = _('No LDAP user was found')
|
||||||
|
else:
|
||||||
orgs = self.get_orgs(org_ids)
|
orgs = self.get_orgs(org_ids)
|
||||||
new_users, error_msg = LDAPImportUtil().perform_import(users, orgs)
|
new_users, error_msg = LDAPImportUtil().perform_import(users, orgs)
|
||||||
ok = True
|
ok = True
|
||||||
|
|
Loading…
Reference in New Issue