summaryrefslogtreecommitdiff
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
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>
-rw-r--r--mirrors/views.py18
-rw-r--r--sitestatic/archweb.css10
-rw-r--r--templates/mirrors/mirrorlist_generate.html (renamed from templates/mirrors/index.html)2
3 files changed, 26 insertions, 4 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})
diff --git a/sitestatic/archweb.css b/sitestatic/archweb.css
index fdc356ff..407156f8 100644
--- a/sitestatic/archweb.css
+++ b/sitestatic/archweb.css
@@ -802,6 +802,16 @@ table td.country {
white-space: normal;
}
+form#list-generator div ul {
+ list-style: none;
+ display: inline;
+ padding-left: 0;
+}
+
+ form#list-generator div ul li {
+ display: inline;
+ }
+
/* dev/TU biographies */
div#arch-bio-toc {
width: 75%;
diff --git a/templates/mirrors/index.html b/templates/mirrors/mirrorlist_generate.html
index 49907b8f..e6f5e28c 100644
--- a/templates/mirrors/index.html
+++ b/templates/mirrors/mirrorlist_generate.html
@@ -36,7 +36,7 @@
mirror list and used to pre-order the mirrors.</p>
<form id="list-generator" method="get">
- {{ mirrorlist_form.as_p }}
+ {{ mirrorlist_form.as_div }}
<p><label></label> <input type="submit" value="Generate List" /></p>
</form>
</div>