mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-01 23:38:37 +00:00
Merge branch '10.0'
This commit is contained in:
commit
b9884eaff7
@ -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
|
||||
|
@ -19,7 +19,7 @@ class OrgWebSettings extends Component {
|
||||
loading: true,
|
||||
errorMsg: '',
|
||||
config_dict: null,
|
||||
logoPath: mediaUrl + logoPath,
|
||||
logoPath: logoPath,
|
||||
file_ext_white_list: '',
|
||||
};
|
||||
}
|
||||
@ -54,7 +54,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) => {
|
||||
@ -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 (
|
||||
<Fragment>
|
||||
<MainPanelTopbar {...this.props} />
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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})
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user