From 87900585da07869e48d85807ec71ff4cac52c34a Mon Sep 17 00:00:00 2001 From: mprahl Date: Mon, 27 Nov 2017 15:25:53 -0500 Subject: [PATCH] Use koji.BUILD_STATES when filtering component builds by state name --- module_build_service/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/module_build_service/utils.py b/module_build_service/utils.py index 06cfb026..a1429ea7 100644 --- a/module_build_service/utils.py +++ b/module_build_service/utils.py @@ -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')