mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Minor fix for host has_active_failures field, indentation on custom_filters file.
This commit is contained in:
@@ -4,8 +4,6 @@
|
|||||||
from rest_framework.filters import BaseFilterBackend
|
from rest_framework.filters import BaseFilterBackend
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
|
||||||
# TODO: does order_by still work?
|
|
||||||
|
|
||||||
class CustomFilterBackend(object):
|
class CustomFilterBackend(object):
|
||||||
|
|
||||||
def filter_queryset(self, request, queryset, view):
|
def filter_queryset(self, request, queryset, view):
|
||||||
@@ -24,22 +22,22 @@ class CustomFilterBackend(object):
|
|||||||
for key, value in request.QUERY_PARAMS.items():
|
for key, value in request.QUERY_PARAMS.items():
|
||||||
|
|
||||||
if key in [ 'page', 'page_size', 'format' ]:
|
if key in [ 'page', 'page_size', 'format' ]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if key in ('order', 'order_by'):
|
if key in ('order', 'order_by'):
|
||||||
order_by = value
|
order_by = value
|
||||||
continue
|
continue
|
||||||
|
|
||||||
key2 = key
|
key2 = key
|
||||||
if key2.endswith("__int"):
|
if key2.endswith("__int"):
|
||||||
key2 = key.replace("__int","")
|
key2 = key.replace("__int","")
|
||||||
value = int(value)
|
value = int(value)
|
||||||
|
|
||||||
terms[key2] = value
|
terms[key2] = value
|
||||||
|
|
||||||
qs = qs.filter(**terms)
|
qs = qs.filter(**terms)
|
||||||
|
|
||||||
if order_by:
|
if order_by:
|
||||||
qs = qs.order_by(order_by)
|
qs = qs.order_by(order_by)
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|||||||
@@ -204,7 +204,8 @@ class Host(CommonModelNameNotUnique):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def has_active_failures(self):
|
def has_active_failures(self):
|
||||||
return self.last_job_host_summary and self.last_job_host_summary.failed
|
return bool(self.last_job_host_summary and
|
||||||
|
self.last_job_host_summary.failed)
|
||||||
|
|
||||||
# Use .job_host_summaries.all() to get jobs affecting this host.
|
# Use .job_host_summaries.all() to get jobs affecting this host.
|
||||||
# Use .job_events.all() to get events affecting this host.
|
# Use .job_events.all() to get events affecting this host.
|
||||||
|
|||||||
Reference in New Issue
Block a user