summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--releng/views.py54
1 files changed, 37 insertions, 17 deletions
diff --git a/releng/views.py b/releng/views.py
index a1bc3b81..67b3cb4a 100644
--- a/releng/views.py
+++ b/releng/views.py
@@ -8,11 +8,13 @@ from .models import (Architecture, BootType, Bootloader, ClockChoice,
Filesystem, HardwareType, InstallType, Iso, IsoType, Module, Source,
Test)
+
def standard_field(model, empty_label=None, help_text=None, required=True):
return forms.ModelChoiceField(queryset=model.objects.all(),
widget=forms.RadioSelect(), empty_label=empty_label,
help_text=help_text, required=required)
+
class TestForm(forms.ModelForm):
iso = forms.ModelChoiceField(queryset=Iso.objects.filter(
active=True).order_by('-id'))
@@ -24,29 +26,34 @@ class TestForm(forms.ModelForm):
source = standard_field(Source)
clock_choice = standard_field(ClockChoice)
filesystem = standard_field(Filesystem,
- help_text="Verify /etc/fstab, `df -hT` output and commands like " \
+ help_text="Verify /etc/fstab, `df -hT` output and commands like "
"lvdisplay for special modules.")
modules = forms.ModelMultipleChoiceField(queryset=Module.objects.all(),
- help_text="", widget=forms.CheckboxSelectMultiple(), required=False)
+ widget=forms.CheckboxSelectMultiple(), required=False)
bootloader = standard_field(Bootloader,
- help_text="Verify that the entries in the bootloader config looks OK.")
+ help_text="Verify that the entries in the bootloader config "
+ "looks OK.")
rollback_filesystem = standard_field(Filesystem,
- help_text="If you did a rollback followed by a new attempt to setup " \
- "your blockdevices/filesystems, select which option you took here.",
+ help_text="If you did a rollback followed by a new attempt to "
+ "setup your blockdevices/filesystems, select which option you "
+ "took here.",
empty_label="N/A (did not rollback)", required=False)
- rollback_modules = forms.ModelMultipleChoiceField(queryset=Module.objects.all(),
- help_text="If you did a rollback followed by a new attempt to setup " \
- "your blockdevices/filesystems, select which option you took here.",
+ rollback_modules = forms.ModelMultipleChoiceField(
+ queryset=Module.objects.all(),
+ help_text="If you did a rollback followed by a new attempt to "
+ "setup your blockdevices/filesystems, select which option you "
+ "took here.",
widget=forms.CheckboxSelectMultiple(), required=False)
success = forms.BooleanField(
- help_text="Only check this if everything went fine. " \
- "If you ran into problems please create a ticket on <a " \
- "href=\"https://bugs.archlinux.org/index.php?project=6\">the " \
- "bugtracker</a> (or check that one already exists) and link to " \
+ help_text="Only check this if everything went fine. "
+ "If you ran into problems please create a ticket on <a "
+ "href=\"https://bugs.archlinux.org/index.php?project=6\">the "
+ "bugtracker</a> (or check that one already exists) and link to "
"it in the comments.",
required=False)
website = forms.CharField(label='',
- widget=forms.TextInput(attrs={'style': 'display:none;'}), required=False)
+ widget=forms.TextInput(attrs={'style': 'display:none;'}),
+ required=False)
class Meta:
model = Test
@@ -59,6 +66,7 @@ class TestForm(forms.ModelForm):
"modules": forms.CheckboxSelectMultiple(),
}
+
def submit_test_result(request):
if request.POST:
form = TestForm(request.POST)
@@ -74,6 +82,7 @@ def submit_test_result(request):
context = {'form': form}
return render(request, 'releng/add.html', context)
+
def calculate_option_overview(field_name):
field = Test._meta.get_field(field_name)
model = field.rel.to
@@ -108,6 +117,7 @@ def calculate_option_overview(field_name):
return option
+
def options_fetch_iso(options):
'''Replaces the Iso PK with a full Iso model object in a list of options
used on the overview page. We do it this way to only have to query the Iso
@@ -128,13 +138,19 @@ def options_fetch_iso(options):
return options
+
def test_results_overview(request):
# data structure produced:
- # [ { option, name, is_rollback, values: [ { value, success, failure } ... ] } ... ]
+ # [ {
+ # option, name, is_rollback,
+ # values: [ { value, success, failure } ... ]
+ # }
+ # ...
+ # ]
all_options = []
- fields = [ 'architecture', 'iso_type', 'boot_type', 'hardware_type',
+ fields = ['architecture', 'iso_type', 'boot_type', 'hardware_type',
'install_type', 'source', 'clock_choice', 'filesystem', 'modules',
- 'bootloader', 'rollback_filesystem', 'rollback_modules' ]
+ 'bootloader', 'rollback_filesystem', 'rollback_modules']
for field in fields:
all_options.append(calculate_option_overview(field))
@@ -146,6 +162,7 @@ def test_results_overview(request):
}
return render(request, 'releng/results.html', context)
+
def test_results_iso(request, iso_id):
iso = get_object_or_404(Iso, pk=iso_id)
test_list = iso.test_set.select_related()
@@ -155,6 +172,7 @@ def test_results_iso(request, iso_id):
}
return render(request, 'releng/result_list.html', context)
+
def test_results_for(request, option, value):
if option not in Test._meta.get_all_field_names():
raise Http404
@@ -171,9 +189,11 @@ def test_results_for(request, option, value):
}
return render(request, 'releng/result_list.html', context)
+
def submit_test_thanks(request):
return render(request, "releng/thanks.html", None)
+
def iso_overview(request):
isos = Iso.objects.all().order_by('-pk')
successes = dict(Iso.objects.values_list('pk').filter(
@@ -186,7 +206,7 @@ def iso_overview(request):
# only show "useful" rows, currently active ISOs or those with results
isos = [iso for iso in isos if
- iso.active == True or iso.successes > 0 or iso.failures > 0]
+ iso.active is True or iso.successes > 0 or iso.failures > 0]
context = {
'isos': isos