From a206b5114cb2f20879a9a40302161d85bbc2f3cc Mon Sep 17 00:00:00 2001 From: lian Date: Tue, 24 Oct 2023 14:09:57 +0800 Subject: [PATCH] fix custom org logo bug when enable AVATAR_FILE_STORAGE (#5703) --- frontend/src/components/logo.js | 2 +- .../src/pages/org-admin/web-settings/web-settings.js | 10 ++++++---- seahub/base/context_processors.py | 3 +++ seahub/organizations/api/admin/logo.py | 4 ++++ seahub/organizations/settings.py | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/logo.js b/frontend/src/components/logo.js index e98e497012..ead2ef8ec1 100644 --- a/frontend/src/components/logo.js +++ b/frontend/src/components/logo.js @@ -17,7 +17,7 @@ class Logo extends React.Component { return (
{this.props.showCloseSidePanelIcon && { seafileAPI.orgAdminUpdateLogo(orgID, file).then((res) => { this.setState({ - logoPath: mediaUrl + res.data.logo_path + logoPath: res.data.logo_path }); toaster.success(gettext('Success')); }).catch((error) => { @@ -77,7 +77,9 @@ class OrgWebSettings extends Component { } render() { - const { loading, errorMsg, config_dict, logoPath, file_ext_white_list } = this.state; + const { loading, errorMsg, config_dict, file_ext_white_list } = this.state; + let logoPath = this.state.logoPath; + logoPath = logoPath.indexOf('image-view') != -1 ? logoPath : mediaUrl + logoPath; return ( diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index ba57204374..c41daaab62 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -95,6 +95,9 @@ def base(request): org_logo_url = OrgAdminSettings.objects.get_org_logo_url(org.org_id) if org_logo_url: logo_path = org_logo_url + from seahub.avatar.settings import AVATAR_FILE_STORAGE + if AVATAR_FILE_STORAGE == 'seahub.base.database_storage.DatabaseStorage': + logo_path = "/image-view/" + logo_path # get favicon path custom_favicon_file = os.path.join(MEDIA_ROOT, CUSTOM_FAVICON_PATH) diff --git a/seahub/organizations/api/admin/logo.py b/seahub/organizations/api/admin/logo.py index 752500d4ca..2c8f70b574 100644 --- a/seahub/organizations/api/admin/logo.py +++ b/seahub/organizations/api/admin/logo.py @@ -71,4 +71,8 @@ class OrgAdminLogo(APIView): logger.error(e) return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error') + from seahub.avatar.settings import AVATAR_FILE_STORAGE + if AVATAR_FILE_STORAGE == 'seahub.base.database_storage.DatabaseStorage': + org_logo_url = "/image-view/" + org_logo_url + return Response({'logo_path': org_logo_url}) diff --git a/seahub/organizations/settings.py b/seahub/organizations/settings.py index 35d6e7dc85..bf25fac745 100644 --- a/seahub/organizations/settings.py +++ b/seahub/organizations/settings.py @@ -16,4 +16,4 @@ ORG_AUTO_URL_PREFIX = getattr(settings, 'ORG_AUTO_URL_PREFIX', True) ORG_ENABLE_ADMIN_INVITE_USER = getattr(settings, 'ORG_ENABLE_ADMIN_INVITE_USER', False) ORG_ENABLE_ADMIN_CUSTOM_NAME = getattr(settings, 'ORG_ENABLE_ADMIN_CUSTOM_NAME', True) -ORG_ENABLE_ADMIN_CUSTOM_LOGO = getattr(settings, 'ORG_ENABLE_ADMIN_CUSTOM_LOGO', False) +ORG_ENABLE_ADMIN_CUSTOM_LOGO = getattr(settings, 'ORG_ENABLE_ADMIN_CUSTOM_LOGO', True)