From 952eba9625c5222e1eee77f711ecb3996998bafb Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 25 Apr 2012 02:20:45 -0500 Subject: 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 --- mirrors/views.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'mirrors/views.py') diff --git a/mirrors/views.py b/mirrors/views.py index 349c17d..6c08f71 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 s." + return self._html_output( + normal_row = u'%(label)s %(field)s%(help_text)s', + error_row = u'%s', + row_ender = '', + help_text_html = u' %s', + 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}) -- cgit v1.2.3-24-g4f1b