1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-18 06:57:52 +00:00

Merge branch '10.0'

This commit is contained in:
lian 2023-11-10 11:04:10 +08:00
commit b9884eaff7
10 changed files with 60 additions and 45 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

@ -19,7 +19,7 @@ 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: '',
}; };
} }
@ -54,7 +54,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) => {
@ -76,7 +76,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

@ -30,7 +30,8 @@ class CustomSharePermissionsView(APIView):
""" """
# permission check # permission check
if not check_folder_permission(request, repo_id, '/'): if not check_folder_permission(request, repo_id, '/'):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# resource check # resource check
repo = seafile_api.get_repo(repo_id) repo = seafile_api.get_repo(repo_id)
@ -66,7 +67,8 @@ class CustomSharePermissionsView(APIView):
# permission check # permission check
if not is_repo_admin(username, repo_id): if not is_repo_admin(username, repo_id):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# resource check # resource check
repo = seafile_api.get_repo(repo_id) repo = seafile_api.get_repo(repo_id)
@ -97,7 +99,8 @@ class CustomSharePermissionView(APIView):
""" """
# permission check # permission check
if not check_folder_permission(request, repo_id, '/'): if not check_folder_permission(request, repo_id, '/'):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# resource check # resource check
repo = seafile_api.get_repo(repo_id) repo = seafile_api.get_repo(repo_id)
@ -118,21 +121,24 @@ class CustomSharePermissionView(APIView):
def put(self, request, repo_id, permission_id): def put(self, request, repo_id, permission_id):
"""Update a custom share permission """Update a custom share permission
""" """
username = request.user.username
# argument check # argument check
permission = request.data.get('permission', None) permission = request.data.get('permission', None)
if not permission: if not permission:
error_msg = 'permission invalid.' error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg) return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
permission_name = request.data.get('permission_name', None) permission_name = request.data.get('permission_name', None)
if not permission_name: if not permission_name:
error_msg = 'permission_name invalid.' error_msg = 'permission_name invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg) return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
description = request.data.get('description', '') description = request.data.get('description', '')
# permission check # permission check
username = request.user.username
if not is_repo_admin(username, repo_id): if not is_repo_admin(username, repo_id):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# resource check # resource check
repo = seafile_api.get_repo(repo_id) repo = seafile_api.get_repo(repo_id)
@ -140,17 +146,15 @@ class CustomSharePermissionView(APIView):
error_msg = 'Library %s not found.' % repo_id error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg) return api_error(status.HTTP_404_NOT_FOUND, error_msg)
try: permission_objs = CustomSharePermissions.objects.filter(repo_id=repo_id) \
permission_obj = CustomSharePermissions.objects.get(id=permission_id) .filter(id=permission_id)
if not permission_obj: if not permission_objs:
return api_error(status.HTTP_404_NOT_FOUND, 'Permission %s not found.' % permission_id) error_msg = f'Permission {permission_id} not found in library {repo_id}.'
except Exception as e: return api_error(status.HTTP_404_NOT_FOUND, error_msg)
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
# main # main
try: try:
permission_obj = permission_objs[0]
permission_obj.name = permission_name permission_obj.name = permission_name
permission_obj.description = description permission_obj.description = description
permission_obj.permission = permission permission_obj.permission = permission
@ -170,7 +174,8 @@ class CustomSharePermissionView(APIView):
# permission check # permission check
if not is_repo_admin(username, repo_id): if not is_repo_admin(username, repo_id):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# resource check # resource check
repo = seafile_api.get_repo(repo_id) repo = seafile_api.get_repo(repo_id)

View File

@ -28,7 +28,7 @@ from seahub.utils.repo import get_repo_owner, get_available_repo_perms
from seahub.share.models import ExtraGroupsSharePermission from seahub.share.models import ExtraGroupsSharePermission
from seahub.share.signals import share_repo_to_group_successful from seahub.share.signals import share_repo_to_group_successful
from seahub.share.utils import is_repo_admin, check_group_share_in_permission, \ from seahub.share.utils import is_repo_admin, check_group_share_in_permission, \
share_dir_to_group, normalize_custom_permission_name share_dir_to_group
from seahub.constants import PERMISSION_READ from seahub.constants import PERMISSION_READ
from seahub.base.models import UserStarredFiles, UserMonitoredRepos from seahub.base.models import UserStarredFiles, UserMonitoredRepos
from seahub.base.templatetags.seahub_tags import email2nickname, \ from seahub.base.templatetags.seahub_tags import email2nickname, \
@ -191,8 +191,6 @@ class GroupLibraries(APIView):
permission = request.data.get('permission', PERMISSION_READ) permission = request.data.get('permission', PERMISSION_READ)
if permission not in get_available_repo_perms(): if permission not in get_available_repo_perms():
permission = normalize_custom_permission_name(permission)
if not permission:
error_msg = 'permission invalid.' error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg) return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
@ -214,11 +212,11 @@ class GroupLibraries(APIView):
if is_org_context(request): if is_org_context(request):
is_org = True is_org = True
org_id = request.user.org.org_id org_id = request.user.org.org_id
repo_id = seafile_api.create_org_repo(repo_name, repo_id = seafile_api.create_org_repo(repo_name, '', username, org_id, password,
'', username, org_id, password, enc_version=settings.ENCRYPTED_LIBRARY_VERSION) enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else: else:
repo_id = seafile_api.create_repo(repo_name, repo_id = seafile_api.create_repo(repo_name, '', username, password,
'', username, password, enc_version=settings.ENCRYPTED_LIBRARY_VERSION) enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
repo = seafile_api.get_repo(repo_id) repo = seafile_api.get_repo(repo_id)
share_dir_to_group(repo, '/', username, username, group_id, share_dir_to_group(repo, '/', username, username, group_id,
@ -232,14 +230,15 @@ class GroupLibraries(APIView):
# for notification # for notification
share_repo_to_group_successful.send(sender=None, from_user=username, share_repo_to_group_successful.send(sender=None, from_user=username,
group_id=group_id, repo=repo, path='/', org_id=org_id) group_id=group_id, repo=repo,
path='/', org_id=org_id)
# for perm audit # for perm audit
send_perm_audit_msg('add-repo-perm', username, group_id, send_perm_audit_msg('add-repo-perm', username,
repo_id, '/', permission) group_id, repo_id, '/', permission)
group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, None,
None, group_id, is_org) group_id, is_org)
group_repo_info = get_group_repo_info(request, group_repo) group_repo_info = get_group_repo_info(request, group_repo)
group_repo_info['owner_email'] = username group_repo_info['owner_email'] = username
@ -280,8 +279,8 @@ class GroupLibrary(APIView):
if is_org_context(request): if is_org_context(request):
is_org = True is_org = True
group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, None,
None, group_id, is_org) group_id, is_org)
if not group_repo: if not group_repo:
error_msg = 'Group library %s not found.' % repo_id error_msg = 'Group library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg) return api_error(status.HTTP_404_NOT_FOUND, error_msg)

View File

@ -458,6 +458,8 @@ class GroupMembersImport(APIView):
for email in emails_list: for email in emails_list:
email_from_excel = email
user_not_found = False user_not_found = False
try: try:
@ -473,15 +475,15 @@ class GroupMembersImport(APIView):
except User.DoesNotExist: except User.DoesNotExist:
user_not_found = True user_not_found = True
email_name = email2nickname(email)
if user_not_found: if user_not_found:
result['failed'].append({ result['failed'].append({
'email': email, 'email': email_from_excel,
'email_name': email_name, 'email_name': email2nickname(email_from_excel),
'error_msg': 'User %s not found.' % email_name 'error_msg': 'User %s not found.' % email2nickname(email_from_excel)
}) })
continue continue
email_name = email2nickname(email)
if is_group_member(group_id, email, in_structure=False): if is_group_member(group_id, email, in_structure=False):
result['failed'].append({ result['failed'].append({
'email': email, 'email': email,

View File

@ -97,6 +97,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

@ -83,7 +83,7 @@ class Command(BaseCommand):
return return
for repo_id, *_ in res: for repo_id, *_ in res:
repo_ids.append(repo_ids) repo_ids.append(repo_id)
if repo_id not in all_repo_ids: if repo_id not in all_repo_ids:
invalid_repo_ids.append(repo_id) invalid_repo_ids.append(repo_id)

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)

View File

@ -60,7 +60,7 @@ $('#get-code').on('click', function() {
email: email email: email
}, },
success: function() { success: function() {
feedback('{% trans "A verification code has been sent to the email." %}', 'success'); feedback("{% trans "A verification code has been sent to the email." %}", 'success');
}, },
error: function(xhr) { error: function(xhr) {
var error_msg = prepareAjaxErrorMsg(xhr); var error_msg = prepareAjaxErrorMsg(xhr);