From 500ebdbbd20894455b2f8eea2fa30132b3cfea3e Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Mon, 18 Apr 2016 08:56:04 -0400 Subject: [PATCH 1/2] fix index error generating organization detail view context --- awx/api/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/awx/api/views.py b/awx/api/views.py index cf6849df71..f028dcb238 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -673,6 +673,9 @@ class OrganizationDetail(RetrieveUpdateDestroyAPIView): admins=Count('admin_role__members', distinct=True) ).values('users', 'admins') + if direct_counts.count() == 0: + return full_context + org_counts = direct_counts[0] org_counts['inventories'] = Inventory.accessible_objects(**access_kwargs).filter( organization__id=org_id).count() From 333730f30e0039beb38315078b6d61d5e9bfe030 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Mon, 18 Apr 2016 10:51:27 -0400 Subject: [PATCH 2/2] make special case for no results slightly more clear --- awx/api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/api/views.py b/awx/api/views.py index f028dcb238..a97f68d9a7 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -673,7 +673,7 @@ class OrganizationDetail(RetrieveUpdateDestroyAPIView): admins=Count('admin_role__members', distinct=True) ).values('users', 'admins') - if direct_counts.count() == 0: + if not direct_counts: return full_context org_counts = direct_counts[0]