def query_custom(request): # TODO: validate entity as content_type # TODO: validate conditions content_type = ContentType.objects.get( model=request.GET.get("entity"), app_label=_get_app_label_for_model(request.GET.get("entity")) ) view = QueryResultView( content_type=content_type, conditions=_parse_conditions(content_type, request.GET.get("conditions")), request=request, model=content_type.model_class(), table_class=QUERY_CONTENT_TYPE_TABLE[content_type.model] ) table = QUERY_CONTENT_TYPE_TABLE[content_type.model]( view.get_table_data() ) return render_to_response( 'lava_results_app/query_custom.html', { 'query_table': table, 'bread_crumb_trail': BreadCrumbTrail.leading_to(query_custom), 'context_help': BreadCrumbTrail.leading_to(query_list), }, RequestContext(request) )
def query_display(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) view = QueryResultView( content_type=query.content_type, conditions=query.querycondition_set.all(), request=request, model=query.content_type.model_class(), table_class=QUERY_CONTENT_TYPE_TABLE[query.content_type.model] ) table = QUERY_CONTENT_TYPE_TABLE[query.content_type.model]( view.get_table_data() ) config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) return render_to_response( 'lava_results_app/query_display.html', { 'query': query, 'entity': query.content_type.model, 'conditions': _join_conditions(query), 'query_table': table, 'terms_data': table.prepare_terms_data(view), 'search_data': table.prepare_search_data(view), 'discrete_data': table.prepare_discrete_data(view), 'bread_crumb_trail': BreadCrumbTrail.leading_to( query_display, username=username, name=name), 'context_help': BreadCrumbTrail.leading_to(query_list), }, RequestContext(request) )
def query_list(request): group_tables = {} terms_data = search_data = discrete_data = {} for group in QueryGroup.objects.all(): if group.query_set.count(): prefix = "group_%s_" % group.id group_view = GroupQueryView(request, group, model=Query, table_class=GroupQueryTable) table = GroupQueryTable(group_view.get_table_data(prefix), prefix=prefix) search_data.update(table.prepare_search_data(group_view)) discrete_data.update(table.prepare_discrete_data(group_view)) terms_data.update(table.prepare_terms_data(group_view)) group_tables[group.name] = table config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) prefix = "other_" other_view = OtherQueryView(request, model=Query, table_class=OtherQueryTable) other_query_table = OtherQueryTable(other_view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": other_query_table.length}) config.configure(other_query_table) search_data.update(other_query_table.prepare_search_data(other_view)) discrete_data.update(other_query_table.prepare_discrete_data(other_view)) terms_data.update(other_query_table.prepare_terms_data(other_view)) if request.user.is_authenticated(): prefix = "user_" view = UserQueryView(request, model=Query, table_class=UserQueryTable) user_query_table = UserQueryTable(view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": user_query_table.length}) config.configure(user_query_table) search_data.update(user_query_table.prepare_search_data(view)) discrete_data.update(user_query_table.prepare_discrete_data(view)) terms_data.update(user_query_table.prepare_terms_data(view)) else: user_query_table = None return render_to_response( 'lava_results_app/query_list.html', { 'user_query_table': user_query_table, 'other_query_table': other_query_table, 'search_data': search_data, "discrete_data": discrete_data, 'terms_data': terms_data, 'group_tables': group_tables, 'bread_crumb_trail': BreadCrumbTrail.leading_to(query_list), 'context_help': BreadCrumbTrail.leading_to(query_list), }, RequestContext(request) )
def image_report_detail(request, name): image_report = get_object_or_404(ImageReport, name=name) return render_to_response( 'dashboard_app/image_report_detail.html', { 'image_report': image_report, 'bread_crumb_trail': BreadCrumbTrail.leading_to( image_report_detail, name=name), 'context_help': BreadCrumbTrail.leading_to(image_report_list), }, RequestContext(request) )
def image_report_detail(request, name): image_report = get_object_or_404(ImageReport, name=name) template = loader.get_template('dashboard_app/image_report_detail.html') return HttpResponse(template.render( { 'image_report': image_report, 'bread_crumb_trail': BreadCrumbTrail.leading_to( image_report_detail, name=name), 'context_help': BreadCrumbTrail.leading_to(image_report_list), }, request=request) )
def chart_detail(request, name): chart = get_object_or_404(Chart, name=name) return render_to_response( 'lava_results_app/chart_detail.html', { 'chart': chart, 'chart_queries': chart.queries.all(), 'bread_crumb_trail': BreadCrumbTrail.leading_to( chart_detail, name=name), 'context_help': BreadCrumbTrail.leading_to(chart_list), }, RequestContext(request) )
def image_report_list(request): group_tables = {} terms_data = search_data = discrete_data = {} for group in ImageReportGroup.objects.all().prefetch_related("imagereport_set"): if group.imagereport_set.exists(): prefix = "group_%s_" % group.id group_view = GroupImageReportView(request, group, model=ImageReportChart, table_class=GroupImageReportTable) table = GroupImageReportTable(group_view.get_table_data(prefix), prefix=prefix) search_data.update(table.prepare_search_data(group_view)) discrete_data.update(table.prepare_discrete_data(group_view)) terms_data.update(table.prepare_terms_data(group_view)) group_tables[group.name] = table config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) prefix = "other_" other_view = OtherImageReportView(request, model=ImageReportChart, table_class=OtherImageReportTable) other_image_table = OtherImageReportTable(other_view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": other_image_table.length}) config.configure(other_image_table) search_data.update(other_image_table.prepare_search_data(other_view)) discrete_data.update(other_image_table.prepare_discrete_data(other_view)) terms_data.update(other_image_table.prepare_terms_data(other_view)) if request.user.is_authenticated(): prefix = "user_" view = UserImageReportView(request, model=ImageReportChart, table_class=UserImageReportTable) user_image_table = UserImageReportTable(view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request, paginate={"per_page": user_image_table.length}) config.configure(user_image_table) search_data.update(user_image_table.prepare_search_data(view)) discrete_data.update(user_image_table.prepare_discrete_data(view)) terms_data.update(user_image_table.prepare_terms_data(view)) else: user_image_table = None template = loader.get_template('dashboard_app/image_report_list.html') return HttpResponse(template.render( { 'user_image_table': user_image_table, 'other_image_table': other_image_table, 'search_data': search_data, "discrete_data": discrete_data, 'terms_data': terms_data, 'group_tables': group_tables, 'bread_crumb_trail': BreadCrumbTrail.leading_to(image_report_list), 'context_help': BreadCrumbTrail.leading_to(image_report_list), }, request=request) )
def query_detail(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) return render_to_response( 'lava_results_app/query_detail.html', { 'query': query, 'bread_crumb_trail': BreadCrumbTrail.leading_to( query_detail, username=username, name=name), 'context_help': BreadCrumbTrail.leading_to(query_list), 'condition_form': QueryConditionForm( request.user, instance=None, initial={'query': query, 'table': query.content_type}), }, RequestContext(request) )
def image_report_detail(request, name): image_report = get_object_or_404(ImageReport, name=name) template = loader.get_template('dashboard_app/image_report_detail.html') return HttpResponse( template.render( { 'image_report': image_report, 'bread_crumb_trail': BreadCrumbTrail.leading_to(image_report_detail, name=name), 'context_help': BreadCrumbTrail.leading_to(image_report_list), }, request=request))
def image_report_display(request, name): image_report = get_object_or_404(ImageReport, name=name) if not request.user.is_superuser: if not image_report.is_published and image_report.user != request.user: raise PermissionDenied if not image_report.is_accessible_by(request.user): raise PermissionDenied() chart_data = {} for index, chart in enumerate( image_report.imagereportchart_set.all().order_by( 'relative_index')): chart_data[index] = chart.get_chart_data(request.user) template = loader.get_template('dashboard_app/image_report_display.html') return HttpResponse(template.render( { 'image_report': image_report, 'chart_data': simplejson.dumps(chart_data), 'bread_crumb_trail': BreadCrumbTrail.leading_to( image_report_detail, name=name), }, request=request) )
def testcase(request, job, pk, case): """ Each testcase can appear multiple times in the same testsuite and testjob, the action_data.action_level distinguishes each testcase. :param request: http request object :param job: ID of the TestJob :param pk: the name of the TestSuite :param case: the name of one or more TestCase objects in the TestSuite """ test_suite = get_object_or_404(TestSuite, name=pk, job=job) job = get_restricted_job(request.user, pk=job, request=request) test_cases = TestCase.objects.filter(name=case, suite=test_suite) template = loader.get_template("lava_results_app/case.html") return HttpResponse( template.render( { 'bread_crumb_trail': BreadCrumbTrail.leading_to( testcase, pk=pk, job=job.id, case=case), 'job': job, 'suite': test_suite, 'job_link': pklink(job), 'test_cases': test_cases, 'bug_links': BugLink.objects.filter( object_id__in=test_cases.values_list('id', flat=True), content_type_id=ContentType.objects.get_for_model( TestCase).id, ) }, request=request))
def image_chart_filter_detail(request, name, id, slug): if request.method == 'POST': # Saving image chart test. chart_test = _get_image_chart_test(slug, request.POST.get('chart_test_id')) request.POST.get('attributes') chart_test.name = request.POST.get('alias') chart_test.attributes = request.POST.getlist('attributes') chart_test.save() chart_filter = get_object_or_404(ImageChartFilter, id=slug) image_chart = chart_filter.image_chart xaxis_attribute_changed = False supported_attrs = image_chart.get_supported_attributes(request.user) if image_chart.xaxis_attribute: if not supported_attrs or \ image_chart.xaxis_attribute not in supported_attrs: image_chart.xaxis_attribute = None image_chart.save() xaxis_attribute_changed = True return render_to_response( 'dashboard_app/image_chart_filter_detail.html', { 'chart_filter': chart_filter, 'xaxis_attribute_changed': xaxis_attribute_changed, 'bread_crumb_trail': BreadCrumbTrail.leading_to( image_chart_filter_detail, name=name, id=id, slug=slug), }, RequestContext(request))
def image_report_display(request, name): image_report = get_object_or_404(ImageReport, name=name) if not request.user.is_superuser: if not image_report.is_published and image_report.user != request.user: raise PermissionDenied if not image_report.is_accessible_by(request.user): raise PermissionDenied() chart_data = {} for index, chart in enumerate( image_report.imagereportchart_set.all().order_by( 'relative_index')): chart_data[index] = chart.get_chart_data(request.user) return render_to_response( 'dashboard_app/image_report_display.html', { 'image_report': image_report, 'chart_data': simplejson.dumps(chart_data), 'bread_crumb_trail': BreadCrumbTrail.leading_to(image_report_detail, name=name), }, RequestContext(request))
def suite(request, job, pk): job = get_restricted_job(request.user, pk=job, request=request) test_suite = get_object_or_404(TestSuite, name=pk, job=job) data = SuiteView(request, model=TestCase, table_class=SuiteTable) suite_table = SuiteTable( data.get_table_data().filter(suite=test_suite) ) RequestConfig(request, paginate={"per_page": suite_table.length}).configure(suite_table) template = loader.get_template("lava_results_app/suite.html") return HttpResponse(template.render( { 'bread_crumb_trail': BreadCrumbTrail.leading_to(suite, pk=pk, job=job.id), 'job': job, 'job_link': pklink(job), 'testsuite_content_type_id': ContentType.objects.get_for_model( TestSuite).id, 'suite_name': pk, 'suite_id': test_suite.id, 'suite_table': suite_table, 'bug_links': BugLink.objects.filter( object_id=test_suite.id, content_type_id=ContentType.objects.get_for_model( TestSuite).id, ) }, request=request))
def testjob(request, job): job = get_restricted_job(request.user, pk=job, request=request) data = ResultsView(request, model=TestSuite, table_class=TestJobResultsTable) suite_table = TestJobResultsTable( data.get_table_data().filter(job=job) ) failed_definitions = [] yaml_dict = OrderedDict() if TestData.objects.filter(testjob=job).exists(): # some duplicates can exist, so get would fail here and [0] is quicker than try except. testdata = TestData.objects.filter( testjob=job).prefetch_related('actionlevels__testcase', 'actionlevels__testcase__suite')[0] if job.state == TestJob.STATE_FINISHED: # returns something like ['singlenode-advanced', 'smoke-tests-basic', 'smoke-tests-basic'] executed = [ { case.action_metadata['test_definition_start']: case.action_metadata.get('success', '')} for case in TestCase.objects.filter( suite__in=TestSuite.objects.filter(job=job)) if case.action_metadata and 'test_definition_start' in case.action_metadata and case.suite.name == 'lava'] submitted = [ actiondata.testcase.action_metadata for actiondata in testdata.actionlevels.all() if actiondata.testcase and 'test-runscript-overlay' in actiondata.action_name] # compare with a dict similar to created in executed for item in submitted: if executed and {item['name']: item['success']} not in executed: comparison = {} if item['from'] != 'inline': comparison['repository'] = item['repository'] comparison['path'] = item['path'] comparison['name'] = item['name'] comparison['uuid'] = item['success'] failed_definitions.append(comparison) # hide internal python objects, like OrderedDict for data in testdata.attributes.all().order_by('name'): yaml_dict[str(data.name)] = str(data.value) RequestConfig(request, paginate={"per_page": suite_table.length}).configure(suite_table) template = loader.get_template("lava_results_app/job.html") return HttpResponse(template.render( { 'bread_crumb_trail': BreadCrumbTrail.leading_to(testjob, job=job.id), 'job': job, 'job_link': pklink(job), 'suite_table': suite_table, 'metadata': yaml_dict, 'failed_definitions': failed_definitions, 'condition_choices': simplejson.dumps( QueryCondition.get_condition_choices(job) ), 'available_content_types': simplejson.dumps( QueryCondition.get_similar_job_content_types() ), }, request=request))
def image_chart_filter_edit(request, name, id, slug): image_chart_filter = get_object_or_404(ImageChartFilter, id=slug) return image_chart_filter_form( request, BreadCrumbTrail.leading_to(image_chart_filter_edit, name=name, id=id, slug=slug), instance=image_chart_filter)
def test_run_software_context(request, pathname, content_sha1, analyzer_assigned_uuid): test_run = get_restricted_object( TestRun, lambda test_run: test_run.bundle.bundle_stream, request.user, analyzer_assigned_uuid=analyzer_assigned_uuid) 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, content_sha1=content_sha1, analyzer_assigned_uuid=analyzer_assigned_uuid), "packages": test_run.packages.all().order_by('name'), "sources": test_run.sources.all(), "half_packages_count": int(test_run.packages.count() / 2.0) }, request=request))
def query_detail(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) query_conditions = Query.serialize_conditions( query.querycondition_set.all()) template = loader.get_template('lava_results_app/query_detail.html') return HttpResponse( template.render( { 'query': query, 'query_conditions': query_conditions, 'bread_crumb_trail': BreadCrumbTrail.leading_to( query_detail, username=username, name=name), 'context_help': ['lava-queries-charts'], 'condition_form': QueryConditionForm(instance=None, initial={ 'query': query, 'table': query.content_type }), }, request=request))
def image_chart_edit(request, name, id): image_chart = get_object_or_404(ImageReportChart, id=id) return image_chart_form( request, BreadCrumbTrail.leading_to(image_chart_edit, name=name, id=id), instance=image_chart)
def pmqa_filter_view(request, pathname, device_type): test = Test.objects.get(test_id='pwrmgmt') bs = BundleStream.objects.get(pathname=pathname) filter_data = { 'bundle_streams': [bs], 'attributes': [('target.device_type', device_type)], 'tests': [{'test': test, 'test_cases': []}], 'build_number_attribute': 'build.id', } return render_to_response( "dashboard_app/pmqa_filter.html", { 'filter_table': FilterTable( "filter-table", reverse( pmqa_filter_view_json, kwargs=dict( pathname=pathname, device_type=device_type)), params=(request.user, filter_data)), 'bundle_stream': bs.slug, 'device_type': device_type, 'bread_crumb_trail': BreadCrumbTrail.leading_to( pmqa_filter_view, pathname=pathname, device_type=device_type), }, RequestContext(request))
def filters_list(request): public_view = PublicFiltersView(request, model=TestRunFilter, table_class=PublicFiltersTable) prefix = "public_" public_filters_table = PublicFiltersTable(public_view.get_table_data(prefix), prefix=prefix) config = RequestConfig(request) config.configure(public_filters_table) search_data = public_filters_table.prepare_search_data(public_view) discrete_data = public_filters_table.prepare_discrete_data(public_view) terms_data = public_filters_table.prepare_terms_data(public_view) times_data = public_filters_table.prepare_times_data(public_view) user_filters_table = None if request.user.is_authenticated(): user_view = UserFiltersView(request, model=TestRunFilter, table_class=UserFiltersTable) prefix = "user_" user_filters_table = UserFiltersTable(user_view.get_table_data(prefix), prefix=prefix) config.configure(user_filters_table) search_data.update(user_filters_table.prepare_search_data(user_view)) discrete_data.update(user_filters_table.prepare_discrete_data(user_view)) terms_data.update(user_filters_table.prepare_terms_data(user_view)) return render_to_response( "dashboard_app/filters_list.html", { "user_filters_table": user_filters_table, "public_filters_table": public_filters_table, "terms_data": terms_data, "search_data": search_data, "times_data": times_data, "discrete_data": discrete_data, "bread_crumb_trail": BreadCrumbTrail.leading_to(filters_list), }, RequestContext(request), )
def image_chart_detail(request, name, id): image_chart = get_object_or_404(ImageReportChart, id=id) xaxis_attribute_changed = False supported_attrs = image_chart.get_supported_attributes(request.user) if image_chart.xaxis_attribute: if not supported_attrs or \ image_chart.xaxis_attribute not in supported_attrs: image_chart.xaxis_attribute = None image_chart.save() xaxis_attribute_changed = True template = loader.get_template( 'dashboard_app/image_report_chart_detail.html') return HttpResponse( template.render( { 'image_chart': image_chart, 'xaxis_attribute_changed': xaxis_attribute_changed, 'bread_crumb_trail': BreadCrumbTrail.leading_to( image_chart_detail, name=name, id=id), }, request=request))
def test_result_detail(request, pathname, content_sha1, analyzer_assigned_uuid, relative_index): test_run = get_restricted_object( TestRun, lambda test_run: test_run.bundle.bundle_stream, request.user, analyzer_assigned_uuid=analyzer_assigned_uuid) try: test_result = test_run.test_results.select_related('test_run').get( relative_index=relative_index) except TestResult.DoesNotExist: raise Http404 template = get_template("dashboard_app/test_result_detail.html") return HttpResponse( template.render( { 'bread_crumb_trail': BreadCrumbTrail.leading_to( test_result_detail, pathname=pathname, content_sha1=content_sha1, analyzer_assigned_uuid=analyzer_assigned_uuid, relative_index=relative_index), "test_result": test_result }, request=request))
def test_run_detail(request, pathname, content_sha1, analyzer_assigned_uuid): job_list = [] view = TestRunDetailView(request, get_restricted_object( TestRun, lambda test_run: test_run.bundle.bundle_stream, request.user, analyzer_assigned_uuid=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", { 'bread_crumb_trail': BreadCrumbTrail.leading_to( test_run_detail, pathname=pathname, content_sha1=content_sha1, analyzer_assigned_uuid=analyzer_assigned_uuid), "test_run": view.test_run, "bundle": view.test_run.bundle, "job_list": job_list, "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), "test_table": table, }, RequestContext(request))
def image_chart_add(request, name): image_report = get_object_or_404(ImageReport, name=name) return image_chart_form( request, BreadCrumbTrail.leading_to(image_chart_add, name=name), image_report=image_report)
def query_add_condition(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) return query_condition_form( request, query, BreadCrumbTrail.leading_to(query_add))
def bundle_list(request, pathname): """ List of bundles in a specified bundle stream. """ bundle_stream = get_restricted_object( BundleStream, lambda bundle_stream: bundle_stream, request.user, pathname=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", { 'bundle_list': table, 'bread_crumb_trail': BreadCrumbTrail.leading_to( bundle_list, pathname=pathname), "terms_data": table.prepare_terms_data(data), "search_data": table.prepare_search_data(data), "discrete_data": table.prepare_discrete_data(data), "times_data": table.prepare_times_data(data), "bundle_stream": bundle_stream, }, RequestContext(request))
def test_run_list(request, pathname): """ List of test runs in a specified bundle in a bundle stream. """ bundle_stream = get_restricted_object( BundleStream, lambda bundle_stream: bundle_stream, request.user, pathname=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) )
def image_chart_filter_detail(request, name, id, slug): if request.method == 'POST': # Saving image chart test. chart_test = _get_image_chart_test( slug, request.POST.get('chart_test_id')) request.POST.get('attributes') chart_test.name = request.POST.get('alias') chart_test.attributes = request.POST.getlist('attributes') chart_test.save() chart_filter = get_object_or_404(ImageChartFilter, id=slug) image_chart = chart_filter.image_chart xaxis_attribute_changed = False supported_attrs = image_chart.get_supported_attributes(request.user) if image_chart.xaxis_attribute: if not supported_attrs or \ image_chart.xaxis_attribute not in supported_attrs: image_chart.xaxis_attribute = None image_chart.save() xaxis_attribute_changed = True template = loader.get_template('dashboard_app/image_chart_filter_detail.html') return HttpResponse(template.render( { 'chart_filter': chart_filter, 'xaxis_attribute_changed': xaxis_attribute_changed, 'bread_crumb_trail': BreadCrumbTrail.leading_to( image_chart_filter_detail, name=name, id=id, slug=slug), }, request=request) )
def image_chart_add(request, name): image_report = ImageReport.objects.get(name=name) return image_chart_form( request, BreadCrumbTrail.leading_to(image_chart_add, name=name), image_report=image_report)
def bundle_stream_list(request): """ List of bundle streams. """ data = BundleStreamView(request, model=BundleStream, table_class=BundleStreamTable) table = BundleStreamTable(data.get_table_data()) context_dict = { 'bread_crumb_trail': BreadCrumbTrail.leading_to(bundle_stream_list), "bundle_stream_table": table, "terms_data": table.prepare_terms_data(data), "search_data": table.prepare_search_data(data), "discrete_data": table.prepare_discrete_data(data), 'has_personal_streams': ( request.user.is_authenticated() and BundleStream.objects.filter(user=request.user).count() > 0), 'has_team_streams': ( request.user.is_authenticated() and BundleStream.objects.filter( group__in=request.user.groups.all()).count() > 0), } RequestConfig(request, paginate={"per_page": table.length}).configure(table) if django.VERSION > (1, 8): template = get_template('dashboard_app/bundle_stream_list.html') return HttpResponse(template.render(context_dict, request)) else: return render_to_response( 'dashboard_app/bundle_stream_list.html', context_dict, RequestContext(request) )
def test_run_list(request, pathname): """ List of test runs in a specified bundle in a bundle stream. """ bundle_stream = get_restricted_object( BundleStream, lambda bundle_stream: bundle_stream, request.user, pathname=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) 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))
def image_report_list(request): imagesets = ImageSet.objects.filter() imagesets_data = [] for imageset in imagesets: images_data = [] for image in imageset.images.all(): # Migration hack: Image.filter cannot be auto populated, so ignore # images that have not been migrated to filters for now. if image.filter: filter_data = image.filter.as_data() is_accessible = True for stream in image.filter.bundle_streams.all(): if not stream.is_accessible_by(request.user): is_accessible = False break image_data = { 'name': image.name, 'is_accessible': is_accessible, 'link': image.name, } images_data.append(image_data) images_data.sort(key=lambda d: d['name']) imageset_data = { 'name': imageset.name, 'images': images_data, } imagesets_data.append(imageset_data) imagesets_data.sort(key=lambda d: d['name']) template = loader.get_template("dashboard_app/image-reports.html") return HttpResponse(template.render( { 'bread_crumb_trail': BreadCrumbTrail.leading_to(image_report_list), 'imagesets': imagesets_data, }, request=request))
def bundle_list(request, pathname): """ List of bundles in a specified bundle stream. """ bundle_stream = get_restricted_object( BundleStream, lambda bundle_stream: bundle_stream, request.user, pathname=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) template = get_template("dashboard_app/bundle_list.html") return HttpResponse(template.render( { 'bundle_list': table, 'bread_crumb_trail': BreadCrumbTrail.leading_to( bundle_list, pathname=pathname), "terms_data": table.prepare_terms_data(data), "search_data": table.prepare_search_data(data), "discrete_data": table.prepare_discrete_data(data), "times_data": table.prepare_times_data(data), "bundle_stream": bundle_stream, }, request=request))
def suite(request, job, pk): job = get_restricted_job(request.user, pk=job, request=request) test_suite = get_object_or_404(TestSuite, name=pk, job=job) data = SuiteView(request, model=TestCase, table_class=SuiteTable) suite_table = SuiteTable(data.get_table_data().filter(suite=test_suite)) RequestConfig(request, paginate={"per_page": suite_table.length}).configure( suite_table ) template = loader.get_template("lava_results_app/suite.html") return HttpResponse( template.render( { "bread_crumb_trail": BreadCrumbTrail.leading_to( suite, pk=pk, job=job.id ), "job": job, "job_link": pklink(job), "testsuite_content_type_id": ContentType.objects.get_for_model( TestSuite ).id, "suite_name": pk, "suite_id": test_suite.id, "suite_table": suite_table, "bug_links": BugLink.objects.filter( object_id=test_suite.id, content_type_id=ContentType.objects.get_for_model(TestSuite).id, ), }, request=request, ) )
def query(request): template = loader.get_template("lava_results_app/query_list.html") return HttpResponse( template.render( {"bread_crumb_trail": BreadCrumbTrail.leading_to(index)}, request=request ) )
def suite(request, job, pk): job = get_object_or_404(TestJob, pk=job) check_request_auth(request, job) test_suite = get_object_or_404(TestSuite, name=pk, job=job) data = SuiteView(request, model=TestCase, table_class=SuiteTable) suite_table = SuiteTable(data.get_table_data().filter(suite=test_suite)) RequestConfig(request, paginate={ "per_page": suite_table.length }).configure(suite_table) template = loader.get_template("lava_results_app/suite.html") return HttpResponse( template.render( { 'bread_crumb_trail': BreadCrumbTrail.leading_to(suite, pk=pk, job=job.id), 'job': job, 'job_link': pklink(job), 'content_type_id': ContentType.objects.get_for_model(TestCase).id, 'suite_name': pk, 'suite_table': suite_table, 'bug_links': BugLink.objects.filter( object_id=test_suite.id, content_type_id=ContentType.objects.get_for_model( TestSuite).id, ) }, request=request))
def test_run_detail(request, pathname, content_sha1, analyzer_assigned_uuid): job_list = [] view = TestRunDetailView(request, get_restricted_object( TestRun, lambda test_run: test_run.bundle.bundle_stream, request.user, analyzer_assigned_uuid=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) template = get_template("dashboard_app/test_run_detail.html") return HttpResponse(template.render( { 'bread_crumb_trail': BreadCrumbTrail.leading_to( test_run_detail, pathname=pathname, content_sha1=content_sha1, analyzer_assigned_uuid=analyzer_assigned_uuid), "test_run": view.test_run, "bundle": view.test_run.bundle, "job_list": job_list, "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), "test_table": table, }, request=request))
def image_report_list(request): imagesets = ImageSet.objects.filter() imagesets_data = [] for imageset in imagesets: images_data = [] for image in imageset.images.all(): # Migration hack: Image.filter cannot be auto populated, so ignore # images that have not been migrated to filters for now. if image.filter: filter_data = image.filter.as_data() image_data = { 'name': image.name, 'bundle_count': evaluate_filter(request.user, filter_data).count(), 'link': image.name, } images_data.append(image_data) images_data.sort(key=lambda d: d['name']) imageset_data = { 'name': imageset.name, 'images': images_data, } imagesets_data.append(imageset_data) imagesets_data.sort(key=lambda d: d['name']) return render_to_response( "dashboard_app/image-reports.html", { 'bread_crumb_trail': BreadCrumbTrail.leading_to(image_report_list), 'imagesets': imagesets_data, }, RequestContext(request))
def query_detail(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) query_conditions = Query.serialize_conditions( query.querycondition_set.all()) template = loader.get_template("lava_results_app/query_detail.html") return HttpResponse( template.render( { "query": query, "query_conditions": query_conditions, "bread_crumb_trail": BreadCrumbTrail.leading_to( query_detail, username=username, name=name), "context_help": ["lava-queries-charts"], "condition_form": QueryConditionForm(instance=None, initial={ "query": query, "table": query.content_type }), }, request=request, ))
def chart_edit(request, name): chart = get_object_or_404(Chart, name=name) return chart_form( request, BreadCrumbTrail.leading_to(chart_edit, name=name), instance=chart )
def chart_query_add(request, name): chart = get_object_or_404(Chart, name=name) return chart_query_form( request, BreadCrumbTrail.leading_to(chart_query_add, name=name), chart=chart )
def chart_list(request): group_tables = {} terms_data = search_data = discrete_data = {} for group in ChartGroup.objects.all(): if group.chart_set.count(): prefix = "group_%s_" % group.id group_view = GroupChartView( request, group, model=Chart, table_class=GroupChartTable ) table = GroupChartTable( group_view.get_table_data(prefix), request=request, prefix=prefix ) search_data.update(table.prepare_search_data(group_view)) discrete_data.update(table.prepare_discrete_data(group_view)) terms_data.update(table.prepare_terms_data(group_view)) group_tables[group.name] = table config = RequestConfig(request, paginate={"per_page": table.length}) config.configure(table) prefix = "other_" other_view = OtherChartView(request, model=Chart, table_class=OtherChartTable) other_chart_table = OtherChartTable( other_view.get_table_data(prefix), request=request, prefix=prefix ) config = RequestConfig(request, paginate={"per_page": other_chart_table.length}) config.configure(other_chart_table) search_data.update(other_chart_table.prepare_search_data(other_view)) discrete_data.update(other_chart_table.prepare_discrete_data(other_view)) terms_data.update(other_chart_table.prepare_terms_data(other_view)) if request.user.is_authenticated: prefix = "user_" view = UserChartView(request, model=Chart, table_class=UserChartTable) user_chart_table = UserChartTable( view.get_table_data(prefix), request=request, prefix=prefix ) config = RequestConfig(request, paginate={"per_page": user_chart_table.length}) config.configure(user_chart_table) search_data.update(user_chart_table.prepare_search_data(view)) discrete_data.update(user_chart_table.prepare_discrete_data(view)) terms_data.update(user_chart_table.prepare_terms_data(view)) else: user_chart_table = None template = loader.get_template("lava_results_app/chart_list.html") return HttpResponse( template.render( { "user_chart_table": user_chart_table, "other_chart_table": other_chart_table, "search_data": search_data, "discrete_data": discrete_data, "terms_data": terms_data, "group_tables": group_tables, "bread_crumb_trail": BreadCrumbTrail.leading_to(chart_list), "context_help": ["lava-queries-charts"], }, request=request, ) )
def chart_display(request, name): chart = get_object_or_404(Chart, name=name) if not request.user.is_superuser: if not chart.is_published and chart.owner != request.user: raise PermissionDenied chart_data = {} for index, chart_query in enumerate( chart.chartquery_set.all().order_by("relative_index") ): chart_data[index] = chart_query.get_data(request.user) template = loader.get_template("lava_results_app/chart_display.html") return HttpResponse( template.render( { "chart": chart, "chart_data": simplejson.dumps(chart_data), "bread_crumb_trail": BreadCrumbTrail.leading_to( chart_display, name=name ), "can_admin": chart.can_admin(request.user), }, request=request, ) )
def filter_detail(request, username, name): qfilter = get_object_or_404(TestRunFilter, owner__username=username, name=name) if not request.user.is_superuser: if not qfilter.public and qfilter.owner != request.user: raise PermissionDenied() if not qfilter.is_accessible_by(request.user): raise PermissionDenied() if not request.user.is_authenticated(): subscription = None else: try: subscription = TestRunFilterSubscription.objects.get( user=request.user, filter=qfilter) except TestRunFilterSubscription.DoesNotExist: subscription = None view = FilterDetailView(request, qfilter, model=TestRun) if view.is_pass_table(): table = FilterPassTable(view.get_table_data(), match_maker=view.match_maker) else: table = FilterSummaryTable(view.get_table_data(), match_maker=view.match_maker) RequestConfig(request, paginate={"per_page": table.length}).configure(table) return render_to_response( 'dashboard_app/filter_detail.html', { 'filter': qfilter, 'subscription': subscription, 'filter_table': table, "terms_data": table.prepare_terms_data(view), "search_data": table.prepare_search_data(view), "discrete_data": table.prepare_discrete_data(view), 'bread_crumb_trail': BreadCrumbTrail.leading_to( filter_detail, name=name, username=username), }, RequestContext(request) )
def filter_subscribe(request, username, name): filter = get_object_or_404(TestRunFilter, owner__username=username, name=name) if not request.user.is_superuser: if not filter.public and filter.owner != request.user: raise PermissionDenied() try: subscription = TestRunFilterSubscription.objects.get( user=request.user, filter=filter) except TestRunFilterSubscription.DoesNotExist: subscription = None if request.method == "POST": form = TestRunFilterSubscriptionForm( filter, request.user, request.POST, instance=subscription) if form.is_valid(): if 'unsubscribe' in request.POST: subscription.delete() else: form.save() return HttpResponseRedirect(filter.get_absolute_url()) else: form = TestRunFilterSubscriptionForm( filter, request.user, instance=subscription) return render_to_response( 'dashboard_app/filter_subscribe.html', { 'filter': filter, 'form': form, 'subscription': subscription, 'bread_crumb_trail': BreadCrumbTrail.leading_to( filter_subscribe, name=name, username=username), }, RequestContext(request) )
def version(request): data = { 'bread_crumb_trail': BreadCrumbTrail.leading_to(version) } context = RequestContext(request, data) template = loader.get_template('version_details.html') return HttpResponse(template.render(context))
def chart_edit(request, name): chart = get_object_or_404(Chart, name=name) return chart_form( request, BreadCrumbTrail.leading_to(chart_edit, name=name), instance=chart)
def query_edit(request, username, name): query = get_object_or_404(Query, owner__username=username, name=name) return query_form( request, BreadCrumbTrail.leading_to(query_edit, username=username, name=name), instance=query)
def me(request): # pylint: disable=invalid-name ExtendedUser.objects.get_or_create(user=request.user) data = { 'irc_form': ExtendedUserIRCForm(instance=request.user.extendeduser), 'bread_crumb_trail': BreadCrumbTrail.leading_to( me, you=request.user.get_full_name() or request.user.username), } return render(request, 'me.html', data)
def me(request): data = { 'bread_crumb_trail': BreadCrumbTrail.leading_to( me, you=request.user.get_full_name() or request.user.username), } context = RequestContext(request, data) template = loader.get_template('me.html') return HttpResponse(template.render(context))
def query_edit_condition(request, username, name, id): query = get_object_or_404(Query, owner__username=username, name=name) query_condition = get_object_or_404(QueryCondition, id=id) return query_condition_form( request, query, BreadCrumbTrail.leading_to(query_add), instance=query_condition)
def chart_query_edit(request, name, id): chart_query = get_object_or_404(ChartQuery, id=id) return chart_query_form( request, BreadCrumbTrail.leading_to(chart_query_edit, name=name, id=id), instance=chart_query )