Use koji.BUILD_STATES when filtering component builds by state name

This commit is contained in:
mprahl
2017-11-27 15:25:53 -05:00
parent 6c8fad0338
commit 87900585da

View File

@@ -449,8 +449,13 @@ def filter_component_builds(flask_request):
if state.isdigit():
search_query['state'] = state
else:
if state in models.BUILD_STATES:
search_query['state'] = models.BUILD_STATES[state]
try:
import koji
except ImportError:
raise ValidationError('Cannot filter by state names because koji isn\'t installed')
if state.upper() in koji.BUILD_STATES:
search_query['state'] = koji.BUILD_STATES[state.upper()]
else:
raise ValidationError('An invalid state was supplied')