summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mirrors/models.py5
-rw-r--r--mirrors/views.py8
-rw-r--r--templates/mirrors/mirrors.html2
3 files changed, 9 insertions, 6 deletions
diff --git a/mirrors/models.py b/mirrors/models.py
index 384668b8..0179d5bf 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -33,11 +33,6 @@ class Mirror(models.Model):
def __unicode__(self):
return self.name
- def supported_protocols(self):
- protocols = MirrorProtocol.objects.filter(
- urls__mirror=self).order_by('protocol').distinct()
- return sorted(protocols)
-
def downstream(self):
return Mirror.objects.filter(upstream=self).order_by('name')
diff --git a/mirrors/views.py b/mirrors/views.py
index 5e374b4d..2e1e83b6 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -159,8 +159,16 @@ def find_mirrors_simple(request, protocol):
def mirrors(request):
mirror_list = Mirror.objects.select_related().order_by('tier', 'country')
+ protos = MirrorUrl.objects.values_list(
+ 'mirror_id', 'protocol__protocol').order_by(
+ 'mirror__id', 'protocol__protocol')
if not request.user.is_authenticated():
mirror_list = mirror_list.filter(public=True, active=True)
+ protos = protos.filter(mirror__public=True, mirror__active=True)
+ protos = dict((k, list(v)) for k, v in groupby(protos, key=itemgetter(0)))
+ for mirror in mirror_list:
+ items = protos.get(mirror.id, [])
+ mirror.protocols = [item[1] for item in items]
return render(request, 'mirrors/mirrors.html',
{'mirror_list': mirror_list})
diff --git a/templates/mirrors/mirrors.html b/templates/mirrors/mirrors.html
index 0950520d..c83d0d43 100644
--- a/templates/mirrors/mirrors.html
+++ b/templates/mirrors/mirrors.html
@@ -29,7 +29,7 @@
<td>{{ mirror.get_tier_display }}</td>
<td>{% if mirror.country %}<img src="{{ mirror.country.flag }}" alt=""/> {% endif %}{{ mirror.country.name }}</td>
<td>{{ mirror.isos|yesno|capfirst }}</td>
- <td class="wrap">{{ mirror.supported_protocols|join:", " }}</td>
+ <td class="wrap">{{ mirror.protocols|join:", " }}</td>
{% if user.is_authenticated %}
<td>{{ mirror.public|yesno|capfirst }}</td>
<td>{{ mirror.active|yesno|capfirst }}</td>