1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 18:29:23 +00:00

fix custom org logo bug when enable AVATAR_FILE_STORAGE (#5703)

This commit is contained in:
lian
2023-10-24 14:09:57 +08:00
committed by GitHub
parent 2a82e10c6f
commit a206b5114c
5 changed files with 15 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ class Logo extends React.Component {
return ( return (
<div className="top-logo"> <div className="top-logo">
<a href={siteRoot} id="logo"> <a href={siteRoot} id="logo">
<img src={mediaUrl + logoPath} height={logoHeight} width={logoWidth} title={siteTitle} alt="logo" /> <img src={logoPath.indexOf('image-view') != -1 ? logoPath : mediaUrl + logoPath} height={logoHeight} width={logoWidth} title={siteTitle} alt="logo" />
</a> </a>
{this.props.showCloseSidePanelIcon && {this.props.showCloseSidePanelIcon &&
<a <a

View File

@@ -20,8 +20,8 @@ class OrgWebSettings extends Component {
loading: true, loading: true,
errorMsg: '', errorMsg: '',
config_dict: null, config_dict: null,
logoPath: mediaUrl + logoPath, logoPath: logoPath,
file_ext_white_list: '', file_ext_white_list: '',
}; };
} }
@@ -55,7 +55,7 @@ class OrgWebSettings extends Component {
updateLogo = (file) => { updateLogo = (file) => {
seafileAPI.orgAdminUpdateLogo(orgID, file).then((res) => { seafileAPI.orgAdminUpdateLogo(orgID, file).then((res) => {
this.setState({ this.setState({
logoPath: mediaUrl + res.data.logo_path logoPath: res.data.logo_path
}); });
toaster.success(gettext('Success')); toaster.success(gettext('Success'));
}).catch((error) => { }).catch((error) => {
@@ -77,7 +77,9 @@ class OrgWebSettings extends Component {
} }
render() { 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 ( return (
<Fragment> <Fragment>
<MainPanelTopbar {...this.props} /> <MainPanelTopbar {...this.props} />

View File

@@ -95,6 +95,9 @@ def base(request):
org_logo_url = OrgAdminSettings.objects.get_org_logo_url(org.org_id) org_logo_url = OrgAdminSettings.objects.get_org_logo_url(org.org_id)
if org_logo_url: if org_logo_url:
logo_path = 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 # get favicon path
custom_favicon_file = os.path.join(MEDIA_ROOT, CUSTOM_FAVICON_PATH) custom_favicon_file = os.path.join(MEDIA_ROOT, CUSTOM_FAVICON_PATH)

View File

@@ -71,4 +71,8 @@ class OrgAdminLogo(APIView):
logger.error(e) logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error') 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}) return Response({'logo_path': org_logo_url})

View File

@@ -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_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_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)