summaryrefslogtreecommitdiff
path: root/isotests/views.py
diff options
context:
space:
mode:
authorTom Willemsen <tom.willemsen@archlinux.us>2011-04-28 13:00:27 -0500
committerDan McGee <dan@archlinux.org>2011-04-28 13:18:29 -0500
commit00e096ddf0654d32e67ac8bc47f3de01ed7e740b (patch)
tree70885935cb7e3e90af07f42708a9d04d818d8e4e /isotests/views.py
parentf4229daac60fa90cbf8d77bfdffd88a467869b3c (diff)
isotests: style cleanup, ui improvements
* Using radio buttons for widgets is smarter. * Model names cleanup. * Test.ms: totally un-descriptive field name, should be modules. * models, Iso: Likely need more than a date field here. Removed date and added name. * get_success_test/get_failed_test: now on abstract superclass * tests.py: I wasn't using these, so I might as well remove it. * admin.py: convention is not to use * imports. * models.py: "# Create your models here." -> not needed. * urls.py: I wasn't using info_dict anymore; I had a blank second pattern definition, and I should follow indentation patterns from elsewhere in the project. * views.py, add: switched to using mostly direct_to_template to avoid some of the boilerplate. * isotest/templates: was old, not used. * I had 4 + 1 templates, but only two views- these other ones were old, unnecessary and not wired up. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'isotests/views.py')
-rw-r--r--isotests/views.py66
1 files changed, 40 insertions, 26 deletions
diff --git a/isotests/views.py b/isotests/views.py
index 738fa90d..cb7f23c5 100644
--- a/isotests/views.py
+++ b/isotests/views.py
@@ -1,50 +1,64 @@
-# Create your views here.
from django.http import HttpResponse, HttpResponseRedirect
-from django.forms import ModelForm, DateField
-from isotests.models import *
-from django.shortcuts import render_to_response
-from django.template import RequestContext, Context, loader
+from django.forms import ModelForm, RadioSelect, CheckboxSelectMultiple
+from django.forms import ModelChoiceField
+from isotests.models import Iso, Architecture, IsoType, BootType
+from isotests.models import HardwareType, InstallType, Source, Test
+from isotests.models import ClockChoice, Filesystem, Module, Bootloader
+from django.template import Context, loader
+from django.views.generic.simple import direct_to_template
class TestForm(ModelForm):
class Meta:
model = Test
+ widgets = {
+ "architecture": RadioSelect(),
+ "iso_type": RadioSelect(),
+ "boot_type": RadioSelect(),
+ "hardware_type": RadioSelect(),
+ "install_type": RadioSelect(),
+ "source": RadioSelect(),
+ "clock_choice": RadioSelect(),
+ "filesystem": RadioSelect(),
+ "rollback_filesystem": RadioSelect(),
+ "bootloader": RadioSelect(),
+ "modules": CheckboxSelectMultiple(),
+ "rollback_modules": CheckboxSelectMultiple(),
+ }
+ iso = ModelChoiceField(queryset=Iso.objects.filter(active=True))
def add_result(request):
- if request.method == 'POST': # If the form has been submitted...
- form = TestForm(request.POST) # A form bound to the post data
- if form.is_valid(): # All validation rules pass
+ if request.method == 'POST':
+ form = TestForm(request.POST)
+ if form.is_valid():
form.save()
- return HttpResponseRedirect('/isotests') # Redirect after POST
+ return HttpResponseRedirect('/isotests')
else:
- form = TestForm() # An unbound form
+ form = TestForm()
- return render_to_response('isotests/add.html', { 'form': form, },
- context_instance=RequestContext(request))
+ context = {'form': form}
+ return direct_to_template(request, 'isotests/add.html', context)
def view_results(request):
- result_success_list = Test.objects.filter(success=True)
- result_failed_list = Test.objects.filter(success=False)
-
architecture_list = Architecture.objects.all()
- isotype_list = Isotype.objects.all()
- boottype_list = Boottype.objects.all()
- hardware_list = Hardware.objects.all()
- installtype_list = InstallType.objects.all()
+ iso_type_list = IsoType.objects.all()
+ boot_type_list = BootType.objects.all()
+ hardware_type_list = HardwareType.objects.all()
+ install_type_list = InstallType.objects.all()
source_list = Source.objects.all()
- clockchoice_list = Clockchoice.objects.all()
+ clock_choice_list = ClockChoice.objects.all()
module_list = Module.objects.all()
filesystem_list = Filesystem.objects.all()
bootloader_list = Bootloader.objects.all()
t = loader.get_template("isotests/results.html")
c = Context({
- 'arch_choices': architecture_list,
- 'isotype_choices': isotype_list,
- 'boottype_choices': boottype_list,
- 'hardware_list': hardware_list,
- 'installtype_list': installtype_list,
+ 'architecture_list': architecture_list,
+ 'iso_type_list': iso_type_list,
+ 'boot_type_list': boot_type_list,
+ 'hardware_type_list': hardware_type_list,
+ 'install_type_list': install_type_list,
'source_list': source_list,
- 'clock_choices': clockchoice_list,
+ 'clock_choices_list': clock_choice_list,
'filesystem_list': filesystem_list,
'module_list': module_list,
'bootloader_list': bootloader_list,