mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-25 23:02:26 +00:00
add api call to set/unset repo public
This commit is contained in:
@@ -18,6 +18,7 @@ urlpatterns = patterns('',
|
|||||||
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/$', Repo.as_view(), name="api2-repo"),
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/$', Repo.as_view(), name="api2-repo"),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/history/$', RepoHistory.as_view()),
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/history/$', RepoHistory.as_view()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/download-info/$', DownloadRepo.as_view()),
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/download-info/$', DownloadRepo.as_view()),
|
||||||
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/public/$', RepoPublic.as_view()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/upload-link/$', UploadLinkView.as_view()),
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/upload-link/$', UploadLinkView.as_view()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/update-link/$', UpdateLinkView.as_view()),
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/update-link/$', UpdateLinkView.as_view()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/upload-blks-link/$', UploadBlksLinkView.as_view()),
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/upload-blks-link/$', UploadBlksLinkView.as_view()),
|
||||||
|
@@ -682,6 +682,41 @@ class DownloadRepo(APIView):
|
|||||||
|
|
||||||
return repo_download_info(request, repo_id)
|
return repo_download_info(request, repo_id)
|
||||||
|
|
||||||
|
class RepoPublic(APIView):
|
||||||
|
authentication_classes = (TokenAuthentication, )
|
||||||
|
permission_classes = (IsAuthenticated,)
|
||||||
|
throttle_classes = (UserRateThrottle, )
|
||||||
|
|
||||||
|
def post(self, request, repo_id, format=None):
|
||||||
|
repo = get_repo(repo_id)
|
||||||
|
if not repo:
|
||||||
|
return api_error(status.HTTP_404_NOT_FOUND, 'Repo not found.')
|
||||||
|
|
||||||
|
if check_permission(repo_id, request.user.username) != 'rw':
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, 'Forbid to access this repo.')
|
||||||
|
|
||||||
|
try:
|
||||||
|
seafile_api.add_inner_pub_repo(repo_id, "r")
|
||||||
|
except:
|
||||||
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Unable to make repo public')
|
||||||
|
|
||||||
|
return HttpResponse(json.dumps({'success': True}), status=200, content_type=json_content_type)
|
||||||
|
|
||||||
|
def delete(self, request, repo_id, format=None):
|
||||||
|
repo = get_repo(repo_id)
|
||||||
|
if not repo:
|
||||||
|
return api_error(status.HTTP_404_NOT_FOUND, 'Repo not found.')
|
||||||
|
|
||||||
|
if check_permission(repo_id, request.user.username) != 'rw':
|
||||||
|
return api_error(status.HTTP_403_FORBIDDEN, 'Forbid to access this repo.')
|
||||||
|
|
||||||
|
try:
|
||||||
|
seafile_api.remove_inner_pub_repo(repo_id)
|
||||||
|
except:
|
||||||
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Unable to make repo private')
|
||||||
|
|
||||||
|
return HttpResponse(json.dumps({'success': True}), status=200, content_type=json_content_type)
|
||||||
|
|
||||||
class UploadLinkView(APIView):
|
class UploadLinkView(APIView):
|
||||||
authentication_classes = (TokenAuthentication, )
|
authentication_classes = (TokenAuthentication, )
|
||||||
permission_classes = (IsAuthenticated, )
|
permission_classes = (IsAuthenticated, )
|
||||||
|
Reference in New Issue
Block a user