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 "" msgstr ""
#: settings/ws.py:205 #: settings/ws.py:205
msgid "Imported {} users successfully (Organization: {})" msgid "Total {}, success {}, failure {}"
msgstr "" msgstr ""
#: templates/_csv_import_export.html:8 #: templates/_csv_import_export.html:8

View File

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

View File

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