mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-02 07:47:32 +00:00
Merge pull request #6877 from haiwen/share-link-org-logo
show org logo on share link page
This commit is contained in:
commit
24405a6600
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -416,15 +422,21 @@ def view_shared_upload_link(request, uploadlink):
|
||||
logger.error(e)
|
||||
max_upload_file_size = -1
|
||||
|
||||
return render(request, 'view_shared_upload_link_react.html', {
|
||||
'repo': repo,
|
||||
'path': path,
|
||||
'username': username,
|
||||
'dir_name': dir_name,
|
||||
'max_upload_file_size': max_upload_file_size,
|
||||
'no_quota': no_quota,
|
||||
'uploadlink': uploadlink,
|
||||
'enable_upload_folder': ENABLE_UPLOAD_FOLDER,
|
||||
'enable_resumable_fileupload': ENABLE_RESUMABLE_FILEUPLOAD,
|
||||
'max_number_of_files_for_fileupload': MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD,
|
||||
})
|
||||
data = {
|
||||
'repo': repo,
|
||||
'path': path,
|
||||
'username': username,
|
||||
'dir_name': dir_name,
|
||||
'max_upload_file_size': max_upload_file_size,
|
||||
'no_quota': no_quota,
|
||||
'uploadlink': uploadlink,
|
||||
'enable_upload_folder': ENABLE_UPLOAD_FOLDER,
|
||||
'enable_resumable_fileupload': ENABLE_RESUMABLE_FILEUPLOAD,
|
||||
'max_number_of_files_for_fileupload': MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD,
|
||||
}
|
||||
|
||||
if not request.user.is_authenticated:
|
||||
from seahub.utils import get_logo_path_by_user
|
||||
data['logo_path'] = get_logo_path_by_user(uploadlink.username)
|
||||
|
||||
return render(request, 'view_shared_upload_link_react.html', data)
|
||||
|
Loading…
Reference in New Issue
Block a user