From 740eaa43aef51c1125851b99005185c826e363d2 Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Fri, 28 Jan 2022 02:39:02 +0000 Subject: [PATCH 1/2] typos --- src/utils/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/config.py b/src/utils/config.py index 56c45d5f8..f3b906f00 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -1114,7 +1114,7 @@ class DomainQuestion(Question): self.default = _get_maindomain() self.choices = { - domain: domain + " ★" if domain == self.default else "" + domain: domain + " ★" if domain == self.default else domain for domain in domain_list()["domains"] } @@ -1178,7 +1178,7 @@ class UserQuestion(Question): if self.default is None: 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", []): self.default = user break From 9486931674230f65a5fe87f036ebcf231f309c4d Mon Sep 17 00:00:00 2001 From: Tagadda <36127788+Tagadda@users.noreply.github.com> Date: Fri, 28 Jan 2022 02:39:20 +0000 Subject: [PATCH 2/2] Hydrate manifest with choices --- src/app.py | 4 ++++ src/utils/config.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/app.py b/src/app.py index 3b6b0a5aa..d7310c0ea 100644 --- a/src/app.py +++ b/src/app.py @@ -57,6 +57,7 @@ from yunohost.utils.config import ( ask_questions_and_parse_answers, DomainQuestion, PathQuestion, + hydrate_questions_with_choices, ) from yunohost.utils.i18n import _value_for_locale from yunohost.utils.error import YunohostError, YunohostValidationError @@ -678,6 +679,9 @@ def app_manifest(app): shutil.rmtree(extracted_app_folder) + raw_questions = manifest.get("arguments", {}).get("install", []) + manifest['arguments']['install'] = hydrate_questions_with_choices(raw_questions) + return manifest diff --git a/src/utils/config.py b/src/utils/config.py index f3b906f00..f44fe5c22 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -1396,3 +1396,15 @@ def ask_questions_and_parse_answers( out.append(question) 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