Add page support to the public repo list
This commit is contained in:
parent
f8b4057b26
commit
58b3ce2647
4 changed files with 82 additions and 5 deletions
|
@ -790,11 +790,13 @@ def list_repos():
|
|||
'is_public': repo_obj.visibility.name == 'public',
|
||||
}
|
||||
|
||||
page = request.args.get('page', None)
|
||||
limit = request.args.get('limit', None)
|
||||
namespace_filter = request.args.get('namespace', None)
|
||||
include_public = request.args.get('public', 'true')
|
||||
include_private = request.args.get('private', 'true')
|
||||
sort = request.args.get('sort', 'false')
|
||||
include_count = request.args.get('count', 'false')
|
||||
|
||||
try:
|
||||
limit = int(limit) if limit else None
|
||||
|
@ -803,21 +805,38 @@ def list_repos():
|
|||
|
||||
include_public = include_public == 'true'
|
||||
include_private = include_private == 'true'
|
||||
include_count = include_count == 'true'
|
||||
sort = sort == 'true'
|
||||
if page:
|
||||
try:
|
||||
page = int(page)
|
||||
except:
|
||||
page = None
|
||||
|
||||
username = None
|
||||
if current_user.is_authenticated() and include_private:
|
||||
username = current_user.db_user().username
|
||||
|
||||
repo_query = model.get_visible_repositories(username, limit=limit,
|
||||
repo_count = None
|
||||
if include_count:
|
||||
repo_count = model.get_visible_repository_count(username,
|
||||
include_public=include_public,
|
||||
sort=sort,
|
||||
namespace=namespace_filter)
|
||||
|
||||
repo_query = model.get_visible_repositories(username, limit=limit, page=page,
|
||||
include_public=include_public,
|
||||
sort=sort,
|
||||
namespace=namespace_filter)
|
||||
|
||||
repos = [repo_view(repo) for repo in repo_query]
|
||||
response = {
|
||||
'repositories': repos
|
||||
}
|
||||
|
||||
if include_count:
|
||||
response['count'] = repo_count
|
||||
|
||||
return jsonify(response)
|
||||
|
||||
|
||||
|
|
Reference in a new issue