mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
Merge pull request #119 from urg/ViewRepoHistory
Add View Repo History api call
This commit is contained in:
@@ -14,6 +14,7 @@ urlpatterns = patterns('',
|
||||
url(r'^account/info/$', AccountInfo.as_view()),
|
||||
url(r'^repos/$', Repos.as_view(), name="api2-repos"),
|
||||
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})/download-info/$', DownloadRepo.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()),
|
||||
|
@@ -570,6 +570,29 @@ class Repo(APIView):
|
||||
seafile_api.remove_repo(repo_id)
|
||||
return Response('success', status=status.HTTP_200_OK)
|
||||
|
||||
class RepoHistory(APIView):
|
||||
authentication_classes = (TokenAuthentication, )
|
||||
permission_classes = (IsAuthenticated,)
|
||||
throttle_classes = (UserRateThrottle, )
|
||||
|
||||
def get(self, request, repo_id, format=None):
|
||||
try:
|
||||
current_page = int(request.GET.get('page', '1'))
|
||||
per_page = int(request.GET.get('per_page', '25'))
|
||||
except ValueError:
|
||||
current_page = 1
|
||||
per_page = 25
|
||||
|
||||
commits_all = get_commits(repo_id, per_page * (current_page -1), per_page + 1)
|
||||
commits = commits_all[:per_page]
|
||||
|
||||
if len(commits_all) == per_page + 1:
|
||||
page_next = True
|
||||
else:
|
||||
page_next = False
|
||||
|
||||
return HttpResponse(json.dumps({"commits": commits, "page_next": page_next}, cls=SearpcObjEncoder), status=200, content_type=json_content_type)
|
||||
|
||||
class DownloadRepo(APIView):
|
||||
authentication_classes = (TokenAuthentication, )
|
||||
permission_classes = (IsAuthenticated, )
|
||||
|
Reference in New Issue
Block a user