From 8973ee37c21ce0703244e07d60590a137ee16832 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 13 Oct 2010 19:15:50 -0500 Subject: Show all mirrors if no IP version specified I'm eating my words on this one- we don't want to filter to none() if we don't have an IP version specified, because people hitting the URL without a ip_version parameter would no longer get any mirrors back. Filter if they are provided by using a Q() object. Signed-off-by: Dan McGee --- mirrors/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mirrors/views.py b/mirrors/views.py index dcac6929..93007acb 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -62,12 +62,12 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False, if countries and 'all' not in countries: qset = qset.filter(mirror__country__in=countries) - if ipv4_supported and not ipv6_supported: - qset = qset.filter(has_ipv4=True) - elif ipv6_supported and not ipv4_supported: - qset = qset.filter(has_ipv6=True) - elif not ipv4_supported and not ipv6_supported: - qset = qset.none() + ip_version = Q() + if ipv4_supported: + ip_version |= Q(has_ipv4=True) + if ipv6_supported: + ip_version |= Q(has_ipv6=True) + qset = qset.filter(ip_version) if not use_status: urls = qset.order_by('mirror__country', 'mirror__name', 'url') -- cgit v1.2.3-54-g00ecf