mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Don't make so many queries for user info when building UserOption form
This commit is contained in:
parent
f56f235705
commit
8ee5aade72
1 changed files with 4 additions and 2 deletions
|
@ -941,9 +941,11 @@ class UserOption(BaseChoicesOption):
|
||||||
|
|
||||||
super().__init__(question)
|
super().__init__(question)
|
||||||
|
|
||||||
|
users = user_list(fields = ["username", "fullname", "mail", "mail-alias"])["users"]
|
||||||
|
|
||||||
self.choices = {
|
self.choices = {
|
||||||
username: f"{infos['fullname']} ({infos['mail']})"
|
username: f"{infos['fullname']} ({infos['mail']})"
|
||||||
for username, infos in user_list()["users"].items()
|
for username, infos in users.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
if not self.choices:
|
if not self.choices:
|
||||||
|
@ -958,7 +960,7 @@ class UserOption(BaseChoicesOption):
|
||||||
# Should be replaced by something like "any first user we find in the admin group"
|
# Should be replaced by something like "any first user we find in the admin group"
|
||||||
root_mail = "root@%s" % _get_maindomain()
|
root_mail = "root@%s" % _get_maindomain()
|
||||||
for user in self.choices.keys():
|
for user in self.choices.keys():
|
||||||
if root_mail in user_info(user).get("mail-aliases", []):
|
if root_mail in users[user].get("mail-aliases", []):
|
||||||
self.default = user
|
self.default = user
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue