fix: Import failed but no prompt message (#14966)

* fix: Import failed but no prompt message

* fix: Prompt message

---------

Co-authored-by: halo <wuyihuangw@gmail.com>
This commit is contained in:
fit2bot 2025-03-04 14:44:57 +08:00 committed by GitHub
parent 9cd1619990
commit 180303ccb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 13 deletions

View File

@ -6197,7 +6197,7 @@ msgid "Get ldap users is None"
msgstr ""
#: settings/ws.py:205
msgid "Imported {} users successfully (Organization: {})"
msgid "Total {}, success {}, failure {}"
msgstr ""
#: templates/_csv_import_export.html:8

View File

@ -6295,8 +6295,8 @@ msgid "Get ldap users is None"
msgstr "获取 LDAP 用户为 None"
#: settings/ws.py:205
msgid "Imported {} users successfully (Organization: {})"
msgstr "成功导入 {} 个用户 ( 组织: {} )"
msgid "Total {}, success {}, failure {}"
msgstr "总共 {},成功 {},失败 {}"
#: templates/_csv_import_export.html:8
msgid "Export"

View File

@ -193,16 +193,14 @@ class LdapWebsocket(AsyncJsonWebsocketConsumer):
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)
if error_msg:
msg = error_msg
count = users if users is None else len(users)
orgs_name = ', '.join([str(org) for org in orgs])
ok = True
msg = _('Imported {} users successfully (Organization: {})').format(count, orgs_name)
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