mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 00:43:53 +00:00
update share dept repo
add 'cloud-edit', 'preview' permission support 'cloud-edit', 'preview' and custom permission when modify share
This commit is contained in:
@@ -124,9 +124,12 @@ class ShareToGroup extends React.Component {
|
||||
} else if (itemType === 'dir') {
|
||||
this.permissions = ['rw', 'r', 'cloud-edit', 'preview'];
|
||||
}
|
||||
if (this.props.isGroupOwnedRepo || !isPro) {
|
||||
if (!isPro) {
|
||||
this.permissions = ['rw', 'r'];
|
||||
}
|
||||
if (this.props.isGroupOwnedRepo) {
|
||||
this.permissions = ['rw', 'r', 'cloud-edit', 'preview'];
|
||||
}
|
||||
}
|
||||
|
||||
handleSelectChange = (option) => {
|
||||
|
@@ -154,9 +154,12 @@ class ShareToUser extends React.Component {
|
||||
} else if (this.props.itemType === 'dir') {
|
||||
this.permissions = ['rw', 'r', 'cloud-edit', 'preview'];
|
||||
}
|
||||
if (this.props.isGroupOwnedRepo || !isPro) {
|
||||
if (!isPro) {
|
||||
this.permissions = ['rw', 'r'];
|
||||
}
|
||||
if (this.props.isGroupOwnedRepo) {
|
||||
this.permissions = ['rw', 'r', 'cloud-edit', 'preview'];
|
||||
}
|
||||
}
|
||||
|
||||
handleSelectChange = (option) => {
|
||||
|
@@ -39,7 +39,8 @@ from seahub.share.utils import share_dir_to_user, share_dir_to_group, update_use
|
||||
check_user_share_out_permission, update_group_dir_permission, \
|
||||
check_group_share_out_permission, check_user_share_in_permission, \
|
||||
normalize_custom_permission_name
|
||||
from seahub.constants import PERMISSION_READ, PERMISSION_READ_WRITE
|
||||
from seahub.constants import PERMISSION_READ, PERMISSION_READ_WRITE, \
|
||||
PERMISSION_PREVIEW, PERMISSION_PREVIEW_EDIT
|
||||
from seahub.views import check_folder_permission
|
||||
|
||||
from seahub.settings import ENABLE_STORAGE_CLASSES, STORAGE_CLASS_MAPPING_POLICY, \
|
||||
@@ -47,6 +48,7 @@ from seahub.settings import ENABLE_STORAGE_CLASSES, STORAGE_CLASS_MAPPING_POLICY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_group_owned_repo_info(request, repo_id):
|
||||
|
||||
repo = seafile_api.get_repo(repo_id)
|
||||
@@ -72,6 +74,7 @@ def get_group_owned_repo_info(request, repo_id):
|
||||
|
||||
return repo_info
|
||||
|
||||
|
||||
class GroupOwnedLibraries(APIView):
|
||||
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
||||
permission_classes = (IsAuthenticated, IsProVersion)
|
||||
@@ -123,8 +126,7 @@ class GroupOwnedLibraries(APIView):
|
||||
group_id = int(group_id)
|
||||
if is_pro_version() and ENABLE_STORAGE_CLASSES:
|
||||
|
||||
if STORAGE_CLASS_MAPPING_POLICY in ('USER_SELECT',
|
||||
'ROLE_BASED'):
|
||||
if STORAGE_CLASS_MAPPING_POLICY in ('USER_SELECT', 'ROLE_BASED'):
|
||||
|
||||
storages = get_library_storages(request)
|
||||
storage_id = request.data.get("storage_id", None)
|
||||
@@ -132,8 +134,11 @@ class GroupOwnedLibraries(APIView):
|
||||
error_msg = 'storage_id invalid.'
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
repo_id = seafile_api.add_group_owned_repo(group_id, repo_name,
|
||||
permission, password, enc_version=ENCRYPTED_LIBRARY_VERSION,
|
||||
repo_id = seafile_api.add_group_owned_repo(group_id,
|
||||
repo_name,
|
||||
permission,
|
||||
password,
|
||||
enc_version=ENCRYPTED_LIBRARY_VERSION,
|
||||
storage_id=storage_id)
|
||||
else:
|
||||
# STORAGE_CLASS_MAPPING_POLICY == 'REPO_ID_MAPPING'
|
||||
@@ -153,13 +158,15 @@ class GroupOwnedLibraries(APIView):
|
||||
# for notification
|
||||
repo = seafile_api.get_repo(repo_id)
|
||||
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)
|
||||
|
||||
info = get_group_owned_repo_info(request, repo_id)
|
||||
# TODO
|
||||
info['permission'] = permission
|
||||
return Response(info)
|
||||
|
||||
|
||||
class GroupOwnedLibrary(APIView):
|
||||
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
||||
permission_classes = (IsAuthenticated, IsProVersion)
|
||||
@@ -241,6 +248,7 @@ def get_group_id_by_repo_owner(repo_owner):
|
||||
|
||||
return int(repo_owner.split('@')[0])
|
||||
|
||||
|
||||
class GroupOwnedLibraryUserFolderPermission(APIView):
|
||||
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
||||
permission_classes = (IsAuthenticated, IsProVersion)
|
||||
@@ -885,7 +893,8 @@ class GroupOwnedLibraryUserShare(APIView):
|
||||
|
||||
# parameter check
|
||||
permission = request.data.get('permission', PERMISSION_READ)
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE]:
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE,
|
||||
PERMISSION_PREVIEW, PERMISSION_PREVIEW_EDIT]:
|
||||
permission = normalize_custom_permission_name(permission)
|
||||
if not permission:
|
||||
error_msg = 'permission invalid.'
|
||||
@@ -980,7 +989,8 @@ class GroupOwnedLibraryUserShare(APIView):
|
||||
repo=repo, path=path, org_id=org_id)
|
||||
|
||||
send_perm_audit_msg('add-repo-perm',
|
||||
username, to_user, repo_id, path, permission)
|
||||
username, to_user,
|
||||
repo_id, path, permission)
|
||||
|
||||
return Response(result)
|
||||
|
||||
@@ -1003,7 +1013,10 @@ class GroupOwnedLibraryUserShare(APIView):
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
permission = request.data.get('permission', PERMISSION_READ)
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE]:
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE,
|
||||
PERMISSION_PREVIEW, PERMISSION_PREVIEW_EDIT]:
|
||||
permission = normalize_custom_permission_name(permission)
|
||||
if not permission:
|
||||
error_msg = 'permission invalid.'
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
@@ -1158,7 +1171,10 @@ class GroupOwnedLibraryGroupShare(APIView):
|
||||
|
||||
# parameter check
|
||||
permission = request.data.get('permission', PERMISSION_READ)
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE]:
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE,
|
||||
PERMISSION_PREVIEW, PERMISSION_PREVIEW_EDIT]:
|
||||
permission = normalize_custom_permission_name(permission)
|
||||
if not permission:
|
||||
error_msg = 'permission invalid.'
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
@@ -1221,7 +1237,10 @@ class GroupOwnedLibraryGroupShare(APIView):
|
||||
})
|
||||
|
||||
share_repo_to_group_successful.send(sender=None,
|
||||
from_user=username, group_id=gid, repo=repo, path=path,
|
||||
from_user=username,
|
||||
group_id=gid,
|
||||
repo=repo,
|
||||
path=path,
|
||||
org_id=org_id)
|
||||
|
||||
send_perm_audit_msg('add-repo-perm', username, gid,
|
||||
@@ -1250,7 +1269,10 @@ class GroupOwnedLibraryGroupShare(APIView):
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
permission = request.data.get('permission', PERMISSION_READ)
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE]:
|
||||
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE,
|
||||
PERMISSION_PREVIEW, PERMISSION_PREVIEW_EDIT]:
|
||||
permission = normalize_custom_permission_name(permission)
|
||||
if not permission:
|
||||
error_msg = 'permission invalid.'
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
@@ -1285,7 +1307,8 @@ class GroupOwnedLibraryGroupShare(APIView):
|
||||
repo_id, path, repo_owner, to_group_id, permission, org_id)
|
||||
|
||||
send_perm_audit_msg('modify-repo-perm',
|
||||
username, to_group_id, repo_id, path, permission)
|
||||
username, to_group_id,
|
||||
repo_id, path, permission)
|
||||
|
||||
return Response({'success': True})
|
||||
|
||||
|
Reference in New Issue
Block a user