Add the builds tab

This commit is contained in:
Joseph Schorr 2015-03-13 15:34:28 -07:00
parent 347bf31f2d
commit 333e0acd6d
25 changed files with 668 additions and 60 deletions

View file

@ -148,12 +148,17 @@ class RepositoryBuildList(RepositoryParamResource):
@require_repo_read
@parse_args
@query_param('limit', 'The maximum number of builds to return', type=int, default=5)
@query_param('since', 'Returns all builds since the given unix timecode', type=int, default=None)
@nickname('getRepoBuilds')
def get(self, args, namespace, repository):
""" Get the list of repository builds. """
limit = args['limit']
builds = list(model.list_repository_builds(namespace, repository, limit))
limit = args.get('limit', 5)
since = args.get('since', None)
if since is not None:
since = datetime.datetime.utcfromtimestamp(since)
builds = model.list_repository_builds(namespace, repository, limit, since=since)
can_write = ModifyRepositoryPermission(namespace, repository).can()
return {
'builds': [build_status_view(build, can_write) for build in builds]