configpanel: allow other ConfigPanels to have no settings defined

This commit is contained in:
axolotle 2023-10-22 17:51:04 +02:00
parent e7b43c763c
commit 3a31984e3c
2 changed files with 3 additions and 1 deletions

View file

@ -1801,6 +1801,7 @@ class AppConfigPanel(ConfigPanel):
entity_type = "app"
save_path_tpl = os.path.join(APPS_SETTING_PATH, "{entity}/settings.yml")
config_path_tpl = os.path.join(APPS_SETTING_PATH, "{entity}/config_panel.toml")
settings_must_be_defined: bool = True
def _get_raw_settings(self, config: "ConfigPanelModel") -> "RawSettings":
return self._call_config_script("show")

View file

@ -279,6 +279,7 @@ class ConfigPanel:
save_path_tpl: Union[str, None] = None
config_path_tpl = "/usr/share/yunohost/config_{entity_type}.toml"
save_mode = "full"
settings_must_be_defined: bool = False
filter_key: "FilterKey" = (None, None, None)
config: Union[ConfigPanelModel, None] = None
form: Union["FormModel", None] = None
@ -627,7 +628,7 @@ class ConfigPanel:
value = option.default
elif option.type is OptionType.file or option.bind == "null":
continue
else:
elif self.settings_must_be_defined:
raise YunohostError(
f"Config panel question '{option.id}' should be initialized with a value during install or upgrade.",
raw_msg=True,