Merge lp:~mwhudson/lava-dashboard/use-tables-code into lp:lava-dashboard

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 307
Proposed branch: lp:~mwhudson/lava-dashboard/use-tables-code
Merge into: lp:lava-dashboard
Diff against target: 549 lines (+237/-143)
6 files modified
dashboard_app/templates/dashboard_app/bundle_list.html (+6/-41)
dashboard_app/templates/dashboard_app/bundle_stream_list.html (+5/-29)
dashboard_app/templates/dashboard_app/test_run_detail.html (+5/-34)
dashboard_app/templates/dashboard_app/test_run_list.html (+3/-1)
dashboard_app/urls.py (+4/-0)
dashboard_app/views.py (+214/-38)
To merge this branch: bzr merge lp:~mwhudson/lava-dashboard/use-tables-code
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+97795@code.launchpad.net

Description of the change

This branch converts a pretty arbitrary selection of the tables in the dispatcher over to ajax tables.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

529 + print test_run

Stray debug?

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

review: Approve
312. By Michael Hudson-Doyle

remove print

313. By Michael Hudson-Doyle

merge trunk

314. By Michael Hudson-Doyle

changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dashboard_app/templates/dashboard_app/bundle_list.html'
--- dashboard_app/templates/dashboard_app/bundle_list.html 2011-12-15 16:13:43 +0000
+++ dashboard_app/templates/dashboard_app/bundle_list.html 2012-03-20 21:23:20 +0000
@@ -1,4 +1,6 @@
1{% extends "dashboard_app/_content_with_sidebar.html" %}1{% extends "dashboard_app/_content_with_sidebar.html" %}
2
3{% load django_tables2 %}
2{% load i18n %}4{% load i18n %}
3{% load humanize %}5{% load humanize %}
46
@@ -32,14 +34,6 @@
32</div>34</div>
33<script type="text/javascript" charset="utf-8"> 35<script type="text/javascript" charset="utf-8">
34 $(document).ready(function() {36 $(document).ready(function() {
35 oTable = $('#bundles').dataTable({
36 bJQueryUI: true,
37 sPaginationType: "full_numbers",
38 aaSorting: [[4, "desc"]],
39 iDisplayLength: 25,
40 aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
41 sDom: 'lfr<"#master-toolbar">t<"F"ip>'
42 });
43 // Try hard to make our radio boxes behave as links37 // Try hard to make our radio boxes behave as links
44 $("#master-toolbar-splice span.view-as").buttonset();38 $("#master-toolbar-splice span.view-as").buttonset();
45 $("#master-toolbar-splice span.view-as input").change(function(event) {39 $("#master-toolbar-splice span.view-as input").change(function(event) {
@@ -56,39 +50,10 @@
56 $("#master-toolbar").addClass("ui-widget-header ui-corner-tl ui-corner-tr").css(50 $("#master-toolbar").addClass("ui-widget-header ui-corner-tl ui-corner-tr").css(
57 "padding", "5pt").css("text-align", "center");51 "padding", "5pt").css("text-align", "center");
58 });52 });
59</script> 53</script>
60<table class="demo_jui display" id="bundles">54
61 <thead>55{% render_table bundle_table %}
62 <tr>56
63 <th>{% trans "Bundle Name" %}</th>
64 <th>{% trans "Passes" %}</th>
65 <th>{% trans "Fails " %}</th>
66 <th>{% trans "Total Results" %}</th>
67 <th>{% trans "Uploaded On" %}</th>
68 <th>{% trans "Uploaded By" %}</th>
69 <th>{% trans "Deserialized?" %}</th>
70 </tr>
71 </thead>
72 <tbody>
73 {% for bundle in bundle_list %}
74 <tr>
75 <td><a href="{{ bundle.get_absolute_url }}"><code>{{ bundle.content_filename }}</code></a></td>
76 <td>{{ bundle.get_summary_results.pass }}</td>
77 <td>{{ bundle.get_summary_results.fail }}</td>
78 <td>{{ bundle.get_summary_results.total }}</td>
79 <td>{{ bundle.uploaded_on|date:"Y-m-d H:i:s"}}</td>
80 <td>
81 {% if bundle.uploaded_by %}
82 {{ bundle.uploaded_by }}
83 {% else %}
84 <em>{% trans "anonymous user" %}</em>
85 {% endif %}
86 </td>
87 <td>{{ bundle.is_deserialized|yesno }}</td>
88 </tr>
89 {% endfor %}
90 </tbody>
91</table>
92{% endblock %}57{% endblock %}
9358
9459
9560
=== modified file 'dashboard_app/templates/dashboard_app/bundle_stream_list.html'
--- dashboard_app/templates/dashboard_app/bundle_stream_list.html 2011-07-12 02:34:12 +0000
+++ dashboard_app/templates/dashboard_app/bundle_stream_list.html 2012-03-20 21:23:20 +0000
@@ -1,38 +1,14 @@
1{% extends "dashboard_app/_content_with_sidebar.html" %}1{% extends "dashboard_app/_content_with_sidebar.html" %}
2
3{% load django_tables2 %}
2{% load i18n %}4{% load i18n %}
3{% load pagination_tags %}5{% load pagination_tags %}
46
57
6{% block content %}8{% block content %}
7<script type="text/javascript" charset="utf-8"> 9
8 $(document).ready(function() {10{% render_table bundle_stream_table %}
9 oTable = $('#bundle_streams').dataTable({11
10 bJQueryUI: true,
11 sPaginationType: "full_numbers",
12 iDisplayLength: 25,
13 });
14 });
15</script>
16<table class="demo_jui display" id="bundle_streams">
17 <thead>
18 <tr>
19 <th width="50%">Pathname</th>
20 <th>Name</th>
21 <th>Number of test runs</th>
22 <th>Number of bundles</th>
23 </tr>
24 </thead>
25 <tbody>
26 {% for bundle_stream in bundle_stream_list %}
27 <tr>
28 <td style="vertical-align: top;"><a href="{% url dashboard_app.views.bundle_list bundle_stream.pathname %}"><code>{{ bundle_stream.pathname }}</code></a></td>
29 <td>{{ bundle_stream.name|default:"<i>not set</i>" }}</td>
30 <td style="vertical-align: top;"><a href="{% url dashboard_app.views.test_run_list bundle_stream.pathname %}">{{ bundle_stream.get_test_run_count }}</a></td>
31 <td style="vertical-align: top;"><a href="{% url dashboard_app.views.bundle_list bundle_stream.pathname %}">{{ bundle_stream.bundles.count}}</a></td>
32 </tr>
33 {% endfor %}
34 </tbody>
35</table>
36{% endblock %}12{% endblock %}
3713
3814
3915
=== modified file 'dashboard_app/templates/dashboard_app/test_run_detail.html'
--- dashboard_app/templates/dashboard_app/test_run_detail.html 2011-09-27 20:58:16 +0000
+++ dashboard_app/templates/dashboard_app/test_run_detail.html 2012-03-20 21:23:20 +0000
@@ -1,43 +1,14 @@
1{% extends "dashboard_app/_content_with_sidebar.html" %}1{% extends "dashboard_app/_content_with_sidebar.html" %}
2
3{% load django_tables2 %}
2{% load i18n %}4{% load i18n %}
3{% load humanize %}5{% load humanize %}
46
57
6{% block content %}8{% block content %}
7<script type="text/javascript" charset="utf-8"> 9
8 $(document).ready(function() {10{% render_table test_table %}
9 oTable = $('#test_results').dataTable({11
10 "bJQueryUI": true,
11 "sPaginationType": "full_numbers",
12 "aaSorting": [[0, "asc"]],
13 });
14 });
15</script>
16<table class="demo_jui display" id="test_results">
17 <thead>
18 <tr>
19 <th>#</th>
20 <th>{% trans "Test case" %}</th>
21 <th>{% trans "Result" %}</th>
22 <th>{% trans "Measurement" %}</th>
23 </tr>
24 </thead>
25 <tbody>
26 {% for test_result in test_run.get_results %}
27 <tr>
28 <td width="1%">{{ test_result.relative_index }}</td>
29 <td>{{ test_result.test_case|default_if_none:"<em>Not specified</em>" }}</td>
30 <td>
31 <a href ="{{test_result.get_absolute_url}}">
32 <img src="{{ STATIC_URL }}dashboard_app/images/icon-{{ test_result.result_code }}.png"
33 alt="{{ test_result.get_result_display }}" width="16" height="16" border="0"/></a>
34 <a href ="{{test_result.get_absolute_url}}">{{ test_result.get_result_display }}</a>
35 </td>
36 <td>{{ test_result.measurement|default_if_none:"Not specified" }} {{ test_result.units }}</td>
37 </tr>
38 {% endfor %}
39 </tbody>
40</table>
41{% endblock %}12{% endblock %}
4213
4314
4415
=== modified file 'dashboard_app/templates/dashboard_app/test_run_list.html'
--- dashboard_app/templates/dashboard_app/test_run_list.html 2011-09-27 21:26:42 +0000
+++ dashboard_app/templates/dashboard_app/test_run_list.html 2012-03-20 21:23:20 +0000
@@ -1,4 +1,6 @@
1{% extends "dashboard_app/_content_with_sidebar.html" %}1{% extends "dashboard_app/_content_with_sidebar.html" %}
2
3{% load django_tables2 %}
2{% load i18n %}4{% load i18n %}
3{% load humanize %}5{% load humanize %}
46
@@ -55,7 +57,7 @@
55 "padding", "5pt").css("text-align", "center");57 "padding", "5pt").css("text-align", "center");
56 });58 });
57</script> 59</script>
58{% include "dashboard_app/_test_run_list_table.html" %}60{% render_table test_run_table %}
59{% endblock %}61{% endblock %}
6062
6163
6264
=== modified file 'dashboard_app/urls.py'
--- dashboard_app/urls.py 2011-10-06 12:03:00 +0000
+++ dashboard_app/urls.py 2012-03-20 21:23:20 +0000
@@ -46,16 +46,20 @@
46 'mapper': legacy_mapper,46 'mapper': legacy_mapper,
47 'template_name': 'dashboard_app/api.html'}),47 'template_name': 'dashboard_app/api.html'}),
48 url(r'^streams/$', 'bundle_stream_list'),48 url(r'^streams/$', 'bundle_stream_list'),
49 url(r'^streams/json$', 'bundle_stream_list_json'),
49 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/$', 'bundle_list'),50 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/$', 'bundle_list'),
51 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/json$', 'bundle_list_table_json'),
50 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/$', 'bundle_detail'),52 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/$', 'bundle_detail'),
51 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/json$', 'bundle_json'),53 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/json$', 'bundle_json'),
52 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/$', 'test_run_detail'),54 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/$', 'test_run_detail'),
55 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/json$', 'test_run_detail_test_json'),
53 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/attachments$', 'attachment_list'),56 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/attachments$', 'attachment_list'),
54 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/attachments/(?P<pk>[0-9]+)/$', 'attachment_detail'),57 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/attachments/(?P<pk>[0-9]+)/$', 'attachment_detail'),
55 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/result/(?P<relative_index>[0-9]+)/$', 'test_result_detail'),58 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/result/(?P<relative_index>[0-9]+)/$', 'test_result_detail'),
56 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/hardware-context/$', 'test_run_hardware_context'),59 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/hardware-context/$', 'test_run_hardware_context'),
57 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/software-context/$', 'test_run_software_context'),60 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/(?P<content_sha1>[0-9a-z]+)/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/software-context/$', 'test_run_software_context'),
58 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)test-runs/$', 'test_run_list'),61 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)test-runs/$', 'test_run_list'),
62 url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)test-runs/json$', 'test_run_list_json'),
59 url(r'^permalink/test-run/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/$', 'redirect_to_test_run'),63 url(r'^permalink/test-run/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/$', 'redirect_to_test_run'),
60 url(r'^permalink/test-run/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/(?P<trailing>.*)$', 'redirect_to_test_run'),64 url(r'^permalink/test-run/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/(?P<trailing>.*)$', 'redirect_to_test_run'),
61 url(r'^permalink/test-result/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/(?P<relative_index>[0-9]+)/$', 'redirect_to_test_result'),65 url(r'^permalink/test-result/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/(?P<relative_index>[0-9]+)/$', 'redirect_to_test_result'),
6266
=== modified file 'dashboard_app/views.py'
--- dashboard_app/views.py 2011-12-15 16:13:43 +0000
+++ dashboard_app/views.py 2012-03-20 21:23:20 +0000
@@ -25,14 +25,24 @@
2525
26from django.contrib.auth.decorators import login_required26from django.contrib.auth.decorators import login_required
27from django.contrib.sites.models import Site27from django.contrib.sites.models import Site
28from django.core.urlresolvers import reverse
28from django.db.models.manager import Manager29from django.db.models.manager import Manager
29from django.db.models.query import QuerySet30from django.db.models.query import QuerySet
30from django.http import Http404, HttpResponse, HttpResponseRedirect31from django.http import Http404, HttpResponse, HttpResponseRedirect
31from django.shortcuts import render_to_response, redirect, get_object_or_40432from django.shortcuts import render_to_response, redirect, get_object_or_404
32from django.template import RequestContext, loader33from django.template import RequestContext, loader
33from django.views.generic.create_update import create_object 34from django.utils.safestring import mark_safe
34from django.views.generic.list_detail import object_list, object_detail35from django.views.generic.list_detail import object_list, object_detail
3536
37from django_tables2 import Attrs, Column, TemplateColumn
38
39from lava.utils.data_tables.tables import DataTablesTable
40from lava_server.views import index as lava_index
41from lava_server.bread_crumbs import (
42 BreadCrumb,
43 BreadCrumbTrail,
44)
45
36from dashboard_app.models import (46from dashboard_app.models import (
37 Attachment,47 Attachment,
38 Bundle,48 Bundle,
@@ -46,11 +56,6 @@
46 TestRun,56 TestRun,
47 TestingEffort,57 TestingEffort,
48)58)
49from lava_server.views import index as lava_index
50from lava_server.bread_crumbs import (
51 BreadCrumb,
52 BreadCrumbTrail,
53)
5459
5560
56def _get_queryset(klass):61def _get_queryset(klass):
@@ -99,6 +104,37 @@
99 }, RequestContext(request))104 }, RequestContext(request))
100105
101106
107
108
109class BundleStreamTable(DataTablesTable):
110
111 pathname = TemplateColumn(
112 '<a href="{% url dashboard_app.views.bundle_list record.pathname %}">'
113 '<code>{{ record.pathname }}</code></a>')
114 name = TemplateColumn(
115 '{{ record.name|default:"<i>not set</i>" }}')
116 number_of_test_runs = TemplateColumn(
117 '<a href="{% url dashboard_app.views.test_run_list record.pathname %}">'
118 '{{ record.get_test_run_count }}')
119 number_of_bundles = TemplateColumn(
120 '<a href="{% url dashboard_app.views.bundle_list record.pathname %}">'
121 '{{ record.bundles.count}}</a>')
122
123 def get_queryset(self, user):
124 return BundleStream.objects.accessible_by_principal(user)
125
126 datatable_opts = {
127 'iDisplayLength': 25,
128 'sPaginationType': "full_numbers",
129 }
130
131 searchable_columns = ['pathname', 'name']
132
133
134def bundle_stream_list_json(request):
135 return BundleStreamTable.json(request, params=(request.user,))
136
137
102@BreadCrumb("Bundle Streams", parent=index)138@BreadCrumb("Bundle Streams", parent=index)
103def bundle_stream_list(request):139def bundle_stream_list(request):
104 """140 """
@@ -108,7 +144,9 @@
108 'dashboard_app/bundle_stream_list.html', {144 'dashboard_app/bundle_stream_list.html', {
109 'bread_crumb_trail': BreadCrumbTrail.leading_to(145 'bread_crumb_trail': BreadCrumbTrail.leading_to(
110 bundle_stream_list),146 bundle_stream_list),
111 "bundle_stream_list": BundleStream.objects.accessible_by_principal(request.user).order_by('pathname'),147 "bundle_stream_table": BundleStreamTable(
148 'bundle-stream-table', reverse(bundle_stream_list_json),
149 params=(request.user,)),
112 'has_personal_streams': (150 'has_personal_streams': (
113 request.user.is_authenticated() and151 request.user.is_authenticated() and
114 BundleStream.objects.filter(user=request.user).count() > 0),152 BundleStream.objects.filter(user=request.user).count() > 0),
@@ -120,6 +158,52 @@
120 )158 )
121159
122160
161class BundleTable(DataTablesTable):
162
163 content_filename = TemplateColumn(
164 '<a href="{{ record.get_absolute_url }}">'
165 '<code>{{ record.content_filename }}</code></a>',
166 verbose_name="bundle name")
167
168 passes = TemplateColumn('{{ record.get_summary_results.pass }}')
169 fails = TemplateColumn('{{ record.get_summary_results.pass }}')
170 total_results = TemplateColumn('{{ record.get_summary_results.total }}')
171
172 uploaded_on = TemplateColumn('{{ record.uploaded_on|date:"Y-m-d H:i:s"}}')
173 uploaded_by = TemplateColumn('''
174 {% load i18n %}
175 {% if record.uploaded_by %}
176 {{ record.uploaded_by }}
177 {% else %}
178 <em>{% trans "anonymous user" %}</em>
179 {% endif %}''')
180 deserializaled = TemplateColumn('{{ record.is_deserialized|yesno }}')
181
182 def get_queryset(self, bundle_stream):
183 return bundle_stream.bundles.select_related(
184 'bundle_stream', 'deserialization_error')
185
186 datatable_opts = {
187 'aaSorting': [[4, 'desc']],
188 'sPaginationType': 'full_numbers',
189 'iDisplayLength': 25,
190# 'aLengthMenu': [[10, 25, 50, -1], [10, 25, 50, "All"]],
191 'sDom': 'lfr<"#master-toolbar">t<"F"ip>',
192 }
193
194 searchable_columns = ['content_filename']
195
196
197def bundle_list_table_json(request, pathname):
198 bundle_stream = get_restricted_object_or_404(
199 BundleStream,
200 lambda bundle_stream: bundle_stream,
201 request.user,
202 pathname=pathname
203 )
204 return BundleTable.json(request, params=(bundle_stream,))
205
206
123@BreadCrumb(207@BreadCrumb(
124 "Bundles in {pathname}",208 "Bundles in {pathname}",
125 parent=bundle_stream_list,209 parent=bundle_stream_list,
@@ -134,18 +218,20 @@
134 request.user,218 request.user,
135 pathname=pathname219 pathname=pathname
136 )220 )
137 return object_list(221 return render_to_response(
138 request,222 "dashboard_app/bundle_list.html",
139 queryset=bundle_stream.bundles.select_related(223 {
140 'bundle_stream', 'deserialization_error'),224 'bundle_table': BundleTable(
141 template_name="dashboard_app/bundle_list.html",225 'bundle-table',
142 template_object_name="bundle",226 reverse(
143 extra_context={227 bundle_list_table_json, kwargs=dict(pathname=pathname)),
228 params=(bundle_stream,)),
144 'bread_crumb_trail': BreadCrumbTrail.leading_to(229 'bread_crumb_trail': BreadCrumbTrail.leading_to(
145 bundle_list,230 bundle_list,
146 pathname=pathname),231 pathname=pathname),
147 "bundle_stream": bundle_stream232 "bundle_stream": bundle_stream
148 })233 },
234 RequestContext(request))
149235
150236
151@BreadCrumb(237@BreadCrumb(
@@ -229,28 +315,28 @@
229 RequestContext(request))315 RequestContext(request))
230316
231317
232@BreadCrumb(318class TestRunTable(DataTablesTable):
233 "Test runs in {pathname}",319
234 parent=bundle_stream_list,320 record = TemplateColumn(
235 needs=['pathname'])321 '<a href="{{ record.get_absolute_url }}">'
236def test_run_list(request, pathname):322 '<code>{{ record.test }} results<code/></a>',
237 """323 accessor="test__test_id",
238 List of test runs in a specified bundle stream.324 )
239 """325
240 bundle_stream = get_restricted_object_or_404(326 test = TemplateColumn(
241 BundleStream,327 '<a href="{{ record.test.get_absolute_url }}">{{ record.test }}</a>',
242 lambda bundle_stream: bundle_stream,328 accessor="test__test_id",
243 request.user,329 )
244 pathname=pathname330
245 )331 uploaded_on = TemplateColumn(
246 return render_to_response(332 '{{ record.bundle.uploaded_on|date:"Y-m-d H:i:s" }}')
247 'dashboard_app/test_run_list.html', {333
248 'bread_crumb_trail': BreadCrumbTrail.leading_to(334 analyzed_on = TemplateColumn(
249 test_run_list,335 '{{ record.analyzer_assigned_date|date:"Y-m-d H:i:s" }}')
250 pathname=pathname),336
251 "test_run_list": TestRun.objects.filter(337 def get_queryset(self, bundle_stream):
338 return TestRun.objects.filter(
252 bundle__bundle_stream=bundle_stream339 bundle__bundle_stream=bundle_stream
253 ).order_by( # clean any implicit ordering
254 ).select_related(340 ).select_related(
255 "test",341 "test",
256 "bundle",342 "bundle",
@@ -264,12 +350,94 @@
264 "bundle__bundle_stream__pathname", # Needed by TestRun.get_absolute_url 350 "bundle__bundle_stream__pathname", # Needed by TestRun.get_absolute_url
265 "test__name", # needed by Test.__unicode__351 "test__name", # needed by Test.__unicode__
266 "test__test_id", # needed by Test.__unicode__352 "test__test_id", # needed by Test.__unicode__
267 ),353 )
354
355 datatable_opts = {
356 "sPaginationType": "full_numbers",
357 "aaSorting": [[1, "desc"]],
358 "iDisplayLength": 25,
359 "sDom": 'lfr<"#master-toolbar">t<"F"ip>'
360 }
361
362 searchable_columns = ['test__test_id']
363
364
365def test_run_list_json(request, pathname):
366 bundle_stream = get_restricted_object_or_404(
367 BundleStream,
368 lambda bundle_stream: bundle_stream,
369 request.user,
370 pathname=pathname
371 )
372 return TestRunTable.json(request, params=(bundle_stream,))
373
374
375@BreadCrumb(
376 "Test runs in {pathname}",
377 parent=bundle_stream_list,
378 needs=['pathname'])
379def test_run_list(request, pathname):
380 """
381 List of test runs in a specified bundle stream.
382 """
383 bundle_stream = get_restricted_object_or_404(
384 BundleStream,
385 lambda bundle_stream: bundle_stream,
386 request.user,
387 pathname=pathname
388 )
389 return render_to_response(
390 'dashboard_app/test_run_list.html', {
391 'bread_crumb_trail': BreadCrumbTrail.leading_to(
392 test_run_list,
393 pathname=pathname),
394 "test_run_table": TestRunTable(
395 'test-runs',
396 reverse(test_run_list_json, kwargs=dict(pathname=pathname)),
397 params=(bundle_stream,)),
268 "bundle_stream": bundle_stream,398 "bundle_stream": bundle_stream,
269 }, RequestContext(request)399 }, RequestContext(request)
270 )400 )
271401
272402
403class TestTable(DataTablesTable):
404
405 relative_index = Column(
406 verbose_name="#", attrs=Attrs(th=dict(style="width: 1%")),
407 default=mark_safe("<em>Not specified</em>"))
408
409 test_case = Column()
410
411 result = TemplateColumn('''
412 <a href="{{record.get_absolute_url}}">
413 <img src="{{ STATIC_URL }}dashboard_app/images/icon-{{ record.result_code }}.png"
414 alt="{{ record.get_result_display }}" width="16" height="16" border="0"/></a>
415 <a href ="{{record.get_absolute_url}}">{{ record.get_result_display }}</a>
416 ''')
417
418 units = TemplateColumn(
419 '{{ record.measurement|default_if_none:"Not specified" }} {{ record.units }}',
420 verbose_name="measurement")
421
422 def get_queryset(self, test_run):
423 return test_run.get_results()
424
425 datatable_opts = {
426 'sPaginationType': "full_numbers",
427 }
428
429 searchable_columns = ['test_case__test_case_id']
430
431
432def test_run_detail_test_json(request, pathname, content_sha1, analyzer_assigned_uuid):
433 test_run = get_restricted_object_or_404(
434 TestRun, lambda test_run: test_run.bundle.bundle_stream,
435 request.user,
436 analyzer_assigned_uuid=analyzer_assigned_uuid
437 )
438 return TestTable.json(request, params=(test_run,))
439
440
273@BreadCrumb(441@BreadCrumb(
274 "Run {analyzer_assigned_uuid}",442 "Run {analyzer_assigned_uuid}",
275 parent=bundle_detail,443 parent=bundle_detail,
@@ -288,7 +456,15 @@
288 pathname=pathname,456 pathname=pathname,
289 content_sha1=content_sha1,457 content_sha1=content_sha1,
290 analyzer_assigned_uuid=analyzer_assigned_uuid),458 analyzer_assigned_uuid=analyzer_assigned_uuid),
291 "test_run": test_run459 "test_run": test_run,
460 "test_table": TestTable(
461 'test-table',
462 reverse(test_run_detail_test_json, kwargs=dict(
463 pathname=pathname,
464 content_sha1=content_sha1,
465 analyzer_assigned_uuid=analyzer_assigned_uuid)),
466 params=(test_run,))
467
292 }, RequestContext(request))468 }, RequestContext(request))
293469
294470

Subscribers

People subscribed via source and target branches

to all changes: