diff --git a/seahub/utils/__init__.py b/seahub/utils/__init__.py index 5dc3e30982..1ab5e5d99e 100644 --- a/seahub/utils/__init__.py +++ b/seahub/utils/__init__.py @@ -1457,3 +1457,33 @@ ASCII_RE = re.compile(r'[^\x00-\x7f]') def is_valid_password(password): return False if ASCII_RE.search(password) else True + + +def get_logo_path_by_user(username): + + logo_path = LOGO_PATH + + # custom logo + custom_logo_file = os.path.join(MEDIA_ROOT, CUSTOM_LOGO_PATH) + if os.path.exists(custom_logo_file): + logo_path = CUSTOM_LOGO_PATH + + # org custom logo + orgs = ccnet_api.get_orgs_by_user(username) + if orgs: + + from seahub.organizations.settings import ORG_ENABLE_ADMIN_CUSTOM_LOGO + if ORG_ENABLE_ADMIN_CUSTOM_LOGO: + + org = orgs[0] + from seahub.organizations.models import OrgAdminSettings + 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 + + return logo_path diff --git a/seahub/views/file.py b/seahub/views/file.py index 8dfb520234..7e0003fffc 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -1326,7 +1326,6 @@ def view_shared_file(request, fileshare): permissions = fileshare.get_permissions() - #template = 'shared_file_view.html' template = 'shared_file_view_react.html' file_share_link = request.path @@ -1367,8 +1366,13 @@ def view_shared_file(request, fileshare): data['can_edit_file'] = ret_dict['can_edit_file'] data['file_perm'] = ret_dict['file_perm'] + if not request.user.is_authenticated: + from seahub.utils import get_logo_path_by_user + data['logo_path'] = get_logo_path_by_user(shared_by) + return render(request, template, data) + @share_link_audit @share_link_login_required def view_file_via_shared_dir(request, fileshare): @@ -1626,6 +1630,10 @@ def view_file_via_shared_dir(request, fileshare): data['can_edit_file'] = ret_dict['can_edit_file'] data['file_perm'] = ret_dict['file_perm'] + if not request.user.is_authenticated: + from seahub.utils import get_logo_path_by_user + data['logo_path'] = get_logo_path_by_user(shared_by) + return render(request, template, data) @login_required diff --git a/seahub/views/repo.py b/seahub/views/repo.py index 27972ba96e..9fca203a2e 100644 --- a/seahub/views/repo.py +++ b/seahub/views/repo.py @@ -349,28 +349,34 @@ def view_shared_dir(request, fileshare): dir_share_link = request.path desc_for_ogp = _('Share link for %s.') % dir_name - return render(request, template, { - 'repo': repo, - 'token': token, - 'path': req_path, - 'username': username, - 'dir_name': dir_name, - 'dir_path': real_path, - 'file_list': file_list, - 'dir_list': dir_list, - 'zipped': zipped, - 'traffic_over_limit': False, - 'max_upload_file_size': max_upload_file_size, - 'no_quota': no_quota, - 'permissions': permissions, - 'mode': mode, - 'thumbnail_size': thumbnail_size, - 'dir_share_link': dir_share_link, - 'desc_for_ogp': desc_for_ogp, - 'enable_share_link_report_abuse': ENABLE_SHARE_LINK_REPORT_ABUSE, - 'enable_video_thumbnail': ENABLE_VIDEO_THUMBNAIL, - 'enable_pdf_thumbnail': ENABLE_PDF_THUMBNAIL, - }) + data = { + 'repo': repo, + 'token': token, + 'path': req_path, + 'username': username, + 'dir_name': dir_name, + 'dir_path': real_path, + 'file_list': file_list, + 'dir_list': dir_list, + 'zipped': zipped, + 'traffic_over_limit': False, + 'max_upload_file_size': max_upload_file_size, + 'no_quota': no_quota, + 'permissions': permissions, + 'mode': mode, + 'thumbnail_size': thumbnail_size, + 'dir_share_link': dir_share_link, + 'desc_for_ogp': desc_for_ogp, + 'enable_share_link_report_abuse': ENABLE_SHARE_LINK_REPORT_ABUSE, + 'enable_video_thumbnail': ENABLE_VIDEO_THUMBNAIL, + 'enable_pdf_thumbnail': ENABLE_PDF_THUMBNAIL, + } + + if not request.user.is_authenticated: + from seahub.utils import get_logo_path_by_user + data['logo_path'] = get_logo_path_by_user(fileshare.username) + + return render(request, template, data) @share_link_audit