summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/templatetags/flags.py2
-rw-r--r--mirrors/views.py37
-rw-r--r--settings.py5
-rw-r--r--templates/mirrors/mirrors.html8
4 files changed, 39 insertions, 13 deletions
diff --git a/main/templatetags/flags.py b/main/templatetags/flags.py
index 22f524ca..5b356561 100644
--- a/main/templatetags/flags.py
+++ b/main/templatetags/flags.py
@@ -8,6 +8,6 @@ def country_flag(country):
if not country:
return ''
return '<span class="fam-flag fam-flag-%s" title="%s"></span> ' % (
- country.code.lower(), country.name)
+ unicode(country.code).lower(), unicode(country.name))
# vim: set ts=4 sw=4 et:
diff --git a/mirrors/views.py b/mirrors/views.py
index cffafbf5..65fa0123 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -4,7 +4,7 @@ import json
from operator import attrgetter, itemgetter
from django import forms
-from django.forms.widgets import CheckboxSelectMultiple
+from django.forms.widgets import SelectMultiple, CheckboxSelectMultiple
from django.core.serializers.json import DjangoJSONEncoder
from django.db import connection
from django.db.models import Q
@@ -14,7 +14,8 @@ from django.utils.timezone import now
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import condition
-from django_countries.data import COUNTRIES
+from django_countries import countries
+from django_countries.fields import Country
from .models import (Mirror, MirrorUrl, MirrorProtocol, MirrorLog,
CheckLocation)
@@ -22,7 +23,8 @@ from .utils import get_mirror_statuses, get_mirror_errors, DEFAULT_CUTOFF
class MirrorlistForm(forms.Form):
- country = forms.MultipleChoiceField(required=False)
+ country = forms.MultipleChoiceField(required=False,
+ widget=SelectMultiple(attrs={'size': '12'}))
protocol = forms.MultipleChoiceField(required=False,
widget=CheckboxSelectMultiple)
ip_version = forms.MultipleChoiceField(required=False,
@@ -30,8 +32,6 @@ class MirrorlistForm(forms.Form):
widget=CheckboxSelectMultiple)
use_mirror_status = forms.BooleanField(required=False)
- countries = dict(COUNTRIES)
-
def __init__(self, *args, **kwargs):
super(MirrorlistForm, self).__init__(*args, **kwargs)
fields = self.fields
@@ -49,8 +49,8 @@ class MirrorlistForm(forms.Form):
country_codes.update(MirrorUrl.objects.filter(active=True,
mirror__active=True).exclude(country='').values_list(
'country', flat=True).order_by().distinct())
- countries = [(code, self.countries[code]) for code in country_codes]
- return sorted(countries, key=itemgetter(1))
+ code_list = [(code, countries.name(code)) for code in country_codes]
+ return sorted(code_list, key=itemgetter(1))
def as_div(self):
"Returns this form rendered as HTML <divs>s."
@@ -142,14 +142,29 @@ def mirrors(request):
mirror_list = Mirror.objects.select_related().order_by('tier', 'name')
protos = MirrorUrl.objects.values_list(
'mirror_id', 'protocol__protocol').order_by(
- 'mirror__id', 'protocol__protocol').distinct()
+ 'mirror_id', 'protocol__protocol').distinct()
+ countries = MirrorUrl.objects.values_list(
+ 'mirror_id', 'country').order_by(
+ 'mirror_id', 'country').distinct()
+
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 = protos.filter(
+ mirror__public=True, mirror__active=True, active=True)
+ countries = countries.filter(
+ mirror__public=True, mirror__active=True, active=True)
+
protos = {k: list(v) for k, v in groupby(protos, key=itemgetter(0))}
+ countries = {k: list(v) for k, v in groupby(countries, key=itemgetter(0))}
+
for mirror in mirror_list:
- items = protos.get(mirror.id, [])
- mirror.protocols = [item[1] for item in items]
+ item_protos = protos.get(mirror.id, [])
+ mirror.protocols = [item[1] for item in item_protos]
+ mirror.country = None
+ item_countries = countries.get(mirror.id, [])
+ if len(item_countries) == 1:
+ mirror.country = Country(item_countries[0][1])
+
return render(request, 'mirrors/mirrors.html',
{'mirror_list': mirror_list})
diff --git a/settings.py b/settings.py
index ba6c68ee..60fe71bc 100644
--- a/settings.py
+++ b/settings.py
@@ -175,6 +175,11 @@ TORRENT_TRACKERS = (
'http://tracker.archlinux.org:6969/announce',
)
+# Country name overrides for display purposes
+COUNTRIES_OVERRIDE = {
+ 'MK': 'Macedonia',
+}
+
## Import local settings
from local_settings import *
diff --git a/templates/mirrors/mirrors.html b/templates/mirrors/mirrors.html
index 4276b30a..f55bd875 100644
--- a/templates/mirrors/mirrors.html
+++ b/templates/mirrors/mirrors.html
@@ -1,8 +1,12 @@
{% extends "base.html" %}
{% load cycle from future %}
{% load static from staticfiles %}
+{% load flags %}
+
{% block title %}Arch Linux - Mirror Overview{% endblock %}
+{% block head %}<link rel="stylesheet" type="text/css" href="{% static "flags/fam.css" %}" media="screen, projection" />{% endblock %}
+
{% block content %}
<div id="dev-mirrorlist" class="box">
<h2>Mirror Overview</h2>
@@ -10,6 +14,7 @@
<thead>
<tr>
<th>Server</th>
+ <th>Country</th>
<th>Tier</th>
<th>ISOs</th>
<th>Protocols</th>
@@ -26,6 +31,7 @@
<tr class="{% cycle 'odd' 'even' %}">
<td><a href="{{ mirror.get_absolute_url }}"
title="Mirror details for {{ mirror.name }}">{{ mirror.name }}</a></td>
+ <td class="country">{% if mirror.country %}{% country_flag mirror.country %}{{ mirror.country.name }}{% else %}Various{% endif %}</td>
<td>{{ mirror.get_tier_display }}</td>
<td>{{ mirror.isos|yesno|capfirst }}</td>
<td class="wrap">{{ mirror.protocols|join:", " }}</td>
@@ -44,7 +50,7 @@
<script type="text/javascript" src="{% static "archweb.js" %}"></script>
<script type="text/javascript">
$(document).ready(function() {
- $(".results").tablesorter({widgets: ['zebra'], sortList: [[1,0], [0,0]]});
+ $(".results").tablesorter({widgets: ['zebra'], sortList: [[2,0], [0,0]]});
});
</script>
{% endblock %}