Commit b6043723 authored by Neil Williams's avatar Neil Williams Committed by Stevan Radakovic
Browse files

Django1.10 fixes

LAVA-441 - drop render_to_response({}, RequestContext(request)
Switch to loader.get_template(), HttpResponse(template.render({}, request))
render_to_response with a RequestContext has been removed from
django1.10 and raises an exception related to the context_processor.
Drop use of SumIf and replace with conditional expressions.
Handle tightening of filters on isnull conditions when blank
is allowed for the foreignkey. (Prevents jobs starting with 1.10)

Change-Id: I59cf9caa0fe3a82027dec0caad5993cda158791b
parent 02768011
......@@ -78,6 +78,7 @@
import datetime
from django.contrib.contenttypes.models import ContentType
from django.db.models.aggregates import Aggregate
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.db import models
......@@ -90,16 +91,14 @@ from dashboard_app.models import (
TestRun,
)
# SQL Aggregates can be replaced by either of the following,
#
# Conditional Expressions:
# https://docs.djangoproject.com/en/1.8/ref/models/conditional-expressions/
#
# or
#
# Query Expressions:
# https://docs.djangoproject.com/en/1.8/ref/models/expressions/
from django.db.models.aggregates import Aggregate as SQLAggregate
class ArrayAgg(Aggregate):
function = 'ARRAY_AGG'
def convert_value(self, value, expression, connection, context):
if not value:
return []
return value
class FilterMatch(object):
......@@ -353,26 +352,6 @@ class MatchMakingQuerySet(object):
return self._makeMatches(data)
class SQLArrayAgg(SQLAggregate):
sql_function = 'array_agg'
class ArrayAgg(models.Aggregate):
name = 'ArrayAgg'
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLArrayAgg(
col, source=source, is_summary=is_summary, **self.extra)
# For way more detail than you want about what this next line is for,
# see
# http://voices.canonical.com/michael.hudson/2012/09/02/using-postgres-array_agg-from-django/
try:
aggregate.field = models.DecimalField() # vomit
except AttributeError:
pass
query.aggregates[alias] = aggregate
# given filter:
# select from testrun
# where testrun.bundle in filter.bundle_streams ^ accessible_bundles
......@@ -435,14 +414,15 @@ def evaluate_filter(user, filter_data, prefetch_related=None, descending=True):
.extra(
select={'build_number': 'convert_to_integer("dashboard_app_namedattribute"."value")', },
where=['convert_to_integer("dashboard_app_namedattribute"."value") IS NOT NULL'])\
.extra(order_by=ob,).values('build_number').annotate(ArrayAgg('id'))
.extra(order_by=ob,).values('build_number').annotate(
id__arrayagg=ArrayAgg('id'))
else:
if descending:
ob = '-bundle__uploaded_on'
else:
ob = 'bundle__uploaded_on'
testruns = testruns.order_by(ob).values(
'bundle__uploaded_on').annotate(ArrayAgg('id'))
'bundle__uploaded_on').annotate(id__arrayagg=ArrayAgg('id'))
return MatchMakingQuerySet(testruns, filter_data, prefetch_related)
......
......@@ -54,11 +54,11 @@
{% if image_report.image_report_group %}
<div id="group_link" class="group-link">
<a href="{% url 'dashboard_app.views.image_reports.views.image_report_list' %}#{{ image_report.image_report_group|iriencode }}">Group link</a>
<a href="{% url 'lava_dashboard_image_report_report_list' %}#{{ image_report.image_report_group|iriencode }}">Group link</a>
</div>
{% else %}
<div id="group_link" class="group-link" style="display: none;">
<a href="{% url 'dashboard_app.views.image_reports.views.image_report_list' %}#">Group link</a>
<a href="{% url 'lava_dashboard_image_report_report_list' %}#">Group link</a>
</div>
{% endif %}
&nbsp;&nbsp;
......@@ -144,7 +144,7 @@
$("#charts").on("sortstop", function(event, ui) {
var chart_id_order = $("#charts").sortable("toArray").join();
$.ajax({
url: "{% url 'dashboard_app.views.image_reports.views.image_report_order_update' name=image_report.name %}",
url: "{% url 'image_report_order_update' name=image_report.name %}",
type: "POST",
data: {
csrfmiddlewaretoken: '{{csrf_token}}',
......@@ -157,7 +157,7 @@
{% if image_report.is_published %}
<script>
$("#image_report_group").editable(
"{% url 'dashboard_app.views.image_reports.views.image_report_add_group' name=image_report.name %}",
"{% url 'image_report_add_group' name=image_report.name %}",
{
onblur: "submit",
width: 200,
......@@ -180,14 +180,14 @@
{% endif %}
field.select();
field.autocomplete({
source: '{% url 'dashboard_app.views.image_reports.views.image_report_group_list' %}',
source: '{% url 'image_report_group_list' %}',
minLength: 2,
});
});
$("#group").editable(
"{% url 'dashboard_app.views.image_reports.views.image_report_select_group' name=image_report.name %}",
"{% url 'image_report_select_group' name=image_report.name %}",
{
onblur: "submit",
width: 200,
......
......@@ -13,7 +13,7 @@
<h1>Image Report {{ image_report.name }}</h1>
{% if image_report.image_report_group %}
Report Group:&nbsp;&nbsp;<a href="{% url 'dashboard_app.views.image_reports.views.image_report_list' %}#{{ image_report.image_report_group|iriencode }}">{{ image_report.image_report_group }}</a>
Report Group:&nbsp;&nbsp;<a href="{% url 'lava_dashboard_image_report_report_list' %}#{{ image_report.image_report_group|iriencode }}">{{ image_report.image_report_group }}</a>
{% endif %}
{{ image_report.description|keep_spacing|linebreaks }}
......
......@@ -15,20 +15,20 @@ to build your own customized reports.</p>
<p>The dashboard stores results of tests in <em>bundles</em>. These
bundles are then grouped by a thing called <em>bundle streams</em>.
You can drill down by viewing the
<a href="{% url 'dashboard_app.views.bundle_stream_list' %}">bundle stream list</a>.
<a href="{% url 'lava_dashboard_bundle_stream_list' %}">bundle stream list</a>.
However, that view can present too much data.</p>
<p>There are two good ways to limit the data in order to see the
results you are interested in</p>
<h3 class="modal-header">Filters</h3>
<p><a href="{% url 'dashboard_app.views.filters.views.filters_list' %}">Filters</a>
<p><a href="{% url 'lava_dashboard_filters_list' %}">Filters</a>
allow you to create your own list of criteria for what you'd like to look at.
These can be created as "public" so others can use them, or private so only
you can see them.</p>
<h3 class="modal-header">Image Reports</h3>
<p><a href="{% url 'dashboard_app.views.images.image_report_list' %}">Image Reports</a>
<p><a href="{% url 'lava_dashboard_image_report_list' %}">Image Reports</a>
are a feature built on top of filters, that allow a nice view of daily jobs
that are being run in LAVA.</p>
......
......@@ -24,7 +24,7 @@
<dt>{% trans "Test Name" %} (<abbr title="This is the identifier of the test that was invoked. A test is a collection of test cases. Test is also the smallest piece of code that can be invoked by lava-test.">?</abbr>)</dt>
<dd><a href="{{ test_run.test.get_absolute_url }}">{{ test_run.test.test_id }}</a></dd>
<dt>{% trans "Test Run UUID" %} (<abbr title="This is a globally unique identifier that was assigned by the log analyzer. Running the same test multiple times results in different values of this identifier. The dashboard uses this identifier to refer to a particular test run. It is preserved across different LAVA installations, that is, if you pull test results (as bundles) from one system to another this identifier remains intact">?</abbr>)</dt>
<dd><small>{{ test_run.analyzer_assigned_uuid }}(<a href="{% url 'dashboard_app.views.redirect_to_test_run' test_run.analyzer_assigned_uuid %}">permalink</a>)</small></dd>
<dd><small>{{ test_run.analyzer_assigned_uuid }}(<a href="{% url 'lava_dashboard_redirect_to_test_run' test_run.analyzer_assigned_uuid %}">permalink</a>)</small></dd>
<dt>{% trans "Bundle SHA1" %} (<abbr title="This is the SHA1 hash of the bundle that contains this test run.">?</abbr>)</dt>
<dd><a href="{{ test_run.bundle.get_absolute_url }}"><small>{{ test_run.bundle.content_sha1 }}</small></a></dd>
<dt>{% trans "Tags" %} (<abbr title="LAVA can store tags associated with a particular test run. Tags are simple strings like &quot;project-foo-prerelase-testing&quot; or &quot;linaro-image-2011-09-27&quot;. Tags can be used by the testing effort feature to group results together.">?</abbr>)</dt>
......
......@@ -2,7 +2,8 @@
Tests for the Bundle model
"""
import hashlib
import unittest
import django
from django.core.files.base import ContentFile
from django.test import TestCase
from django_testscenarios.ubertest import TestCaseWithScenarios
......@@ -35,6 +36,7 @@ class BundleTests(TestCase, ObjectFactoryMixIn):
content = ContentFile("file content")
content_filename = "file.txt"
@unittest.skipIf(django.VERSION > (1, 10), "V1 support")
def test_construction(self):
dummy, bundle = self.make_and_get_dummy(Bundle)
bundle.content.save(bundle.content_filename, dummy.content)
......
......@@ -39,15 +39,15 @@ class BundleStreamTests(TestCaseWithScenarios):
scenarios = [
('anonymous-no-slug', {
'pathname': '/anonymous/',
'is_public': "true",
'is_anonymous': "true",
'is_public': True,
'is_anonymous': True,
'username': "user",
}),
('anonymous-with-slug', {
'name': _NAME,
'slug': _SLUG,
'is_public': "true",
'is_anonymous': "true",
'is_public': True,
'is_anonymous': True,
'pathname': '/anonymous/slug/',
'username': "user",
}),
......
......@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with Lava Dashboard. If not, see <http://www.gnu.org/licenses/>.
import django
from django.http import HttpResponseForbidden, HttpResponse
from django_testscenarios.ubertest import (TestCase, TestCaseWithScenarios)
from dashboard_app.models import BundleStream, TestRun
......@@ -106,8 +105,4 @@ class TestRunViewAuth(TestCaseWithScenarios):
content of the response is the same.
"""
response = self.client.get(self.test_run_url)
if django.VERSION > (1, 8):
self.assertIsInstance(response, HttpResponseForbidden)
else:
self.assertIsInstance(response, HttpResponse)
self.assertIn('403', response.content)
self.assertIsInstance(response, HttpResponseForbidden)
......@@ -20,7 +20,6 @@
Unit tests for dashboard_app.views.test_run_list
"""
import django
import unittest
from django.http import HttpResponseForbidden, HttpResponse
from django.contrib.auth.models import User, Group
......@@ -79,11 +78,7 @@ class TestRunListViewAnonymousTest(TestCaseWithScenarios):
if self.bundle_stream.is_accessible_by(self.user):
self.assertEqual(response.status_code, 200)
else:
if django.VERSION > (1, 8):
self.assertIsInstance(response, HttpResponseForbidden)
else:
self.assertIsInstance(response, HttpResponse)
self.assertIn('403', response.content)
self.assertIsInstance(response, HttpResponseForbidden)
def test_template_used(self):
response = self.client.get(self.url)
......@@ -91,11 +86,7 @@ class TestRunListViewAnonymousTest(TestCaseWithScenarios):
self.assertTemplateUsed(response,
"dashboard_app/test_run_list.html")
else:
if django.VERSION > (1, 8):
self.assertIsInstance(response, HttpResponseForbidden)
else:
self.assertIsInstance(response, HttpResponse)
self.assertIn('403', response.content)
self.assertIsInstance(response, HttpResponseForbidden)
class TestRunListViewAuthorizedTest(TestRunListViewAnonymousTest):
......
......@@ -121,17 +121,25 @@ urlpatterns = [
url(r'^$', index, name='lava_dashboard'),
url(r'^filters/$', filters_list, name='lava_dashboard_filters_list'),
url(r'^filters/filters_names_json$', filter_name_list_json, name='filter_name_list_json'),
url(r'^filters/\+add$', filter_add),
url(r'^filters/\+add-cases-for-test-json$', filter_add_cases_for_test_json),
url(r'^filters/\+add$', filter_add, name='dashboard_app.views.filters.views.filter_add'),
url(r'^filters/\+add-cases-for-test-json$', filter_add_cases_for_test_json,
name='dashboard_app.views.filters.views.filter_add_cases_for_test_json'),
url(r'^filters/\+get-tests-json$', get_tests_json),
url(r'^filters/\+get-test-cases-json$', get_test_cases_json),
url(r'^filters/\+attribute-name-completion-json$', filter_attr_name_completion_json),
url(r'^filters/\+attribute-value-completion-json$', filter_attr_value_completion_json),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)$', filter_detail),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+edit$', filter_edit),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+copy$', filter_copy),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+subscribe$', filter_subscribe),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+delete$', filter_delete),
url(r'^filters/\+attribute-name-completion-json$', filter_attr_name_completion_json,
name='dashboard_app.views.filters.views.filter_attr_name_completion_json'),
url(r'^filters/\+attribute-value-completion-json$', filter_attr_value_completion_json,
name='dashboard_app.views.filters.views.filter_attr_value_completion_json'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)$', filter_detail,
name='dashboard_app.views.filters.views.filter_detail'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+edit$', filter_edit,
name='dashboard_app.views.filters.views.filter_edit'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+copy$', filter_copy,
name='dashboard_app.views.filters.views.filter_copy'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+subscribe$', filter_subscribe,
name='dashboard_app.views.filters.views.filter_subscribe'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+delete$', filter_delete,
name='dashboard_app.views.filters.views.filter_delete'),
url(r'^filters/~(?P<username>[^/]+)/(?P<name>[a-zA-Z0-9-_]+)/\+compare/(?P<tag1>[a-zA-Z0-9-_: .+]+)/(?P<tag2>[a-zA-Z0-9-_: .+]+)$',
compare_matches),
url(r'^my-subscriptions$', my_subscriptions, name='lava_dashboard_my_subscriptions'),
......@@ -169,8 +177,10 @@ urlpatterns = [
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, name='lava_dashboard_test_run_software_context'),
url(r'^streams(?P<pathname>/[a-zA-Z0-9/._-]+)test-runs/$', test_run_list, name='lava_dashboard_test_run_list'),
url(r'^attachment/(?P<pk>\d+)/download$', attachment_download),
url(r'^attachment/(?P<pk>\d+)/view$', attachment_view),
url(r'^attachment/(?P<pk>\d+)/download$', attachment_download,
name='dashboard_app.views.attachment_download'),
url(r'^attachment/(?P<pk>\d+)/view$', attachment_view,
name='dashboard_app.views.attachment_view'),
url(r'^permalink/test-run/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/$', redirect_to_test_run,
name='lava_dashboard_redirect_to_test_run'),
url(r'^permalink/test-run/(?P<analyzer_assigned_uuid>[a-zA-Z0-9-]+)/(?P<trailing>.*)$', redirect_to_test_run,
......@@ -184,12 +194,14 @@ urlpatterns = [
url(r'^permalink/bundle/(?P<content_sha1>[0-9a-z]+)/(?P<trailing>.*)$', redirect_to_bundle,
name='lava_dashboard_redirect_to_bundle_trailing'),
url(r'^image-reports/$', images_report_list, name='lava_dashboard_image_report_list'),
url(r'^image-reports/(?P<name>[A-Za-z0-9_-]+)$', images_report_detail),
url(r'^image-reports/(?P<name>[A-Za-z0-9_-]+)$', images_report_detail,
name='dashboard_app.views.images.image_report_detail'),
url(r'^image-charts/$', image_report_list,
name='lava_dashboard_image_report_report_list'),
url(r'^image-charts/get-report-groups$', image_report_group_list,
name='image_report_group_list'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)$', image_report_display),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)$', image_report_display,
name='dashboard_app.views.image_reports.views.image_report_display'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+detail$', image_report_detail,
name='image_report_detail'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+add-group$', image_report_add_group,
......@@ -198,19 +210,23 @@ urlpatterns = [
name='image_report_select_group'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+order-update$', image_report_order_update,
name='image_report_order_update'),
url(r'^image-charts/\+add$', image_report_add),
url(r'^image-charts/\+add$', image_report_add,
name='dashboard_app.views.image_reports.views.image_report_add'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+edit$', image_report_edit),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+delete$', image_report_delete),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+publish$', image_report_publish),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+unpublish$', image_report_unpublish),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)$', image_chart_detail),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+add$', image_chart_add),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)$', image_chart_detail,
name='dashboard_app.views.image_reports.views.image_chart_detail'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/\+add$', image_chart_add,
name='dashboard_app.views.image_reports.views.image_chart_add'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)/\+edit$', image_chart_edit),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)/\+delete$', image_chart_delete),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)/\+settings-update$', image_chart_settings_update),
url(r'^image-charts/\+filter-type-check$', image_chart_filter_type_check),
url(r'^image-charts/\+get-chart-test$', get_chart_test_data),
url(r'^image-charts/\+get-group-names$', get_group_names),
url(r'^image-charts/\+get-group-names$', get_group_names,
name='dashboard_app.views.image_reports.views.get_group_names'),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)/\+export$', image_chart_export),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)/\+add-filter$', image_chart_filter_add),
url(r'^image-charts/(?P<name>[a-zA-Z0-9-_]+)/(?P<id>\d+)/(?P<slug>\d+)$', image_chart_filter_detail),
......
......@@ -43,7 +43,6 @@ from django.http import (
HttpResponseBadRequest,
)
from django.shortcuts import render_to_response, redirect, get_object_or_404
from django.template import RequestContext
from lava_server.views import index as lava_index
from lava_server.bread_crumbs import (
BreadCrumb,
......@@ -174,10 +173,11 @@ class SubscribedImageReportView(LavaView):
@BreadCrumb("Dashboard", parent=lava_index)
def index(request):
return render_to_response(
"dashboard_app/index.html", {
template = get_template("dashboard_app/index.html")
return HttpResponse(template.render(
{
'bread_crumb_trail': BreadCrumbTrail.leading_to(index)
}, RequestContext(request))
}, request=request))
@BreadCrumb("My Bundle Streams", parent=index)
......@@ -185,8 +185,8 @@ def mybundlestreams(request):
data = MyBundleStreamView(request, model=BundleStream, table_class=BundleStreamTable)
table = BundleStreamTable(data.get_table_data())
RequestConfig(request, paginate={"per_page": table.length}).configure(table)
return render_to_response(
"dashboard_app/mybundlestreams.html",
template = get_template("dashboard_app/mybundlestreams.html")
return HttpResponse(template.render(
{
'bread_crumb_trail': BreadCrumbTrail.leading_to(mybundlestreams),
"bundle_stream_table": table,
......@@ -194,7 +194,7 @@ def mybundlestreams(request):
"search_data": table.prepare_search_data(data),
"discrete_data": table.prepare_discrete_data(data),
},
RequestContext(request))
request=request))
@BreadCrumb("Bundle Streams", parent=index)
......@@ -273,8 +273,8 @@ def bundle_list(request, pathname):
data = BundleView(request, bundle_stream, model=Bundle, table_class=BundleTable)
table = BundleTable(data.get_table_data())
RequestConfig(request, paginate={"per_page": table.length}).configure(table)
return render_to_response(
"dashboard_app/bundle_list.html",
template = get_template("dashboard_app/bundle_list.html")
return HttpResponse(template.render(
{
'bundle_list': table,
'bread_crumb_trail': BreadCrumbTrail.leading_to(
......@@ -286,7 +286,7 @@ def bundle_list(request, pathname):
"times_data": table.prepare_times_data(data),
"bundle_stream": bundle_stream,
},
RequestContext(request))
request=request))
def _remove_dir(path):
......@@ -403,8 +403,8 @@ def bundle_detail(request, pathname, content_sha1):
view = BundleDetailView(request, pathname=pathname, content_sha1=content_sha1, model=TestRun, table_class=BundleDetailTable)
bundle_table = BundleDetailTable(view.get_table_data())
RequestConfig(request, paginate={"per_page": bundle_table.length}).configure(bundle_table)
return render_to_response(
"dashboard_app/bundle_detail.html",
template = get_template("dashboard_app/bundle_detail.html")
return HttpResponse(template.render(
{
'bundle_table': bundle_table,
'bread_crumb_trail': BreadCrumbTrail.leading_to(
......@@ -421,7 +421,7 @@ def bundle_detail(request, pathname, content_sha1):
"next_bundle": next_bundle,
"previous_bundle": previous_bundle,
},
RequestContext(request))
request=request))
def bundle_export(request, pathname, content_sha1):
......@@ -526,11 +526,12 @@ def ajax_bundle_viewer(request, pk):
request.user,
pk=pk
)
return render_to_response(
"dashboard_app/_ajax_bundle_viewer.html", {
template = get_template("dashboard_app/_ajax_bundle_viewer.html")
return HttpResponse(template.render(
{
"bundle": bundle
},
RequestContext(request))
request=request))
class TestRunView(BundleStreamView):
......@@ -576,19 +577,19 @@ def test_run_list(request, pathname):
view = TestRunView(request, bundle_stream, model=TestRun, table_class=TestRunTable)
table = TestRunTable(view.get_table_data())
RequestConfig(request, paginate={"per_page": table.length}).configure(table)
return render_to_response(
'dashboard_app/test_run_list.html', {
'bread_crumb_trail': BreadCrumbTrail.leading_to(
test_run_list,
pathname=pathname),
"test_run_table": table,
"bundle_stream": bundle_stream,
"terms_data": table.prepare_terms_data(view),
"search_data": table.prepare_search_data(view),
"discrete_data": table.prepare_discrete_data(view),
"times_data": table.prepare_times_data(view),
}, RequestContext(request)
)
template = get_template('dashboard_app/test_run_list.html')
context_dict = {
'bread_crumb_trail': BreadCrumbTrail.leading_to(
test_run_list,
pathname=pathname),
"test_run_table": table,
"bundle_stream": bundle_stream,
"terms_data": table.prepare_terms_data(view),
"search_data": table.prepare_search_data(view),
"discrete_data": table.prepare_discrete_data(view),
"times_data": table.prepare_times_data(view),
}
return HttpResponse(template.render(context_dict, request=request))
class TestRunDetailView(BundleStreamView):
......@@ -616,8 +617,9 @@ def test_run_detail(request, pathname, content_sha1, analyzer_assigned_uuid):
), analyzer_assigned_uuid, model=TestResult, table_class=TestTable)
table = TestTable(view.get_table_data())
RequestConfig(request, paginate={"per_page": table.length}).configure(table)
return render_to_response(
"dashboard_app/test_run_detail.html", {
template = get_template("dashboard_app/test_run_detail.html")
return HttpResponse(template.render(
{
'bread_crumb_trail': BreadCrumbTrail.leading_to(
test_run_detail,
pathname=pathname,
......@@ -631,7 +633,7 @@ def test_run_detail(request, pathname, content_sha1, analyzer_assigned_uuid):
"discrete_data": table.prepare_discrete_data(view),
"times_data": table.prepare_times_data(view),
"test_table": table,
}, RequestContext(request))
}, request=request))
def test_run_export(request, pathname, content_sha1, analyzer_assigned_uuid):
......@@ -697,8 +699,9 @@ def test_run_software_context(request, pathname, content_sha1, analyzer_assigned
request.user,
analyzer_assigned_uuid=analyzer_assigned_uuid
)
return render_to_response(
"dashboard_app/test_run_software_context.html", {
template = get_template("dashboard_app/test_run_software_context.html")
return HttpResponse(template.render(
{
'bread_crumb_trail': BreadCrumbTrail.leading_to(
test_run_software_context,
pathname=pathname,
......@@ -707,7 +710,7 @@ def test_run_software_context(request, pathname, content_sha1, analyzer_assigned
"packages": test_run.packages.all().order_by('name'),
"sources": test_run.sources.all(),
"half_packages_count": int(test_run.packages.count() / 2.0)
}, RequestContext(request))
}, request=request))
@BreadCrumb(
......@@ -721,15 +724,16 @@ def test_run_hardware_context(request, pathname, content_sha1, analyzer_assigned
request.user,
analyzer_assigned_uuid=analyzer_assigned_uuid
)
return render_to_response(
"dashboard_app/test_run_hardware_context.html", {
template = get_template("dashboard_app/test_run_hardware_context.html")
return HttpResponse(template.render(
{
'bread_crumb_trail': BreadCrumbTrail.leading_to(
test_run_hardware_context,
pathname=pathname,
content_sha1=content_sha1,
analyzer_assigned_uuid=analyzer_assigned_uuid),
"test_run": test_run
}, RequestContext(request))
}, request=request))
@login_required
......@@ -803,8 +807,9 @@ def test_result_detail(request, pathname, content_sha1, analyzer_assigned_uuid,
test_result = test_run.test_results.select_related('test_run').get(relative_index=relative_index)
except TestResult.DoesNotExist:
raise Http404
return render_to_response(
"dashboard_app/test_result_detail.html", {
template = get_template("dashboard_app/test_result_detail.html")
return HttpResponse(template.render(
{
'bread_crumb_trail': BreadCrumbTrail.leading_to(
test_result_detail,
pathname=pathname,
......@@ -812,7 +817,7 @@ def test_result_detail(request, pathname, content_sha1, analyzer_assigned_uuid,
analyzer_assigned_uuid=analyzer_assigned_uuid,
relative_index=relative_index),
"test_result": test_result
}, RequestContext(request))
}, request=request))
@login_required
......@@ -955,11 +960,11 @@ def attachment_view(request, pk):
return HttpResponseBadRequest("Attachment %s not viewable" % pk)
if not os.path.exists(attachment.content.path):
raise Http404("Unable to find the attachment")
return render_to_response(
"dashboard_app/attachment_view.html", {
template = get_template("dashboard_app/attachment_view.html")
return HttpResponse(template.render(
{
'attachment': attachment,
}, RequestContext(request))
}, request=request))
@BreadCrumb("Subscriptions", parent=index)
......@@ -993,9 +998,9 @@ def my_subscriptions(request):
discrete_data.update(report_table.prepare_discrete_data(report_view))
terms_data.update(report_table.prepare_terms_data(report_view))
times_data.update(report_table.prepare_times_data(report_view))
return render_to_response(
'dashboard_app/subscribed_list.html', {
template = get_template('dashboard_app/subscribed_list.html')
return HttpResponse(template.render(
{
'filters_table': filters_table,
'report_table': report_table,
"terms_data": terms_data,
......@@ -1004,7 +1009,7 @@ def my_subscriptions(request):
"discrete_data": discrete_data,
'bread_crumb_trail': BreadCrumbTrail.leading_to(
my_subscriptions),
}, RequestContext(request)
}, request=request)
)
......
......@@ -25,8 +25,7 @@ from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.http import Http404
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render_to_response