summaryrefslogtreecommitdiff
path: root/mirrors/views.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-25 02:20:45 -0500
committerDan McGee <dan@archlinux.org>2012-04-25 02:20:45 -0500
commit952eba9625c5222e1eee77f711ecb3996998bafb (patch)
tree94b94c9f1d3271ec30b748fde7f8947fc9500b3a /mirrors/views.py
parent6cc31041772537616a3004b89f0a109a458d124e (diff)
Clean up mirrorlist generation form a bit
Rename template since it really isn't an index of mirrors at all, and convert the form to use multiple checkboxes for both ftp/http and ipv4/ipv6 selection. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/views.py')
-rw-r--r--mirrors/views.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/mirrors/views.py b/mirrors/views.py
index 349c17d1..6c08f712 100644
--- a/mirrors/views.py
+++ b/mirrors/views.py
@@ -2,6 +2,7 @@ import datetime
from operator import attrgetter, itemgetter
from django import forms
+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
@@ -19,9 +20,11 @@ COUNTRY_LOOKUP = dict(COUNTRIES)
class MirrorlistForm(forms.Form):
country = forms.MultipleChoiceField(required=False)
- protocol = forms.MultipleChoiceField(required=False)
+ protocol = forms.MultipleChoiceField(required=False,
+ widget=CheckboxSelectMultiple)
ip_version = forms.MultipleChoiceField(required=False,
- label="IP version", choices=(('4','IPv4'), ('6','IPv6')))
+ label="IP version", choices=(('4','IPv4'), ('6','IPv6')),
+ widget=CheckboxSelectMultiple)
use_mirror_status = forms.BooleanField(required=False)
def __init__(self, *args, **kwargs):
@@ -47,6 +50,15 @@ class MirrorlistForm(forms.Form):
countries = [(code, COUNTRY_LOOKUP[code]) for code in country_codes]
return sorted(countries, key=itemgetter(1))
+ def as_div(self):
+ "Returns this form rendered as HTML <divs>s."
+ return self._html_output(
+ normal_row = u'<div%(html_class_attr)s>%(label)s %(field)s%(help_text)s</div>',
+ error_row = u'%s',
+ row_ender = '</div>',
+ help_text_html = u' <span class="helptext">%s</span>',
+ errors_on_separate_row = True)
+
@csrf_exempt
def generate_mirrorlist(request):
@@ -63,7 +75,7 @@ def generate_mirrorlist(request):
else:
form = MirrorlistForm()
- return direct_to_template(request, 'mirrors/index.html',
+ return direct_to_template(request, 'mirrors/mirrorlist_generate.html',
{'mirrorlist_form': form})