1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 00:00:00 +00:00

support pagination when get group repos (#4642)

Co-authored-by: lian <lian@seafile.com>
This commit is contained in:
lian
2020-08-17 11:53:05 +08:00
committed by GitHub
parent dcff1ff5e1
commit e9c2e5c76e

View File

@@ -58,6 +58,7 @@ def get_group_repo_info(request, group_repo):
return group_repo_info
class GroupLibraries(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
@@ -84,6 +85,16 @@ class GroupLibraries(APIView):
group_repos.sort(key=lambda x: x.last_modified, reverse=True)
try:
current_page = int(request.GET.get('page', '1'))
per_page = int(request.GET.get('per_page', '100'))
except ValueError:
current_page = 1
per_page = 100
start = (current_page - 1) * per_page
group_repos = group_repos[start:start+per_page]
# get repo id owner dict
all_repo_owner = []
repo_id_owner_dict = {}