mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1427 from Tagadda/fix-appinstall
[fix] Compute choices for the yunohost admin when installing an app
This commit is contained in:
commit
3a85b5201a
2 changed files with 18 additions and 2 deletions
|
@ -57,6 +57,7 @@ from yunohost.utils.config import (
|
||||||
ask_questions_and_parse_answers,
|
ask_questions_and_parse_answers,
|
||||||
DomainQuestion,
|
DomainQuestion,
|
||||||
PathQuestion,
|
PathQuestion,
|
||||||
|
hydrate_questions_with_choices,
|
||||||
)
|
)
|
||||||
from yunohost.utils.i18n import _value_for_locale
|
from yunohost.utils.i18n import _value_for_locale
|
||||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||||
|
@ -678,6 +679,9 @@ def app_manifest(app):
|
||||||
|
|
||||||
shutil.rmtree(extracted_app_folder)
|
shutil.rmtree(extracted_app_folder)
|
||||||
|
|
||||||
|
raw_questions = manifest.get("arguments", {}).get("install", [])
|
||||||
|
manifest['arguments']['install'] = hydrate_questions_with_choices(raw_questions)
|
||||||
|
|
||||||
return manifest
|
return manifest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1114,7 +1114,7 @@ class DomainQuestion(Question):
|
||||||
self.default = _get_maindomain()
|
self.default = _get_maindomain()
|
||||||
|
|
||||||
self.choices = {
|
self.choices = {
|
||||||
domain: domain + " ★" if domain == self.default else ""
|
domain: domain + " ★" if domain == self.default else domain
|
||||||
for domain in domain_list()["domains"]
|
for domain in domain_list()["domains"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,7 +1178,7 @@ class UserQuestion(Question):
|
||||||
|
|
||||||
if self.default is None:
|
if self.default is None:
|
||||||
root_mail = "root@%s" % _get_maindomain()
|
root_mail = "root@%s" % _get_maindomain()
|
||||||
for user in self.choices:
|
for user in self.choices.keys():
|
||||||
if root_mail in user_info(user).get("mail-aliases", []):
|
if root_mail in user_info(user).get("mail-aliases", []):
|
||||||
self.default = user
|
self.default = user
|
||||||
break
|
break
|
||||||
|
@ -1396,3 +1396,15 @@ def ask_questions_and_parse_answers(
|
||||||
out.append(question)
|
out.append(question)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
def hydrate_questions_with_choices(raw_questions: List) -> List:
|
||||||
|
out = []
|
||||||
|
|
||||||
|
for raw_question in raw_questions:
|
||||||
|
question = ARGUMENTS_TYPE_PARSERS[raw_question.get("type", "string")](raw_question)
|
||||||
|
if question.choices:
|
||||||
|
raw_question["choices"] = question.choices
|
||||||
|
raw_question["default"] = question.default
|
||||||
|
out.append(raw_question)
|
||||||
|
|
||||||
|
return out
|
||||||
|
|
Loading…
Add table
Reference in a new issue