From 163dd4d3594374401e552d56fb93bc8a01e1db7a Mon Sep 17 00:00:00 2001 From: axolotle Date: Thu, 19 Oct 2023 18:28:29 +0200 Subject: [PATCH] domain:config: remove 'portal_logo' for now --- share/config_domain.toml | 10 +++++----- src/domain.py | 33 ++------------------------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/share/config_domain.toml b/share/config_domain.toml index d56a46b8e..e67407eaa 100644 --- a/share/config_domain.toml +++ b/share/config_domain.toml @@ -7,16 +7,16 @@ name = "Features" [feature.portal] name = "Portal" - # [feature.portal.show_other_domains_apps] - # type = "boolean" - # default = false + [feature.portal.show_other_domains_apps] + type = "boolean" + default = false [feature.portal.portal_title] type = "string" default = "YunoHost" - [feature.portal.portal_logo] - type = "file" + # [feature.portal.portal_logo] + # type = "file" [feature.portal.portal_theme] type = "select" diff --git a/src/domain.py b/src/domain.py index 2a583db66..831b6fdc2 100644 --- a/src/domain.py +++ b/src/domain.py @@ -745,12 +745,12 @@ class DomainConfigPanel(ConfigPanel): "default_app", "show_other_domains_apps", "portal_title", - "portal_logo", + # "portal_logo", "portal_theme", ] if any( option in self.future_values - and self.future_values[option] != self.values.get(option) + and self.new_values[option] != self.values.get(option) for option in portal_options ): from yunohost.portal import PORTAL_SETTINGS_DIR @@ -761,35 +761,6 @@ class DomainConfigPanel(ConfigPanel): portal_values = { option: self.future_values[option] for option in portal_options } - if portal_values["portal_logo"].startswith("/tmp/ynh_filequestion_"): - # FIXME rework this whole mess - # currently only handling API sent images, need to adapt FileOption - # to handle file extensions and file saving since "bind" is only - # done in bash helpers which are not executed in domain config - if "portal_logo[name]" in self.args or self.values["portal_logo"]: - import mimetypes - import base64 - - if "portal_logo[name]" in self.args: - # FIXME choose where to save the file - filepath = os.path.join("/tmp", self.args["portal_logo[name]"]) - # move the temp file created by FileOption with proper name and extension - os.rename(self.new_values["portal_logo"], filepath) - mimetype = mimetypes.guess_type(filepath) - else: - # image has already been saved, do not overwrite it with the empty temp file created by the FileOption - filepath = self.values["portal_logo"] - mimetype = mimetypes.guess_type(filepath) - - # save the proper path to config panel settings - self.new_values["portal_logo"] = filepath - # save the base64 content with mimetype to portal settings - with open(filepath, "rb") as f: - portal_values["portal_logo"] = ( - mimetype[0] - + ":" - + base64.b64encode(f.read()).decode("utf-8") - ) portal_settings_path = Path(f"{PORTAL_SETTINGS_DIR}/{self.entity}.json") portal_settings = {"apps": {}}