mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 19:01:42 +00:00
File Revision
This commit is contained in:
@@ -20,6 +20,7 @@ urlpatterns = patterns('',
|
|||||||
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()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/update-blks-link/$', UpdateBlksLinkView.as_view()),
|
url(r'^repos/(?P<repo_id>[-0-9a-f]{36})/update-blks-link/$', UpdateBlksLinkView.as_view()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9-a-f]{36})/file/$', FileView.as_view(), name='FileView'),
|
url(r'^repos/(?P<repo_id>[-0-9-a-f]{36})/file/$', FileView.as_view(), name='FileView'),
|
||||||
|
url(r'^repos/(?P<repo_id>[-0-9-a-f]{36})/file/revision/$', FileRevision.as_view()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9-a-f]{36})/file/shared-link/$', FileSharedLinkView.as_view()),
|
url(r'^repos/(?P<repo_id>[-0-9-a-f]{36})/file/shared-link/$', FileSharedLinkView.as_view()),
|
||||||
url(r'^repos/(?P<repo_id>[-0-9-a-f]{36})/dir/$', DirView.as_view(), name='DirView'),
|
url(r'^repos/(?P<repo_id>[-0-9-a-f]{36})/dir/$', DirView.as_view(), name='DirView'),
|
||||||
url(r'^starredfiles/', StarredFileView.as_view(), name='starredfiles'),
|
url(r'^starredfiles/', StarredFileView.as_view(), name='starredfiles'),
|
||||||
|
@@ -1127,6 +1127,26 @@ class FileView(APIView):
|
|||||||
|
|
||||||
return reloaddir_if_neccessary(request, repo_id, parent_dir)
|
return reloaddir_if_neccessary(request, repo_id, parent_dir)
|
||||||
|
|
||||||
|
class FileRevision(APIView):
|
||||||
|
authentication_classes = (TokenAuthentication, )
|
||||||
|
permission_classes = (IsAuthenticated,)
|
||||||
|
throttle_classes = (UserRateThrottle, )
|
||||||
|
|
||||||
|
def get(self, request, repo_id, format=None):
|
||||||
|
path = request.GET.get('p', None)
|
||||||
|
assert path, 'path must be passed in the url'
|
||||||
|
|
||||||
|
file_name = os.path.basename(path)
|
||||||
|
commit_id = request.GET.get('commit_id', None)
|
||||||
|
|
||||||
|
try:
|
||||||
|
obj_id = seafserv_threaded_rpc.get_file_id_by_commit_and_path( \
|
||||||
|
commit_id, path)
|
||||||
|
except:
|
||||||
|
return api_error(status.HTTP_404_NOT_FOUND, 'Revision not found.')
|
||||||
|
|
||||||
|
return get_repo_file(request, repo_id, obj_id, file_name, 'download')
|
||||||
|
|
||||||
class FileSharedLinkView(APIView):
|
class FileSharedLinkView(APIView):
|
||||||
"""
|
"""
|
||||||
Support uniform interface for file shared link.
|
Support uniform interface for file shared link.
|
||||||
|
Reference in New Issue
Block a user