Fix the tag logic.

This commit is contained in:
jakedt 2014-03-05 14:57:14 -05:00
parent 638dbb3d8d
commit 7a89b0872f

View file

@ -212,22 +212,19 @@ def build_status_badge(namespace, repository):
abort(404)
# Lookup the tags for the repository.
# Lookup the current/recent build.
status = 'none'
tags = model.list_repository_tags(namespace, repository)
is_empty = len(list(tags)) == 0
build = model.get_recent_repository_build(namespace, repository)
if build:
if build.phase == 'error':
status = 'failed'
elif build.phase == 'complete':
status = 'ready'
else:
status = 'building'
else:
tags = model.list_repository_tags(namespace, repository)
if list(tags):
status = 'ready'
response = make_response(STATUS_TAGS[status])
if not is_empty and (not build or build.phase == 'complete'):
status_name = 'ready'
elif build and build.phase == 'error':
status_name = 'failed'
elif build:
status_name = 'building'
else:
status_name = 'none'
response = make_response(STATUS_TAGS[status_name])
response.content_type = 'image/svg+xml'
return response