Merge lp:~mwhudson/lava-dashboard/use-tables-code into lp:lava-dashboard
- use-tables-code
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Zygmunt Krynicki (community) | Approve | ||
Review via email:
|
Commit message
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 : | # |
- 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
1 | === modified file 'dashboard_app/templates/dashboard_app/bundle_list.html' | |||
2 | --- dashboard_app/templates/dashboard_app/bundle_list.html 2011-12-15 16:13:43 +0000 | |||
3 | +++ dashboard_app/templates/dashboard_app/bundle_list.html 2012-03-20 21:23:20 +0000 | |||
4 | @@ -1,4 +1,6 @@ | |||
5 | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} |
6 | 2 | |||
7 | 3 | {% load django_tables2 %} | ||
8 | 2 | {% load i18n %} | 4 | {% load i18n %} |
9 | 3 | {% load humanize %} | 5 | {% load humanize %} |
10 | 4 | 6 | ||
11 | @@ -32,14 +34,6 @@ | |||
12 | 32 | </div> | 34 | </div> |
13 | 33 | <script type="text/javascript" charset="utf-8"> | 35 | <script type="text/javascript" charset="utf-8"> |
14 | 34 | $(document).ready(function() { | 36 | $(document).ready(function() { |
15 | 35 | oTable = $('#bundles').dataTable({ | ||
16 | 36 | bJQueryUI: true, | ||
17 | 37 | sPaginationType: "full_numbers", | ||
18 | 38 | aaSorting: [[4, "desc"]], | ||
19 | 39 | iDisplayLength: 25, | ||
20 | 40 | aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]], | ||
21 | 41 | sDom: 'lfr<"#master-toolbar">t<"F"ip>' | ||
22 | 42 | }); | ||
23 | 43 | // Try hard to make our radio boxes behave as links | 37 | // Try hard to make our radio boxes behave as links |
24 | 44 | $("#master-toolbar-splice span.view-as").buttonset(); | 38 | $("#master-toolbar-splice span.view-as").buttonset(); |
25 | 45 | $("#master-toolbar-splice span.view-as input").change(function(event) { | 39 | $("#master-toolbar-splice span.view-as input").change(function(event) { |
26 | @@ -56,39 +50,10 @@ | |||
27 | 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( |
28 | 57 | "padding", "5pt").css("text-align", "center"); | 51 | "padding", "5pt").css("text-align", "center"); |
29 | 58 | }); | 52 | }); |
63 | 59 | </script> | 53 | </script> |
64 | 60 | <table class="demo_jui display" id="bundles"> | 54 | |
65 | 61 | <thead> | 55 | {% render_table bundle_table %} |
66 | 62 | <tr> | 56 | |
34 | 63 | <th>{% trans "Bundle Name" %}</th> | ||
35 | 64 | <th>{% trans "Passes" %}</th> | ||
36 | 65 | <th>{% trans "Fails " %}</th> | ||
37 | 66 | <th>{% trans "Total Results" %}</th> | ||
38 | 67 | <th>{% trans "Uploaded On" %}</th> | ||
39 | 68 | <th>{% trans "Uploaded By" %}</th> | ||
40 | 69 | <th>{% trans "Deserialized?" %}</th> | ||
41 | 70 | </tr> | ||
42 | 71 | </thead> | ||
43 | 72 | <tbody> | ||
44 | 73 | {% for bundle in bundle_list %} | ||
45 | 74 | <tr> | ||
46 | 75 | <td><a href="{{ bundle.get_absolute_url }}"><code>{{ bundle.content_filename }}</code></a></td> | ||
47 | 76 | <td>{{ bundle.get_summary_results.pass }}</td> | ||
48 | 77 | <td>{{ bundle.get_summary_results.fail }}</td> | ||
49 | 78 | <td>{{ bundle.get_summary_results.total }}</td> | ||
50 | 79 | <td>{{ bundle.uploaded_on|date:"Y-m-d H:i:s"}}</td> | ||
51 | 80 | <td> | ||
52 | 81 | {% if bundle.uploaded_by %} | ||
53 | 82 | {{ bundle.uploaded_by }} | ||
54 | 83 | {% else %} | ||
55 | 84 | <em>{% trans "anonymous user" %}</em> | ||
56 | 85 | {% endif %} | ||
57 | 86 | </td> | ||
58 | 87 | <td>{{ bundle.is_deserialized|yesno }}</td> | ||
59 | 88 | </tr> | ||
60 | 89 | {% endfor %} | ||
61 | 90 | </tbody> | ||
62 | 91 | </table> | ||
67 | 92 | {% endblock %} | 57 | {% endblock %} |
68 | 93 | 58 | ||
69 | 94 | 59 | ||
70 | 95 | 60 | ||
71 | === modified file 'dashboard_app/templates/dashboard_app/bundle_stream_list.html' | |||
72 | --- dashboard_app/templates/dashboard_app/bundle_stream_list.html 2011-07-12 02:34:12 +0000 | |||
73 | +++ dashboard_app/templates/dashboard_app/bundle_stream_list.html 2012-03-20 21:23:20 +0000 | |||
74 | @@ -1,38 +1,14 @@ | |||
75 | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} |
76 | 2 | |||
77 | 3 | {% load django_tables2 %} | ||
78 | 2 | {% load i18n %} | 4 | {% load i18n %} |
79 | 3 | {% load pagination_tags %} | 5 | {% load pagination_tags %} |
80 | 4 | 6 | ||
81 | 5 | 7 | ||
82 | 6 | {% block content %} | 8 | {% block content %} |
112 | 7 | <script type="text/javascript" charset="utf-8"> | 9 | |
113 | 8 | $(document).ready(function() { | 10 | {% render_table bundle_stream_table %} |
114 | 9 | oTable = $('#bundle_streams').dataTable({ | 11 | |
86 | 10 | bJQueryUI: true, | ||
87 | 11 | sPaginationType: "full_numbers", | ||
88 | 12 | iDisplayLength: 25, | ||
89 | 13 | }); | ||
90 | 14 | }); | ||
91 | 15 | </script> | ||
92 | 16 | <table class="demo_jui display" id="bundle_streams"> | ||
93 | 17 | <thead> | ||
94 | 18 | <tr> | ||
95 | 19 | <th width="50%">Pathname</th> | ||
96 | 20 | <th>Name</th> | ||
97 | 21 | <th>Number of test runs</th> | ||
98 | 22 | <th>Number of bundles</th> | ||
99 | 23 | </tr> | ||
100 | 24 | </thead> | ||
101 | 25 | <tbody> | ||
102 | 26 | {% for bundle_stream in bundle_stream_list %} | ||
103 | 27 | <tr> | ||
104 | 28 | <td style="vertical-align: top;"><a href="{% url dashboard_app.views.bundle_list bundle_stream.pathname %}"><code>{{ bundle_stream.pathname }}</code></a></td> | ||
105 | 29 | <td>{{ bundle_stream.name|default:"<i>not set</i>" }}</td> | ||
106 | 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> | ||
107 | 31 | <td style="vertical-align: top;"><a href="{% url dashboard_app.views.bundle_list bundle_stream.pathname %}">{{ bundle_stream.bundles.count}}</a></td> | ||
108 | 32 | </tr> | ||
109 | 33 | {% endfor %} | ||
110 | 34 | </tbody> | ||
111 | 35 | </table> | ||
115 | 36 | {% endblock %} | 12 | {% endblock %} |
116 | 37 | 13 | ||
117 | 38 | 14 | ||
118 | 39 | 15 | ||
119 | === modified file 'dashboard_app/templates/dashboard_app/test_run_detail.html' | |||
120 | --- dashboard_app/templates/dashboard_app/test_run_detail.html 2011-09-27 20:58:16 +0000 | |||
121 | +++ dashboard_app/templates/dashboard_app/test_run_detail.html 2012-03-20 21:23:20 +0000 | |||
122 | @@ -1,43 +1,14 @@ | |||
123 | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} |
124 | 2 | |||
125 | 3 | {% load django_tables2 %} | ||
126 | 2 | {% load i18n %} | 4 | {% load i18n %} |
127 | 3 | {% load humanize %} | 5 | {% load humanize %} |
128 | 4 | 6 | ||
129 | 5 | 7 | ||
130 | 6 | {% block content %} | 8 | {% block content %} |
165 | 7 | <script type="text/javascript" charset="utf-8"> | 9 | |
166 | 8 | $(document).ready(function() { | 10 | {% render_table test_table %} |
167 | 9 | oTable = $('#test_results').dataTable({ | 11 | |
134 | 10 | "bJQueryUI": true, | ||
135 | 11 | "sPaginationType": "full_numbers", | ||
136 | 12 | "aaSorting": [[0, "asc"]], | ||
137 | 13 | }); | ||
138 | 14 | }); | ||
139 | 15 | </script> | ||
140 | 16 | <table class="demo_jui display" id="test_results"> | ||
141 | 17 | <thead> | ||
142 | 18 | <tr> | ||
143 | 19 | <th>#</th> | ||
144 | 20 | <th>{% trans "Test case" %}</th> | ||
145 | 21 | <th>{% trans "Result" %}</th> | ||
146 | 22 | <th>{% trans "Measurement" %}</th> | ||
147 | 23 | </tr> | ||
148 | 24 | </thead> | ||
149 | 25 | <tbody> | ||
150 | 26 | {% for test_result in test_run.get_results %} | ||
151 | 27 | <tr> | ||
152 | 28 | <td width="1%">{{ test_result.relative_index }}</td> | ||
153 | 29 | <td>{{ test_result.test_case|default_if_none:"<em>Not specified</em>" }}</td> | ||
154 | 30 | <td> | ||
155 | 31 | <a href ="{{test_result.get_absolute_url}}"> | ||
156 | 32 | <img src="{{ STATIC_URL }}dashboard_app/images/icon-{{ test_result.result_code }}.png" | ||
157 | 33 | alt="{{ test_result.get_result_display }}" width="16" height="16" border="0"/></a> | ||
158 | 34 | <a href ="{{test_result.get_absolute_url}}">{{ test_result.get_result_display }}</a> | ||
159 | 35 | </td> | ||
160 | 36 | <td>{{ test_result.measurement|default_if_none:"Not specified" }} {{ test_result.units }}</td> | ||
161 | 37 | </tr> | ||
162 | 38 | {% endfor %} | ||
163 | 39 | </tbody> | ||
164 | 40 | </table> | ||
168 | 41 | {% endblock %} | 12 | {% endblock %} |
169 | 42 | 13 | ||
170 | 43 | 14 | ||
171 | 44 | 15 | ||
172 | === modified file 'dashboard_app/templates/dashboard_app/test_run_list.html' | |||
173 | --- dashboard_app/templates/dashboard_app/test_run_list.html 2011-09-27 21:26:42 +0000 | |||
174 | +++ dashboard_app/templates/dashboard_app/test_run_list.html 2012-03-20 21:23:20 +0000 | |||
175 | @@ -1,4 +1,6 @@ | |||
176 | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} | 1 | {% extends "dashboard_app/_content_with_sidebar.html" %} |
177 | 2 | |||
178 | 3 | {% load django_tables2 %} | ||
179 | 2 | {% load i18n %} | 4 | {% load i18n %} |
180 | 3 | {% load humanize %} | 5 | {% load humanize %} |
181 | 4 | 6 | ||
182 | @@ -55,7 +57,7 @@ | |||
183 | 55 | "padding", "5pt").css("text-align", "center"); | 57 | "padding", "5pt").css("text-align", "center"); |
184 | 56 | }); | 58 | }); |
185 | 57 | </script> | 59 | </script> |
187 | 58 | {% include "dashboard_app/_test_run_list_table.html" %} | 60 | {% render_table test_run_table %} |
188 | 59 | {% endblock %} | 61 | {% endblock %} |
189 | 60 | 62 | ||
190 | 61 | 63 | ||
191 | 62 | 64 | ||
192 | === modified file 'dashboard_app/urls.py' | |||
193 | --- dashboard_app/urls.py 2011-10-06 12:03:00 +0000 | |||
194 | +++ dashboard_app/urls.py 2012-03-20 21:23:20 +0000 | |||
195 | @@ -46,16 +46,20 @@ | |||
196 | 46 | 'mapper': legacy_mapper, | 46 | 'mapper': legacy_mapper, |
197 | 47 | 'template_name': 'dashboard_app/api.html'}), | 47 | 'template_name': 'dashboard_app/api.html'}), |
198 | 48 | url(r'^streams/$', 'bundle_stream_list'), | 48 | url(r'^streams/$', 'bundle_stream_list'), |
199 | 49 | url(r'^streams/json$', 'bundle_stream_list_json'), | ||
200 | 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'), |
201 | 51 | url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)bundles/json$', 'bundle_list_table_json'), | ||
202 | 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'), |
203 | 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'), |
204 | 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'), |
205 | 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'), | ||
206 | 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'), |
207 | 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'), |
208 | 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'), |
209 | 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'), |
210 | 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'), |
211 | 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'), |
212 | 62 | url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)test-runs/json$', 'test_run_list_json'), | ||
213 | 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'), |
214 | 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'), |
215 | 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'), |
216 | 62 | 66 | ||
217 | === modified file 'dashboard_app/views.py' | |||
218 | --- dashboard_app/views.py 2011-12-15 16:13:43 +0000 | |||
219 | +++ dashboard_app/views.py 2012-03-20 21:23:20 +0000 | |||
220 | @@ -25,14 +25,24 @@ | |||
221 | 25 | 25 | ||
222 | 26 | from django.contrib.auth.decorators import login_required | 26 | from django.contrib.auth.decorators import login_required |
223 | 27 | from django.contrib.sites.models import Site | 27 | from django.contrib.sites.models import Site |
224 | 28 | from django.core.urlresolvers import reverse | ||
225 | 28 | from django.db.models.manager import Manager | 29 | from django.db.models.manager import Manager |
226 | 29 | from django.db.models.query import QuerySet | 30 | from django.db.models.query import QuerySet |
227 | 30 | from django.http import Http404, HttpResponse, HttpResponseRedirect | 31 | from django.http import Http404, HttpResponse, HttpResponseRedirect |
228 | 31 | from django.shortcuts import render_to_response, redirect, get_object_or_404 | 32 | from django.shortcuts import render_to_response, redirect, get_object_or_404 |
229 | 32 | from django.template import RequestContext, loader | 33 | from django.template import RequestContext, loader |
231 | 33 | from django.views.generic.create_update import create_object | 34 | from django.utils.safestring import mark_safe |
232 | 34 | from django.views.generic.list_detail import object_list, object_detail | 35 | from django.views.generic.list_detail import object_list, object_detail |
233 | 35 | 36 | ||
234 | 37 | from django_tables2 import Attrs, Column, TemplateColumn | ||
235 | 38 | |||
236 | 39 | from lava.utils.data_tables.tables import DataTablesTable | ||
237 | 40 | from lava_server.views import index as lava_index | ||
238 | 41 | from lava_server.bread_crumbs import ( | ||
239 | 42 | BreadCrumb, | ||
240 | 43 | BreadCrumbTrail, | ||
241 | 44 | ) | ||
242 | 45 | |||
243 | 36 | from dashboard_app.models import ( | 46 | from dashboard_app.models import ( |
244 | 37 | Attachment, | 47 | Attachment, |
245 | 38 | Bundle, | 48 | Bundle, |
246 | @@ -46,11 +56,6 @@ | |||
247 | 46 | TestRun, | 56 | TestRun, |
248 | 47 | TestingEffort, | 57 | TestingEffort, |
249 | 48 | ) | 58 | ) |
250 | 49 | from lava_server.views import index as lava_index | ||
251 | 50 | from lava_server.bread_crumbs import ( | ||
252 | 51 | BreadCrumb, | ||
253 | 52 | BreadCrumbTrail, | ||
254 | 53 | ) | ||
255 | 54 | 59 | ||
256 | 55 | 60 | ||
257 | 56 | def _get_queryset(klass): | 61 | def _get_queryset(klass): |
258 | @@ -99,6 +104,37 @@ | |||
259 | 99 | }, RequestContext(request)) | 104 | }, RequestContext(request)) |
260 | 100 | 105 | ||
261 | 101 | 106 | ||
262 | 107 | |||
263 | 108 | |||
264 | 109 | class BundleStreamTable(DataTablesTable): | ||
265 | 110 | |||
266 | 111 | pathname = TemplateColumn( | ||
267 | 112 | '<a href="{% url dashboard_app.views.bundle_list record.pathname %}">' | ||
268 | 113 | '<code>{{ record.pathname }}</code></a>') | ||
269 | 114 | name = TemplateColumn( | ||
270 | 115 | '{{ record.name|default:"<i>not set</i>" }}') | ||
271 | 116 | number_of_test_runs = TemplateColumn( | ||
272 | 117 | '<a href="{% url dashboard_app.views.test_run_list record.pathname %}">' | ||
273 | 118 | '{{ record.get_test_run_count }}') | ||
274 | 119 | number_of_bundles = TemplateColumn( | ||
275 | 120 | '<a href="{% url dashboard_app.views.bundle_list record.pathname %}">' | ||
276 | 121 | '{{ record.bundles.count}}</a>') | ||
277 | 122 | |||
278 | 123 | def get_queryset(self, user): | ||
279 | 124 | return BundleStream.objects.accessible_by_principal(user) | ||
280 | 125 | |||
281 | 126 | datatable_opts = { | ||
282 | 127 | 'iDisplayLength': 25, | ||
283 | 128 | 'sPaginationType': "full_numbers", | ||
284 | 129 | } | ||
285 | 130 | |||
286 | 131 | searchable_columns = ['pathname', 'name'] | ||
287 | 132 | |||
288 | 133 | |||
289 | 134 | def bundle_stream_list_json(request): | ||
290 | 135 | return BundleStreamTable.json(request, params=(request.user,)) | ||
291 | 136 | |||
292 | 137 | |||
293 | 102 | @BreadCrumb("Bundle Streams", parent=index) | 138 | @BreadCrumb("Bundle Streams", parent=index) |
294 | 103 | def bundle_stream_list(request): | 139 | def bundle_stream_list(request): |
295 | 104 | """ | 140 | """ |
296 | @@ -108,7 +144,9 @@ | |||
297 | 108 | 'dashboard_app/bundle_stream_list.html', { | 144 | 'dashboard_app/bundle_stream_list.html', { |
298 | 109 | 'bread_crumb_trail': BreadCrumbTrail.leading_to( | 145 | 'bread_crumb_trail': BreadCrumbTrail.leading_to( |
299 | 110 | bundle_stream_list), | 146 | bundle_stream_list), |
301 | 111 | "bundle_stream_list": BundleStream.objects.accessible_by_principal(request.user).order_by('pathname'), | 147 | "bundle_stream_table": BundleStreamTable( |
302 | 148 | 'bundle-stream-table', reverse(bundle_stream_list_json), | ||
303 | 149 | params=(request.user,)), | ||
304 | 112 | 'has_personal_streams': ( | 150 | 'has_personal_streams': ( |
305 | 113 | request.user.is_authenticated() and | 151 | request.user.is_authenticated() and |
306 | 114 | BundleStream.objects.filter(user=request.user).count() > 0), | 152 | BundleStream.objects.filter(user=request.user).count() > 0), |
307 | @@ -120,6 +158,52 @@ | |||
308 | 120 | ) | 158 | ) |
309 | 121 | 159 | ||
310 | 122 | 160 | ||
311 | 161 | class BundleTable(DataTablesTable): | ||
312 | 162 | |||
313 | 163 | content_filename = TemplateColumn( | ||
314 | 164 | '<a href="{{ record.get_absolute_url }}">' | ||
315 | 165 | '<code>{{ record.content_filename }}</code></a>', | ||
316 | 166 | verbose_name="bundle name") | ||
317 | 167 | |||
318 | 168 | passes = TemplateColumn('{{ record.get_summary_results.pass }}') | ||
319 | 169 | fails = TemplateColumn('{{ record.get_summary_results.pass }}') | ||
320 | 170 | total_results = TemplateColumn('{{ record.get_summary_results.total }}') | ||
321 | 171 | |||
322 | 172 | uploaded_on = TemplateColumn('{{ record.uploaded_on|date:"Y-m-d H:i:s"}}') | ||
323 | 173 | uploaded_by = TemplateColumn(''' | ||
324 | 174 | {% load i18n %} | ||
325 | 175 | {% if record.uploaded_by %} | ||
326 | 176 | {{ record.uploaded_by }} | ||
327 | 177 | {% else %} | ||
328 | 178 | <em>{% trans "anonymous user" %}</em> | ||
329 | 179 | {% endif %}''') | ||
330 | 180 | deserializaled = TemplateColumn('{{ record.is_deserialized|yesno }}') | ||
331 | 181 | |||
332 | 182 | def get_queryset(self, bundle_stream): | ||
333 | 183 | return bundle_stream.bundles.select_related( | ||
334 | 184 | 'bundle_stream', 'deserialization_error') | ||
335 | 185 | |||
336 | 186 | datatable_opts = { | ||
337 | 187 | 'aaSorting': [[4, 'desc']], | ||
338 | 188 | 'sPaginationType': 'full_numbers', | ||
339 | 189 | 'iDisplayLength': 25, | ||
340 | 190 | # 'aLengthMenu': [[10, 25, 50, -1], [10, 25, 50, "All"]], | ||
341 | 191 | 'sDom': 'lfr<"#master-toolbar">t<"F"ip>', | ||
342 | 192 | } | ||
343 | 193 | |||
344 | 194 | searchable_columns = ['content_filename'] | ||
345 | 195 | |||
346 | 196 | |||
347 | 197 | def bundle_list_table_json(request, pathname): | ||
348 | 198 | bundle_stream = get_restricted_object_or_404( | ||
349 | 199 | BundleStream, | ||
350 | 200 | lambda bundle_stream: bundle_stream, | ||
351 | 201 | request.user, | ||
352 | 202 | pathname=pathname | ||
353 | 203 | ) | ||
354 | 204 | return BundleTable.json(request, params=(bundle_stream,)) | ||
355 | 205 | |||
356 | 206 | |||
357 | 123 | @BreadCrumb( | 207 | @BreadCrumb( |
358 | 124 | "Bundles in {pathname}", | 208 | "Bundles in {pathname}", |
359 | 125 | parent=bundle_stream_list, | 209 | parent=bundle_stream_list, |
360 | @@ -134,18 +218,20 @@ | |||
361 | 134 | request.user, | 218 | request.user, |
362 | 135 | pathname=pathname | 219 | pathname=pathname |
363 | 136 | ) | 220 | ) |
371 | 137 | return object_list( | 221 | return render_to_response( |
372 | 138 | request, | 222 | "dashboard_app/bundle_list.html", |
373 | 139 | queryset=bundle_stream.bundles.select_related( | 223 | { |
374 | 140 | 'bundle_stream', 'deserialization_error'), | 224 | 'bundle_table': BundleTable( |
375 | 141 | template_name="dashboard_app/bundle_list.html", | 225 | 'bundle-table', |
376 | 142 | template_object_name="bundle", | 226 | reverse( |
377 | 143 | extra_context={ | 227 | bundle_list_table_json, kwargs=dict(pathname=pathname)), |
378 | 228 | params=(bundle_stream,)), | ||
379 | 144 | 'bread_crumb_trail': BreadCrumbTrail.leading_to( | 229 | 'bread_crumb_trail': BreadCrumbTrail.leading_to( |
380 | 145 | bundle_list, | 230 | bundle_list, |
381 | 146 | pathname=pathname), | 231 | pathname=pathname), |
382 | 147 | "bundle_stream": bundle_stream | 232 | "bundle_stream": bundle_stream |
384 | 148 | }) | 233 | }, |
385 | 234 | RequestContext(request)) | ||
386 | 149 | 235 | ||
387 | 150 | 236 | ||
388 | 151 | @BreadCrumb( | 237 | @BreadCrumb( |
389 | @@ -229,28 +315,28 @@ | |||
390 | 229 | RequestContext(request)) | 315 | RequestContext(request)) |
391 | 230 | 316 | ||
392 | 231 | 317 | ||
413 | 232 | @BreadCrumb( | 318 | class TestRunTable(DataTablesTable): |
414 | 233 | "Test runs in {pathname}", | 319 | |
415 | 234 | parent=bundle_stream_list, | 320 | record = TemplateColumn( |
416 | 235 | needs=['pathname']) | 321 | '<a href="{{ record.get_absolute_url }}">' |
417 | 236 | def test_run_list(request, pathname): | 322 | '<code>{{ record.test }} results<code/></a>', |
418 | 237 | """ | 323 | accessor="test__test_id", |
419 | 238 | List of test runs in a specified bundle stream. | 324 | ) |
420 | 239 | """ | 325 | |
421 | 240 | bundle_stream = get_restricted_object_or_404( | 326 | test = TemplateColumn( |
422 | 241 | BundleStream, | 327 | '<a href="{{ record.test.get_absolute_url }}">{{ record.test }}</a>', |
423 | 242 | lambda bundle_stream: bundle_stream, | 328 | accessor="test__test_id", |
424 | 243 | request.user, | 329 | ) |
425 | 244 | pathname=pathname | 330 | |
426 | 245 | ) | 331 | uploaded_on = TemplateColumn( |
427 | 246 | return render_to_response( | 332 | '{{ record.bundle.uploaded_on|date:"Y-m-d H:i:s" }}') |
428 | 247 | 'dashboard_app/test_run_list.html', { | 333 | |
429 | 248 | 'bread_crumb_trail': BreadCrumbTrail.leading_to( | 334 | analyzed_on = TemplateColumn( |
430 | 249 | test_run_list, | 335 | '{{ record.analyzer_assigned_date|date:"Y-m-d H:i:s" }}') |
431 | 250 | pathname=pathname), | 336 | |
432 | 251 | "test_run_list": TestRun.objects.filter( | 337 | def get_queryset(self, bundle_stream): |
433 | 338 | return TestRun.objects.filter( | ||
434 | 252 | bundle__bundle_stream=bundle_stream | 339 | bundle__bundle_stream=bundle_stream |
435 | 253 | ).order_by( # clean any implicit ordering | ||
436 | 254 | ).select_related( | 340 | ).select_related( |
437 | 255 | "test", | 341 | "test", |
438 | 256 | "bundle", | 342 | "bundle", |
439 | @@ -264,12 +350,94 @@ | |||
440 | 264 | "bundle__bundle_stream__pathname", # Needed by TestRun.get_absolute_url | 350 | "bundle__bundle_stream__pathname", # Needed by TestRun.get_absolute_url |
441 | 265 | "test__name", # needed by Test.__unicode__ | 351 | "test__name", # needed by Test.__unicode__ |
442 | 266 | "test__test_id", # needed by Test.__unicode__ | 352 | "test__test_id", # needed by Test.__unicode__ |
444 | 267 | ), | 353 | ) |
445 | 354 | |||
446 | 355 | datatable_opts = { | ||
447 | 356 | "sPaginationType": "full_numbers", | ||
448 | 357 | "aaSorting": [[1, "desc"]], | ||
449 | 358 | "iDisplayLength": 25, | ||
450 | 359 | "sDom": 'lfr<"#master-toolbar">t<"F"ip>' | ||
451 | 360 | } | ||
452 | 361 | |||
453 | 362 | searchable_columns = ['test__test_id'] | ||
454 | 363 | |||
455 | 364 | |||
456 | 365 | def test_run_list_json(request, pathname): | ||
457 | 366 | bundle_stream = get_restricted_object_or_404( | ||
458 | 367 | BundleStream, | ||
459 | 368 | lambda bundle_stream: bundle_stream, | ||
460 | 369 | request.user, | ||
461 | 370 | pathname=pathname | ||
462 | 371 | ) | ||
463 | 372 | return TestRunTable.json(request, params=(bundle_stream,)) | ||
464 | 373 | |||
465 | 374 | |||
466 | 375 | @BreadCrumb( | ||
467 | 376 | "Test runs in {pathname}", | ||
468 | 377 | parent=bundle_stream_list, | ||
469 | 378 | needs=['pathname']) | ||
470 | 379 | def test_run_list(request, pathname): | ||
471 | 380 | """ | ||
472 | 381 | List of test runs in a specified bundle stream. | ||
473 | 382 | """ | ||
474 | 383 | bundle_stream = get_restricted_object_or_404( | ||
475 | 384 | BundleStream, | ||
476 | 385 | lambda bundle_stream: bundle_stream, | ||
477 | 386 | request.user, | ||
478 | 387 | pathname=pathname | ||
479 | 388 | ) | ||
480 | 389 | return render_to_response( | ||
481 | 390 | 'dashboard_app/test_run_list.html', { | ||
482 | 391 | 'bread_crumb_trail': BreadCrumbTrail.leading_to( | ||
483 | 392 | test_run_list, | ||
484 | 393 | pathname=pathname), | ||
485 | 394 | "test_run_table": TestRunTable( | ||
486 | 395 | 'test-runs', | ||
487 | 396 | reverse(test_run_list_json, kwargs=dict(pathname=pathname)), | ||
488 | 397 | params=(bundle_stream,)), | ||
489 | 268 | "bundle_stream": bundle_stream, | 398 | "bundle_stream": bundle_stream, |
490 | 269 | }, RequestContext(request) | 399 | }, RequestContext(request) |
491 | 270 | ) | 400 | ) |
492 | 271 | 401 | ||
493 | 272 | 402 | ||
494 | 403 | class TestTable(DataTablesTable): | ||
495 | 404 | |||
496 | 405 | relative_index = Column( | ||
497 | 406 | verbose_name="#", attrs=Attrs(th=dict(style="width: 1%")), | ||
498 | 407 | default=mark_safe("<em>Not specified</em>")) | ||
499 | 408 | |||
500 | 409 | test_case = Column() | ||
501 | 410 | |||
502 | 411 | result = TemplateColumn(''' | ||
503 | 412 | <a href="{{record.get_absolute_url}}"> | ||
504 | 413 | <img src="{{ STATIC_URL }}dashboard_app/images/icon-{{ record.result_code }}.png" | ||
505 | 414 | alt="{{ record.get_result_display }}" width="16" height="16" border="0"/></a> | ||
506 | 415 | <a href ="{{record.get_absolute_url}}">{{ record.get_result_display }}</a> | ||
507 | 416 | ''') | ||
508 | 417 | |||
509 | 418 | units = TemplateColumn( | ||
510 | 419 | '{{ record.measurement|default_if_none:"Not specified" }} {{ record.units }}', | ||
511 | 420 | verbose_name="measurement") | ||
512 | 421 | |||
513 | 422 | def get_queryset(self, test_run): | ||
514 | 423 | return test_run.get_results() | ||
515 | 424 | |||
516 | 425 | datatable_opts = { | ||
517 | 426 | 'sPaginationType': "full_numbers", | ||
518 | 427 | } | ||
519 | 428 | |||
520 | 429 | searchable_columns = ['test_case__test_case_id'] | ||
521 | 430 | |||
522 | 431 | |||
523 | 432 | def test_run_detail_test_json(request, pathname, content_sha1, analyzer_assigned_uuid): | ||
524 | 433 | test_run = get_restricted_object_or_404( | ||
525 | 434 | TestRun, lambda test_run: test_run.bundle.bundle_stream, | ||
526 | 435 | request.user, | ||
527 | 436 | analyzer_assigned_uuid=analyzer_assigned_uuid | ||
528 | 437 | ) | ||
529 | 438 | return TestTable.json(request, params=(test_run,)) | ||
530 | 439 | |||
531 | 440 | |||
532 | 273 | @BreadCrumb( | 441 | @BreadCrumb( |
533 | 274 | "Run {analyzer_assigned_uuid}", | 442 | "Run {analyzer_assigned_uuid}", |
534 | 275 | parent=bundle_detail, | 443 | parent=bundle_detail, |
535 | @@ -288,7 +456,15 @@ | |||
536 | 288 | pathname=pathname, | 456 | pathname=pathname, |
537 | 289 | content_sha1=content_sha1, | 457 | content_sha1=content_sha1, |
538 | 290 | analyzer_assigned_uuid=analyzer_assigned_uuid), | 458 | analyzer_assigned_uuid=analyzer_assigned_uuid), |
540 | 291 | "test_run": test_run | 459 | "test_run": test_run, |
541 | 460 | "test_table": TestTable( | ||
542 | 461 | 'test-table', | ||
543 | 462 | reverse(test_run_detail_test_json, kwargs=dict( | ||
544 | 463 | pathname=pathname, | ||
545 | 464 | content_sha1=content_sha1, | ||
546 | 465 | analyzer_assigned_uuid=analyzer_assigned_uuid)), | ||
547 | 466 | params=(test_run,)) | ||
548 | 467 | |||
549 | 292 | }, RequestContext(request)) | 468 | }, RequestContext(request)) |
550 | 293 | 469 | ||
551 | 294 | 470 |
529 + print test_run
Stray debug?