diff --git a/awx/api/views.py b/awx/api/views.py index fbc555e9c6..1984f4f136 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -1710,6 +1710,13 @@ class HostList(ListCreateAPIView): qs = qs.filter(filter_q) return qs + def list(self, *args, **kwargs): + try: + queryset = self.get_queryset() + except Exception as e: + return Response(dict(error=_(unicode(e))), status=status.HTTP_400_BAD_REQUEST) + return Response(dict(results=self.serializer_class(queryset, many=True).data)) + class HostDetail(RetrieveUpdateDestroyAPIView): diff --git a/awx/main/fields.py b/awx/main/fields.py index 84e090b7de..63f8159b46 100644 --- a/awx/main/fields.py +++ b/awx/main/fields.py @@ -488,13 +488,8 @@ class DynamicFilterField(models.TextField): * handle keys with " via: a.\"b.c="yeah" * handle key with __ in it - * add not support - - * transform [] into contains via: a.b.c[].d[].e.f[]="blah" - - * handle optional value quoted: a.b.c="" - ''' + filter_string_raw = filter_string filter_string = unicode(filter_string) atom = CharsNotIn(unicode_spaces_other) @@ -511,7 +506,11 @@ class DynamicFilterField(models.TextField): ("or", 2, opAssoc.LEFT, cls.BoolOr), ]) - res = boolExpr.parseString('(' + filter_string + ')') + try: + res = boolExpr.parseString('(' + filter_string + ')') + except: + raise RuntimeError(u"Invalid query %s" % filter_string_raw) + if len(res) > 0: return res[0].result