mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-22 16:56:57 +00:00
update api of shared with me (#2383)
* update api of shared with me return 'group_name' field if current library is a group owned library * add api for delete shared in group owned repo
This commit is contained in:
parent
577e814ae7
commit
c51da1c832
@ -35,8 +35,9 @@ from seahub.utils.rpc import SeafileAPI
|
|||||||
from seahub.share.signals import share_repo_to_user_successful, share_repo_to_group_successful
|
from seahub.share.signals import share_repo_to_user_successful, share_repo_to_group_successful
|
||||||
from seahub.share.utils import share_dir_to_user, share_dir_to_group, update_user_dir_permission, \
|
from seahub.share.utils import share_dir_to_user, share_dir_to_group, update_user_dir_permission, \
|
||||||
check_user_share_out_permission, update_group_dir_permission, \
|
check_user_share_out_permission, update_group_dir_permission, \
|
||||||
check_group_share_out_permission
|
check_group_share_out_permission, check_user_share_in_permission
|
||||||
from seahub.constants import PERMISSION_READ, PERMISSION_READ_WRITE
|
from seahub.constants import PERMISSION_READ, PERMISSION_READ_WRITE
|
||||||
|
from seahub.views import check_folder_permission
|
||||||
|
|
||||||
from seahub.settings import ENABLE_STORAGE_CLASSES, STORAGE_CLASS_MAPPING_POLICY
|
from seahub.settings import ENABLE_STORAGE_CLASSES, STORAGE_CLASS_MAPPING_POLICY
|
||||||
|
|
||||||
@ -1313,3 +1314,43 @@ class GroupOwnedLibraryGroupShare(APIView):
|
|||||||
repo_id, path, permission)
|
repo_id, path, permission)
|
||||||
|
|
||||||
return Response({'success': True})
|
return Response({'success': True})
|
||||||
|
|
||||||
|
|
||||||
|
class GroupOwnedLibraryUserShareInLibrary(APIView):
|
||||||
|
|
||||||
|
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
||||||
|
permission_classes = (IsAuthenticated, IsProVersion)
|
||||||
|
throttle_classes = (UserRateThrottle,)
|
||||||
|
|
||||||
|
@add_org_context
|
||||||
|
def delete(self, request, repo_id, org_id, format=None):
|
||||||
|
""" User delete a repo shared to him/her.
|
||||||
|
"""
|
||||||
|
repo = seafile_api.get_repo(repo_id)
|
||||||
|
if not repo:
|
||||||
|
error_msg = 'Library %s not found.' % repo_id
|
||||||
|
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
|
||||||
|
|
||||||
|
if not check_folder_permission(request, repo_id, '/'):
|
||||||
|
error_msg = 'Permission denied.'
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||||
|
|
||||||
|
username = request.user.username
|
||||||
|
repo_owner = get_repo_owner(request, repo_id)
|
||||||
|
try:
|
||||||
|
if org_id:
|
||||||
|
is_org = True
|
||||||
|
seafile_api.org_remove_share(org_id, repo_id, repo_owner, username)
|
||||||
|
else:
|
||||||
|
is_org = False
|
||||||
|
seafile_api.remove_share(repo_id, repo_owner, username)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
error_msg = 'Internal Server Error'
|
||||||
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
|
permission = check_user_share_in_permission(repo_id, username, is_org)
|
||||||
|
send_perm_audit_msg('delete-repo-perm', repo_owner, username,
|
||||||
|
repo_id, '/', permission)
|
||||||
|
|
||||||
|
return Response({'success': True})
|
||||||
|
@ -704,6 +704,11 @@ class Repos(APIView):
|
|||||||
if q and q.lower() not in r.name.lower():
|
if q and q.lower() not in r.name.lower():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
library_group_name = ''
|
||||||
|
if '@seafile_group' in r.user:
|
||||||
|
library_group_id = get_group_id_by_repo_owner(r.user)
|
||||||
|
library_group_name= group_id_to_name(library_group_id)
|
||||||
|
|
||||||
r.password_need = is_passwd_set(r.repo_id, email)
|
r.password_need = is_passwd_set(r.repo_id, email)
|
||||||
repo = {
|
repo = {
|
||||||
"type": "srepo",
|
"type": "srepo",
|
||||||
@ -726,6 +731,7 @@ class Repos(APIView):
|
|||||||
"root": '',
|
"root": '',
|
||||||
"head_commit_id": r.head_cmmt_id,
|
"head_commit_id": r.head_cmmt_id,
|
||||||
"version": r.version,
|
"version": r.version,
|
||||||
|
"group_name": library_group_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.repo_id in repos_with_admin_share_to:
|
if r.repo_id in repos_with_admin_share_to:
|
||||||
|
@ -28,7 +28,7 @@ from seahub.api2.endpoints.group_libraries import GroupLibraries, GroupLibrary
|
|||||||
from seahub.api2.endpoints.group_owned_libraries import GroupOwnedLibraries, \
|
from seahub.api2.endpoints.group_owned_libraries import GroupOwnedLibraries, \
|
||||||
GroupOwnedLibrary, GroupOwnedLibraryUserFolderPermission, \
|
GroupOwnedLibrary, GroupOwnedLibraryUserFolderPermission, \
|
||||||
GroupOwnedLibraryGroupFolderPermission, GroupOwnedLibraryUserShare, \
|
GroupOwnedLibraryGroupFolderPermission, GroupOwnedLibraryUserShare, \
|
||||||
GroupOwnedLibraryGroupShare
|
GroupOwnedLibraryGroupShare, GroupOwnedLibraryUserShareInLibrary
|
||||||
from seahub.api2.endpoints.address_book.groups import AddressBookGroupsSubGroups
|
from seahub.api2.endpoints.address_book.groups import AddressBookGroupsSubGroups
|
||||||
from seahub.api2.endpoints.address_book.members import AddressBookGroupsSearchMember
|
from seahub.api2.endpoints.address_book.members import AddressBookGroupsSearchMember
|
||||||
|
|
||||||
@ -238,6 +238,7 @@ urlpatterns = [
|
|||||||
url(r'^api/v2.1/group-owned-libraries/(?P<repo_id>[-0-9a-f]{36})/group-folder-permission/$', GroupOwnedLibraryGroupFolderPermission.as_view(), name='api-v2.1-group-owned-library-group-folder-permission'),
|
url(r'^api/v2.1/group-owned-libraries/(?P<repo_id>[-0-9a-f]{36})/group-folder-permission/$', GroupOwnedLibraryGroupFolderPermission.as_view(), name='api-v2.1-group-owned-library-group-folder-permission'),
|
||||||
url(r'^api/v2.1/group-owned-libraries/(?P<repo_id>[-0-9a-f]{36})/user-share/$', GroupOwnedLibraryUserShare.as_view(), name='api-v2.1-group-owned-library-user-share'),
|
url(r'^api/v2.1/group-owned-libraries/(?P<repo_id>[-0-9a-f]{36})/user-share/$', GroupOwnedLibraryUserShare.as_view(), name='api-v2.1-group-owned-library-user-share'),
|
||||||
url(r'^api/v2.1/group-owned-libraries/(?P<repo_id>[-0-9a-f]{36})/group-share/$', GroupOwnedLibraryGroupShare.as_view(), name='api-v2.1-group-owned-library-group-share'),
|
url(r'^api/v2.1/group-owned-libraries/(?P<repo_id>[-0-9a-f]{36})/group-share/$', GroupOwnedLibraryGroupShare.as_view(), name='api-v2.1-group-owned-library-group-share'),
|
||||||
|
url(r'^api/v2.1/group-owned-libraries/user-share-in-libraries/(?P<repo_id>[-0-9-a-f]{36})/$', GroupOwnedLibraryUserShareInLibrary.as_view(), name='api-v2.1-group-owned-library-user-share-in-library'),
|
||||||
|
|
||||||
## user::shared-folders
|
## user::shared-folders
|
||||||
url(r'^api/v2.1/shared-folders/$', SharedFolders.as_view(), name='api-v2.1-shared-folders'),
|
url(r'^api/v2.1/shared-folders/$', SharedFolders.as_view(), name='api-v2.1-shared-folders'),
|
||||||
|
Loading…
Reference in New Issue
Block a user