Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix custom org logo bug when enable AVATAR_FILE_STORAGE #5703

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Logo extends React.Component {
return (
<div className="top-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>
{this.props.showCloseSidePanelIcon &&
<a
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/pages/org-admin/web-settings/web-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class OrgWebSettings extends Component {
loading: true,
errorMsg: '',
config_dict: null,
logoPath: mediaUrl + logoPath,
file_ext_white_list: '',
logoPath: logoPath,
file_ext_white_list: '',
};
}

Expand Down Expand Up @@ -55,7 +55,7 @@ class OrgWebSettings extends Component {
updateLogo = (file) => {
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) => {
Expand All @@ -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 (
<Fragment>
<MainPanelTopbar {...this.props} />
Expand Down
3 changes: 3 additions & 0 deletions seahub/base/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions seahub/organizations/api/admin/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ def post(self, request, org_id):
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})
2 changes: 1 addition & 1 deletion seahub/organizations/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
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)
Loading