diff --git a/frontend/src/components/logo.js b/frontend/src/components/logo.js index d6d45274da..b5183c8934 100644 --- a/frontend/src/components/logo.js +++ b/frontend/src/components/logo.js @@ -17,7 +17,7 @@ class Logo extends React.Component { return (
{this.props.showCloseSidePanelIcon && { 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) => { @@ -76,7 +76,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 ( diff --git a/seahub/api2/endpoints/custom_share_permissions.py b/seahub/api2/endpoints/custom_share_permissions.py index abdd44173b..cf259fd401 100644 --- a/seahub/api2/endpoints/custom_share_permissions.py +++ b/seahub/api2/endpoints/custom_share_permissions.py @@ -30,7 +30,8 @@ class CustomSharePermissionsView(APIView): """ # permission check 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 repo = seafile_api.get_repo(repo_id) @@ -66,7 +67,8 @@ class CustomSharePermissionsView(APIView): # permission check 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 repo = seafile_api.get_repo(repo_id) @@ -97,7 +99,8 @@ class CustomSharePermissionView(APIView): """ # permission check 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 repo = seafile_api.get_repo(repo_id) @@ -118,21 +121,24 @@ class CustomSharePermissionView(APIView): def put(self, request, repo_id, permission_id): """Update a custom share permission """ - username = request.user.username # argument check permission = request.data.get('permission', None) if not permission: error_msg = 'permission invalid.' return api_error(status.HTTP_400_BAD_REQUEST, error_msg) + permission_name = request.data.get('permission_name', None) if not permission_name: error_msg = 'permission_name invalid.' return api_error(status.HTTP_400_BAD_REQUEST, error_msg) + description = request.data.get('description', '') # permission check + username = request.user.username 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 repo = seafile_api.get_repo(repo_id) @@ -140,17 +146,15 @@ class CustomSharePermissionView(APIView): error_msg = 'Library %s not found.' % repo_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) - try: - permission_obj = CustomSharePermissions.objects.get(id=permission_id) - if not permission_obj: - return api_error(status.HTTP_404_NOT_FOUND, 'Permission %s not found.' % permission_id) - except Exception as e: - logger.error(e) - error_msg = 'Internal Server Error' - return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) + permission_objs = CustomSharePermissions.objects.filter(repo_id=repo_id) \ + .filter(id=permission_id) + if not permission_objs: + error_msg = f'Permission {permission_id} not found in library {repo_id}.' + return api_error(status.HTTP_404_NOT_FOUND, error_msg) # main try: + permission_obj = permission_objs[0] permission_obj.name = permission_name permission_obj.description = description permission_obj.permission = permission @@ -170,7 +174,8 @@ class CustomSharePermissionView(APIView): # permission check 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 repo = seafile_api.get_repo(repo_id) diff --git a/seahub/api2/endpoints/group_libraries.py b/seahub/api2/endpoints/group_libraries.py index 3f72e759b1..44e725bcf5 100644 --- a/seahub/api2/endpoints/group_libraries.py +++ b/seahub/api2/endpoints/group_libraries.py @@ -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.signals import share_repo_to_group_successful 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.base.models import UserStarredFiles, UserMonitoredRepos from seahub.base.templatetags.seahub_tags import email2nickname, \ @@ -191,10 +191,8 @@ class GroupLibraries(APIView): permission = request.data.get('permission', PERMISSION_READ) if permission not in get_available_repo_perms(): - permission = normalize_custom_permission_name(permission) - if not permission: - error_msg = 'permission invalid.' - return api_error(status.HTTP_400_BAD_REQUEST, error_msg) + error_msg = 'permission invalid.' + return api_error(status.HTTP_400_BAD_REQUEST, error_msg) # permission check if not request.user.permissions.can_add_repo(): @@ -214,32 +212,33 @@ class GroupLibraries(APIView): if is_org_context(request): is_org = True org_id = request.user.org.org_id - repo_id = seafile_api.create_org_repo(repo_name, - '', username, org_id, password, enc_version=settings.ENCRYPTED_LIBRARY_VERSION) + repo_id = seafile_api.create_org_repo(repo_name, '', username, org_id, password, + enc_version=settings.ENCRYPTED_LIBRARY_VERSION) else: - repo_id = seafile_api.create_repo(repo_name, - '', username, password, enc_version=settings.ENCRYPTED_LIBRARY_VERSION) + repo_id = seafile_api.create_repo(repo_name, '', username, password, + enc_version=settings.ENCRYPTED_LIBRARY_VERSION) repo = seafile_api.get_repo(repo_id) share_dir_to_group(repo, '/', username, username, group_id, - permission, org_id if is_org else None) + permission, org_id if is_org else None) # for activities library_template = request.data.get("library_template", '') repo_created.send(sender=None, org_id=org_id, creator=username, - repo_id=repo_id, repo_name=repo_name, - library_template=library_template) + repo_id=repo_id, repo_name=repo_name, + library_template=library_template) # for notification 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 - send_perm_audit_msg('add-repo-perm', username, group_id, - repo_id, '/', permission) + send_perm_audit_msg('add-repo-perm', username, + group_id, repo_id, '/', permission) - group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, - None, group_id, is_org) + group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, None, + group_id, is_org) group_repo_info = get_group_repo_info(request, group_repo) group_repo_info['owner_email'] = username @@ -280,8 +279,8 @@ class GroupLibrary(APIView): if is_org_context(request): is_org = True - group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, - None, group_id, is_org) + group_repo = seafile_api.get_group_shared_repo_by_path(repo_id, None, + group_id, is_org) if not group_repo: error_msg = 'Group library %s not found.' % repo_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) @@ -307,7 +306,7 @@ class GroupLibrary(APIView): origin_repo_id = group_repo.origin_repo_id or repo_id origin_path = group_repo.origin_path or '/' send_perm_audit_msg('delete-repo-perm', username, group_id, - origin_repo_id, origin_path, permission) + origin_repo_id, origin_path, permission) # delete extra share permission ExtraGroupsSharePermission.objects.delete_share_permission(repo_id, group_id) diff --git a/seahub/api2/endpoints/group_members.py b/seahub/api2/endpoints/group_members.py index 5c1976f9f6..904cb1b4e9 100644 --- a/seahub/api2/endpoints/group_members.py +++ b/seahub/api2/endpoints/group_members.py @@ -458,6 +458,8 @@ class GroupMembersImport(APIView): for email in emails_list: + email_from_excel = email + user_not_found = False try: @@ -473,15 +475,15 @@ class GroupMembersImport(APIView): except User.DoesNotExist: user_not_found = True - email_name = email2nickname(email) if user_not_found: result['failed'].append({ - 'email': email, - 'email_name': email_name, - 'error_msg': 'User %s not found.' % email_name + 'email': email_from_excel, + 'email_name': email2nickname(email_from_excel), + 'error_msg': 'User %s not found.' % email2nickname(email_from_excel) }) continue + email_name = email2nickname(email) if is_group_member(group_id, email, in_structure=False): result['failed'].append({ 'email': email, diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index 8525819684..04e3203b0d 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -97,6 +97,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) diff --git a/seahub/base/management/commands/clear_invalid_repo_data.py b/seahub/base/management/commands/clear_invalid_repo_data.py index 62e4219d98..c8dc9774a4 100644 --- a/seahub/base/management/commands/clear_invalid_repo_data.py +++ b/seahub/base/management/commands/clear_invalid_repo_data.py @@ -83,7 +83,7 @@ class Command(BaseCommand): return for repo_id, *_ in res: - repo_ids.append(repo_ids) + repo_ids.append(repo_id) if repo_id not in all_repo_ids: invalid_repo_ids.append(repo_id) diff --git a/seahub/organizations/api/admin/logo.py b/seahub/organizations/api/admin/logo.py index 5ba52c2a5f..e375440436 100644 --- a/seahub/organizations/api/admin/logo.py +++ b/seahub/organizations/api/admin/logo.py @@ -71,4 +71,8 @@ class OrgAdminLogo(APIView): 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}) diff --git a/seahub/organizations/settings.py b/seahub/organizations/settings.py index 35d6e7dc85..bf25fac745 100644 --- a/seahub/organizations/settings.py +++ b/seahub/organizations/settings.py @@ -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_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) diff --git a/seahub/share/templates/share/share_link_audit.html b/seahub/share/templates/share/share_link_audit.html index f06aae27e0..edf6d4e0ed 100644 --- a/seahub/share/templates/share/share_link_audit.html +++ b/seahub/share/templates/share/share_link_audit.html @@ -60,7 +60,7 @@ $('#get-code').on('click', function() { email: email }, 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) { var error_msg = prepareAjaxErrorMsg(xhr);