summaryrefslogtreecommitdiff
path: root/mirrors
diff options
context:
space:
mode:
Diffstat (limited to 'mirrors')
-rw-r--r--mirrors/admin.py1
-rw-r--r--mirrors/fixtures/mirrorprotocols.json9
-rw-r--r--mirrors/models.py2
-rw-r--r--mirrors/urls_mirrorlist.py4
-rw-r--r--mirrors/views.py29
5 files changed, 10 insertions, 35 deletions
diff --git a/mirrors/admin.py b/mirrors/admin.py
index 9c88207d..d0f2f475 100644
--- a/mirrors/admin.py
+++ b/mirrors/admin.py
@@ -10,6 +10,7 @@ from .models import (Mirror, MirrorProtocol, MirrorUrl, MirrorRsync,
class MirrorUrlForm(forms.ModelForm):
class Meta:
model = MirrorUrl
+
def clean_url(self):
# is this a valid-looking URL?
url_parts = urlparse(self.cleaned_data["url"])
diff --git a/mirrors/fixtures/mirrorprotocols.json b/mirrors/fixtures/mirrorprotocols.json
index 8822ef8e..1a07510b 100644
--- a/mirrors/fixtures/mirrorprotocols.json
+++ b/mirrors/fixtures/mirrorprotocols.json
@@ -9,15 +9,6 @@
}
},
{
- "pk": 2,
- "model": "mirrors.mirrorprotocol",
- "fields": {
- "is_download": true,
- "default": false,
- "protocol": "ftp"
- }
- },
- {
"pk": 3,
"model": "mirrors.mirrorprotocol",
"fields": {
diff --git a/mirrors/models.py b/mirrors/models.py
index d8ac7952..91793e0a 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -47,7 +47,7 @@ class Mirror(models.Model):
class MirrorProtocol(models.Model):
protocol = models.CharField(max_length=10, unique=True)
is_download = models.BooleanField(default=True,
- help_text="Is protocol useful for end-users, e.g. FTP/HTTP")
+ help_text="Is protocol useful for end-users, e.g. HTTP")
default = models.BooleanField(default=True,
help_text="Included by default when building mirror list?")
created = models.DateTimeField(editable=False)
diff --git a/mirrors/urls_mirrorlist.py b/mirrors/urls_mirrorlist.py
index 1444eca9..bba54ec9 100644
--- a/mirrors/urls_mirrorlist.py
+++ b/mirrors/urls_mirrorlist.py
@@ -1,9 +1,11 @@
from django.conf.urls import patterns
+
urlpatterns = patterns('mirrors.views',
(r'^$', 'generate_mirrorlist', {}, 'mirrorlist'),
(r'^all/$', 'find_mirrors', {'countries': ['all']}),
- (r'^all/(?P<protocol>[A-z]+)/$', 'find_mirrors_simple')
+ (r'^all/(?P<protocol>[A-z]+)/$', 'find_mirrors_simple',
+ {}, 'mirrorlist_simple')
)
# vim: set ts=4 sw=4 et:
diff --git a/mirrors/views.py b/mirrors/views.py
index d1dd9da3..22eb57b8 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -8,7 +8,7 @@ from django.forms.widgets import CheckboxSelectMultiple
from django.core.serializers.json import DjangoJSONEncoder
from django.db.models import Q
from django.http import Http404, HttpResponse
-from django.shortcuts import get_object_or_404, render
+from django.shortcuts import get_object_or_404, redirect, render
from django.utils.timezone import now
from django.views.decorators.csrf import csrf_exempt
from django_countries.countries import COUNTRIES
@@ -78,18 +78,6 @@ def generate_mirrorlist(request):
{'mirrorlist_form': form})
-def default_protocol_filter(original_urls):
- key_func = attrgetter('country')
- sorted_urls = sorted(original_urls, key=key_func)
- urls = []
- for _, group in groupby(sorted_urls, key=key_func):
- cntry_urls = list(group)
- if any(url.protocol.default for url in cntry_urls):
- cntry_urls = [url for url in cntry_urls if url.protocol.default]
- urls.extend(cntry_urls)
- return urls
-
-
def status_filter(original_urls):
status_info = get_mirror_statuses()
scores = {u.id: u.score for u in status_info['urls']}
@@ -105,7 +93,7 @@ def status_filter(original_urls):
def find_mirrors(request, countries=None, protocols=None, use_status=False,
- ipv4_supported=True, ipv6_supported=True, smart_protocol=False):
+ ipv4_supported=True, ipv6_supported=True):
if not protocols:
protocols = MirrorProtocol.objects.filter(is_download=True)
elif hasattr(protocols, 'model') and protocols.model == MirrorProtocol:
@@ -126,17 +114,12 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False,
ip_version |= Q(has_ipv6=True)
qset = qset.filter(ip_version)
- if smart_protocol:
- urls = default_protocol_filter(qset)
- else:
- urls = qset
-
if not use_status:
sort_key = attrgetter('country.name', 'mirror.name', 'url')
- urls = sorted(urls, key=sort_key)
+ urls = sorted(qset, key=sort_key)
template = 'mirrors/mirrorlist.txt'
else:
- urls = status_filter(urls)
+ urls = status_filter(qset)
template = 'mirrors/mirrorlist_status.txt'
context = {
@@ -147,9 +130,7 @@ def find_mirrors(request, countries=None, protocols=None, use_status=False,
def find_mirrors_simple(request, protocol):
if protocol == 'smart':
- # generate a 'smart' mirrorlist, one that only includes FTP mirrors if
- # no HTTP mirror is available in that country.
- return find_mirrors(request, smart_protocol=True)
+ return redirect('mirrorlist_simple', 'http', permanent=True)
proto = get_object_or_404(MirrorProtocol, protocol=protocol)
return find_mirrors(request, protocols=[proto])