summaryrefslogtreecommitdiff
path: root/isotests
diff options
context:
space:
mode:
authorTom Willemsen <tom.willemsen@archlinux.us>2011-04-28 13:19:42 -0500
committerDan McGee <dan@archlinux.org>2011-04-28 13:19:49 -0500
commitc292dcfc6bf96ebf5f34342beb1367aa5361f7c4 (patch)
treece49cd8c6bc90b37a6e4f61da53c17018fd865f2 /isotests
parentdb137d4db607461dd32c46e40bee9084eb508da9 (diff)
isotests: various changes and updates
* isotests/fixtures/clockchoices.json: changed 'default' to 'unchanged' * isotests/fixtures/filesystems.json: removed 'check the installed system' line from one of the options * isotests/fixtures/modules.json: added 'ext2','ext3','ext4','swap','xfs','jfs','reiserFS' * isotests/models.py: * Added RollbackOption abstract class that adds the functions get_rollback_success_test and get_rollback_failed_test on top of the IsoOption abstract class for use with the Filesystem and Module classes since Test uses these both in 2 ways (regular and rollback). This keeps them seperated. * renamed the related names of these properties from rollback_test to rollback_test_set (seems more in-tune with the other relations) * isotests/views.py: * changed the order of the fields, the automatic order makes no sense. * Added help texts to the fields success, filesystem, rollback_filesystem and rollback_modules. * Removed help text from modules (made no sense) * Added a website field, should remain empty, a simplistic way to hopefully reduce spambot entries. * templates/isotests/results.html: * Removed the rollback yes/no section * The rollback labels should check get_rollback_success_test and get_rollback_failed_test. * Rollback checkbox removed. * Clearly tell users that success must only be selected if everything works right. * Clearly tell users to only fill in the rollback options if they did a rollback. * Added a thanks page that tells people thanks. * Added links between the pages. * Added links to lists with tests of either a specific iso or of any iso where a specific option was selected. Signed-off-by: Dan McGee <dan@archlinux.org> Conflicts: templates/isotests/results.html
Diffstat (limited to 'isotests')
-rw-r--r--isotests/fixtures/clockchoices.json2
-rw-r--r--isotests/fixtures/filesystems.json2
-rw-r--r--isotests/fixtures/modules.json49
-rw-r--r--isotests/models.py51
-rw-r--r--isotests/urls.py8
-rw-r--r--isotests/views.py64
6 files changed, 151 insertions, 25 deletions
diff --git a/isotests/fixtures/clockchoices.json b/isotests/fixtures/clockchoices.json
index 2c078128..6dfd06e1 100644
--- a/isotests/fixtures/clockchoices.json
+++ b/isotests/fixtures/clockchoices.json
@@ -3,7 +3,7 @@
"pk": 1,
"model": "isotests.clockchoice",
"fields": {
- "name": "default"
+ "name": "unchanged"
}
},
{
diff --git a/isotests/fixtures/filesystems.json b/isotests/fixtures/filesystems.json
index 4d3f1bc4..5386c391 100644
--- a/isotests/fixtures/filesystems.json
+++ b/isotests/fixtures/filesystems.json
@@ -3,7 +3,7 @@
"pk": 1,
"model": "isotests.filesystem",
"fields": {
- "name": "autoprepare (check the installed system, incl fstab)"
+ "name": "autoprepare"
}
},
{
diff --git a/isotests/fixtures/modules.json b/isotests/fixtures/modules.json
index 27d04c7a..ae8a1683 100644
--- a/isotests/fixtures/modules.json
+++ b/isotests/fixtures/modules.json
@@ -33,5 +33,54 @@
"fields": {
"name": "btrfs"
}
+ },
+ {
+ "pk": 6,
+ "model": "isotests.module",
+ "fields": {
+ "name": "ext2"
+ }
+ },
+ {
+ "pk": 7,
+ "model": "isotests.module",
+ "fields": {
+ "name": "ext3"
+ }
+ },
+ {
+ "pk": 8,
+ "model": "isotests.module",
+ "fields": {
+ "name": "ext4"
+ }
+ },
+ {
+ "pk": 9,
+ "model": "isotests.module",
+ "fields": {
+ "name": "swap"
+ }
+ },
+ {
+ "pk": 10,
+ "model": "isotests.module",
+ "fields": {
+ "name": "xfs"
+ }
+ },
+ {
+ "pk": 11,
+ "model": "isotests.module",
+ "fields": {
+ "name": "jfs"
+ }
+ },
+ {
+ "pk": 12,
+ "model": "isotests.module",
+ "fields": {
+ "name": "reiserFS"
+ }
}
]
diff --git a/isotests/models.py b/isotests/models.py
index bffb2d94..ae5bf96f 100644
--- a/isotests/models.py
+++ b/isotests/models.py
@@ -7,19 +7,49 @@ class IsoOption(models.Model):
name = models.CharField(max_length=200)
+ success_tests = None
+ failed_tests = None
+
def __unicode__(self):
return str(self.name)
def get_success_test(self):
- test = self.test_set.filter(success=True).annotate(Max('iso__id'))
- if test:
- return test[0].iso.name
+ if not self.success_tests:
+ self.success_tests = self.test_set.filter(success=True).annotate(Max('iso__id'))
+
+ if self.success_tests:
+ return self.success_tests[0].iso
return None
def get_failed_test(self):
- test = self.test_set.filter(success=False).annotate(Max('iso__id'))
- if test:
- return test[0].iso.name
+ if not self.failed_tests:
+ self.failed_tests = self.test_set.filter(success=False).annotate(Max('iso__id'))
+
+ if self.failed_tests:
+ return self.failed_tests[0].iso
+ return None
+
+class RollbackOption(IsoOption):
+ class Meta:
+ abstract = True
+
+ success_rollback_tests = None
+ failed_rollback_tests = None
+
+ def get_rollback_success_test(self):
+ if not self.success_rollback_tests:
+ self.success_rollback_tests = self.rollback_test_set.filter(success=True).annotate(Max('iso__id'))
+
+ if self.success_rollback_tests:
+ return self.success_rollback_tests[0].iso
+ return None
+
+ def get_rollback_failed_test(self):
+ if not self.failed_rollback_tests:
+ self.failed_rollback_tests = self.rollback_test_set.filter(success=False).annotate(Max('iso__id'))
+
+ if self.failed_rollback_tests:
+ return self.failed_rollback_tests[0].iso
return None
class Iso(models.Model):
@@ -50,10 +80,10 @@ class Source(IsoOption):
class ClockChoice(IsoOption):
pass
-class Filesystem(IsoOption):
+class Filesystem(RollbackOption):
pass
-class Module(IsoOption):
+class Module(RollbackOption):
pass
class Bootloader(IsoOption):
@@ -72,11 +102,10 @@ class Test(models.Model):
clock_choice = models.ForeignKey(ClockChoice)
filesystem = models.ForeignKey(Filesystem)
modules = models.ManyToManyField(Module, null=True, blank=True)
- rollback = models.BooleanField()
rollback_filesystem = models.ForeignKey(Filesystem,
- related_name="rollback_test", null=True, blank=True)
+ related_name="rollback_test_set", null=True, blank=True)
rollback_modules = models.ManyToManyField(Module,
- related_name="rollback_test", null=True, blank=True)
+ related_name="rollback_test_set", null=True, blank=True)
bootloader = models.ForeignKey(Bootloader)
success = models.BooleanField()
comments = models.TextField(null=True, blank=True)
diff --git a/isotests/urls.py b/isotests/urls.py
index f60f0bc9..7f438368 100644
--- a/isotests/urls.py
+++ b/isotests/urls.py
@@ -1,8 +1,12 @@
from django.conf.urls.defaults import patterns
urlpatterns = patterns('isotests.views',
- (r'^$', 'view_results'),
- (r'^add/$', 'add_result')
+ (r'^$', 'view_results'),
+ (r'^add/$', 'add_result'),
+ (r'^thanks/$', 'thanks'),
+ (r'^results/$', 'view_results'),
+ (r'^results/(?P<option>[a-z0-9_]+)/(?P<value>.+)/$', 'view_results_for'),
+ (r'^results/(?P<isoid>.+)/$', 'view_results_iso'),
)
# vim: set ts=4 sw=4 et:
diff --git a/isotests/views.py b/isotests/views.py
index cb7f23c5..61d95e54 100644
--- a/isotests/views.py
+++ b/isotests/views.py
@@ -1,15 +1,22 @@
-from django.http import HttpResponse, HttpResponseRedirect
+from django.forms import ModelChoiceField, CharField, TextInput
from django.forms import ModelForm, RadioSelect, CheckboxSelectMultiple
-from django.forms import ModelChoiceField
+from django.forms import ModelMultipleChoiceField, BooleanField
+from django.http import HttpResponse, HttpResponseRedirect
+from django.template import Context, loader
+from django.views.generic.simple import direct_to_template
+
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
+ fields = ("user_name", "user_email", "iso", "architecture",
+ "iso_type", "boot_type", "hardware_type",
+ "install_type", "source", "clock_choice", "filesystem",
+ "modules", "rollback_filesystem", "rollback_modules",
+ "bootloader", "success", "comments")
widgets = {
"architecture": RadioSelect(),
"iso_type": RadioSelect(),
@@ -18,20 +25,35 @@ class TestForm(ModelForm):
"install_type": RadioSelect(),
"source": RadioSelect(),
"clock_choice": RadioSelect(),
- "filesystem": RadioSelect(),
- "rollback_filesystem": RadioSelect(),
"bootloader": RadioSelect(),
"modules": CheckboxSelectMultiple(),
- "rollback_modules": CheckboxSelectMultiple(),
}
+ success = BooleanField(help_text="Only check this if everything went fine. " \
+ "If you you ran into any errors please specify them in the " \
+ "comments.", required=False)
iso = ModelChoiceField(queryset=Iso.objects.filter(active=True))
+ filesystem = ModelChoiceField(queryset=Filesystem.objects.all(),
+ help_text="Check the installed system, including fstab.",
+ widget=RadioSelect())
+ modules = ModelMultipleChoiceField(queryset=Module.objects.all(),
+ help_text="", widget=CheckboxSelectMultiple(), required=False)
+ rollback_filesystem = ModelChoiceField(queryset=Filesystem.objects.all(),
+ help_text="If you did a rollback followed by a new attempt to setup " \
+ "your lockdevices/filesystems, select which option you took here.",
+ widget=RadioSelect(), required=False)
+ rollback_modules = ModelMultipleChoiceField(queryset=Module.objects.all(),
+ help_text="If you did a rollback followed b a new attempt to setup " \
+ "your lockdevices/filesystems, select which option you took here.",
+ widget=CheckboxSelectMultiple(), required=False)
+ website = CharField(label='',
+ widget=TextInput(attrs={'style': 'display:none;'}), required=False)
def add_result(request):
- if request.method == 'POST':
+ if request.POST:
form = TestForm(request.POST)
- if form.is_valid():
+ if form.is_valid() and request.POST['website'] == '':
form.save()
- return HttpResponseRedirect('/isotests')
+ return HttpResponseRedirect('/isotests/thanks/')
else:
form = TestForm()
@@ -64,3 +86,25 @@ def view_results(request):
'bootloader_list': bootloader_list,
})
return HttpResponse(t.render(c))
+
+def view_results_iso(request, isoid):
+ iso = Iso.objects.get(pk=isoid)
+ test_list = Test.objects.filter(iso__pk=isoid)
+ context = {
+ 'iso_name': iso.name,
+ 'test_list': test_list
+ }
+ return direct_to_template(request, 'isotests/result_list.html', context)
+
+def view_results_for(request, option, value):
+ kwargs = {option: value}
+ test_list = Test.objects.filter(**kwargs).order_by("iso__name", "pk")
+ context = {
+ 'option': option,
+ 'value': value,
+ 'test_list': test_list
+ }
+ return direct_to_template(request, 'isotests/result_list.html', context)
+
+def thanks(request):
+ return direct_to_template(request, "isotests/thanks.html", None)