summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/urls_mirrorlist.py5
-rw-r--r--mirrors/views.py18
2 files changed, 14 insertions, 9 deletions
diff --git a/mirrors/urls_mirrorlist.py b/mirrors/urls_mirrorlist.py
index e0f44c78..1444eca9 100644
--- a/mirrors/urls_mirrorlist.py
+++ b/mirrors/urls_mirrorlist.py
@@ -3,10 +3,7 @@ from django.conf.urls import patterns
urlpatterns = patterns('mirrors.views',
(r'^$', 'generate_mirrorlist', {}, 'mirrorlist'),
(r'^all/$', 'find_mirrors', {'countries': ['all']}),
- (r'^all/ftp/$', 'find_mirrors',
- {'countries': ['all'], 'protocols': ['ftp']}),
- (r'^all/http/$', 'find_mirrors',
- {'countries': ['all'], 'protocols': ['http']}),
+ (r'^all/(?P<protocol>[A-z]+)/$', 'find_mirrors_simple')
)
# vim: set ts=4 sw=4 et:
diff --git a/mirrors/views.py b/mirrors/views.py
index c52656f7..6f37ace1 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -82,12 +82,15 @@ def generate_mirrorlist(request):
def find_mirrors(request, countries=None, protocols=None, use_status=False,
ipv4_supported=True, ipv6_supported=True):
if not protocols:
- protocols = MirrorProtocol.objects.filter(
- is_download=True).values_list('protocol', flat=True)
+ protocols = MirrorProtocol.objects.filter(is_download=True)
+ elif hasattr(protocols, 'model') and protocols.model == MirrorProtocol:
+ # we already have a queryset, no need to query again
+ pass
+ else:
+ protocols = MirrorProtocol.objects.filter(protocol__in=protocols)
qset = MirrorUrl.objects.select_related().filter(
- protocol__protocol__in=protocols,
- mirror__public=True, mirror__active=True,
- )
+ protocol__in=protocols,
+ mirror__public=True, mirror__active=True)
if countries and 'all' not in countries:
qset = qset.filter(Q(country__in=countries) |
Q(mirror__country__in=countries))
@@ -124,6 +127,11 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False,
mimetype='text/plain')
+def find_mirrors_simple(request, protocol):
+ proto = get_object_or_404(MirrorProtocol, protocol=protocol)
+ return find_mirrors(request, protocols=[proto])
+
+
def mirrors(request):
mirror_list = Mirror.objects.select_related().order_by('tier', 'country')
if not request.user.is_authenticated():