From bbdfe8bc46d3983b7bd724e8413e1bf933a9321e Mon Sep 17 00:00:00 2001 From: Chris Church Date: Mon, 10 Jun 2013 21:51:34 -0400 Subject: [PATCH] Minor fix for host has_active_failures field, indentation on custom_filters file. --- ansibleworks/main/custom_filters.py | 14 ++++++-------- ansibleworks/main/models/__init__.py | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ansibleworks/main/custom_filters.py b/ansibleworks/main/custom_filters.py index ec1167bb0f..234910183d 100644 --- a/ansibleworks/main/custom_filters.py +++ b/ansibleworks/main/custom_filters.py @@ -4,8 +4,6 @@ from rest_framework.filters import BaseFilterBackend from django.core.exceptions import PermissionDenied -# TODO: does order_by still work? - class CustomFilterBackend(object): def filter_queryset(self, request, queryset, view): @@ -24,22 +22,22 @@ class CustomFilterBackend(object): for key, value in request.QUERY_PARAMS.items(): if key in [ 'page', 'page_size', 'format' ]: - continue + continue if key in ('order', 'order_by'): - order_by = value - continue + order_by = value + continue key2 = key if key2.endswith("__int"): - key2 = key.replace("__int","") - value = int(value) + key2 = key.replace("__int","") + value = int(value) terms[key2] = value qs = qs.filter(**terms) if order_by: - qs = qs.order_by(order_by) + qs = qs.order_by(order_by) return qs diff --git a/ansibleworks/main/models/__init__.py b/ansibleworks/main/models/__init__.py index 46637aa533..1e93168361 100644 --- a/ansibleworks/main/models/__init__.py +++ b/ansibleworks/main/models/__init__.py @@ -204,7 +204,8 @@ class Host(CommonModelNameNotUnique): @property 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_events.all() to get events affecting this host.