AC-990 Make job event filtering by host work even when not capturing hosts M2M. Also fix unit tests to skip checking hosts M2M.

This commit is contained in:
Chris Church
2014-02-06 15:07:37 -05:00
parent 4c38b05f90
commit 11d8387120
5 changed files with 38 additions and 21 deletions

View File

@@ -118,6 +118,12 @@ class FieldLookupBackend(BaseFilterBackend):
for key, values in request.QUERY_PARAMS.lists():
if key in self.RESERVED_NAMES:
continue
# HACK: Make job event filtering by host name mostly work even
# when not capturing job event hosts M2M.
if queryset.model._meta.object_name == 'JobEvent' and key.startswith('hosts__name'):
key = key.replace('hosts__name', 'or__host__name')
or_filters.append((False, 'host__name__isnull', True))
# Custom __int filter suffix (internal use only).
q_int = False