Example #1
0
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)
    )
Example #2
0
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)
    )
Example #3
0
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)
    )
Example #4
0
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)
    )
Example #5
0
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)
    )
Example #6
0
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))
Example #7
0
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))
Example #8
0
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))
Example #9
0
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))
Example #10
0
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))
Example #11
0
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),
    )
Example #12
0
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)
Example #13
0
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)
    )
Example #14
0
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)
    )
Example #15
0
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))
Example #16
0
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))
Example #17
0
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)
Example #18
0
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)
    )
Example #19
0
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))
Example #20
0
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))
Example #21
0
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)
        )
Example #22
0
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)
    )
Example #23
0
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)
Example #24
0
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)
Example #25
0
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)
Example #26
0
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)
Example #27
0
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))
Example #28
0
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)
Example #29
0
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)
Example #30
0
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
    )
Example #31
0
File: views.py Project: ivoire/lava
def tokens(request):
    """
    List of tokens for an authenticated user
    """
    token_list = AuthToken.objects.filter(
        user=request.user).order_by("last_used_on")
    unused = AuthToken.objects.filter(user=request.user,
                                      last_used_on__isnull=True).count()
    return render(
        request,
        "linaro_django_xmlrpc/tokens.html",
        {
            "token_list": token_list,
            "unused": unused,
            "bread_crumb_trail": BreadCrumbTrail.leading_to(tokens),
            "context_help": ["first_steps"],
        },
    )
Example #32
0
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
    )
    test_result = test_run.test_results.select_related('fig').get(relative_index=relative_index)
    return render_to_response(
        "dashboard_app/test_result_detail.html", {
            '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
        }, RequestContext(request))
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
    )
    return render_to_response(
        "dashboard_app/test_run_software_context.html", {
            '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)
        }, RequestContext(request))
Example #34
0
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)
    )
Example #35
0
def my_subscriptions(request):

    prefix = "filter_"
    filter_view = SubscribedFiltersView(request,
                                        model=TestRunFilter,
                                        table_class=PublicFiltersTable)
    filters_table = PublicFiltersTable(request.user,
                                       filter_view.get_table_data(prefix),
                                       prefix=prefix)
    config = RequestConfig(request)
    config.configure(filters_table)

    search_data = filters_table.prepare_search_data(filter_view)
    discrete_data = filters_table.prepare_discrete_data(filter_view)
    terms_data = filters_table.prepare_terms_data(filter_view)
    times_data = filters_table.prepare_times_data(filter_view)

    prefix = "report_"
    report_view = SubscribedImageReportView(request,
                                            model=ImageReportChart,
                                            table_class=UserImageReportTable)
    report_table = UserImageReportTable(report_view.get_table_data(prefix),
                                        prefix=prefix)
    config = RequestConfig(request)
    config.configure(report_table)

    search_data.update(report_table.prepare_search_data(report_view))
    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))
    template = get_template('dashboard_app/subscribed_list.html')
    return HttpResponse(
        template.render(
            {
                'filters_table': filters_table,
                'report_table': report_table,
                "terms_data": terms_data,
                "search_data": search_data,
                "times_data": times_data,
                "discrete_data": discrete_data,
                'bread_crumb_trail':
                BreadCrumbTrail.leading_to(my_subscriptions),
            },
            request=request))
Example #36
0
def index(request):
    data = ResultsView(request, model=TestSuite, table_class=ResultsTable)
    result_table = ResultsIndexTable(data.get_table_data())
    RequestConfig(request,
                  paginate={
                      "per_page": result_table.length,
                      **djt2_paginator_class()
                  }).configure(result_table)
    template = loader.get_template("lava_results_app/index.html")
    return HttpResponse(
        template.render(
            {
                "bread_crumb_trail": BreadCrumbTrail.leading_to(index),
                "content_type_id":
                ContentType.objects.get_for_model(TestSuite).id,
                "result_table": result_table,
            },
            request=request,
        ))
Example #37
0
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))
Example #38
0
def filter_delete(request, username, name):
    if not request.user.is_superuser:
        if request.user.username != username:
            raise PermissionDenied()
    filter = TestRunFilter.objects.get(owner__username=username, name=name)
    if request.method == "POST":
        if 'yes' in request.POST:
            filter.delete()
            return HttpResponseRedirect(reverse(filters_list))
        else:
            return HttpResponseRedirect(filter.get_absolute_url())
    return render_to_response(
        'dashboard_app/filter_delete.html', {
            'bread_crumb_trail':
            BreadCrumbTrail.leading_to(
                filter_delete, name=name, username=username),
            'filter':
            filter,
        }, RequestContext(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 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))
Example #40
0
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)
    template = loader.get_template('dashboard_app/filter_subscribe.html')
    return HttpResponse(
        template.render(
            {
                'filter':
                filter,
                'form':
                form,
                'subscription':
                subscription,
                'bread_crumb_trail':
                BreadCrumbTrail.leading_to(
                    filter_subscribe, name=name, username=username),
            },
            request=request))
Example #41
0
def filters_list(request):
    public_view = PublicFiltersView(request,
                                    model=TestRunFilter,
                                    table_class=PublicFiltersTable)
    prefix = "public_"
    public_filters_table = PublicFiltersTable(
        request.user, 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(request.user,
                                              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))
    template = loader.get_template('dashboard_app/filters_list.html')
    return HttpResponse(
        template.render(
            {
                '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),
            },
            request=request))
Example #42
0
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),
                                      request=request)
    failed_definitions = []
    yaml_dict = OrderedDict()
    with contextlib.suppress(TestData.DoesNotExist):
        # some duplicates can exist, so get would fail here and [0] is quicker than try except.
        testdata = TestData.objects.filter(testjob=job)[0]

        # 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,
                "condition_choices":
                simplejson.dumps(QueryCondition.get_condition_choices(job)),
                "available_content_types":
                simplejson.dumps(
                    QueryCondition.get_similar_job_content_types()),
            },
            request=request,
        ))
Example #43
0
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_object_or_404(TestJob, pk=job)
    test_cases = TestCase.objects.filter(name=case, suite=test_suite)
    return render_to_response(
        "lava_results_app/case.html", {
            '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,
        }, 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

    chart_data = {}
    for chart in image_report.imagereportchart_set.all():
        chart_data[chart.id] = 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)
    )
Example #45
0
def compare_pmqa_results(request, pathname, device_type, build1, build2):
    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',
    }
    test_run_info = compare_filter_matches(request.user, filter_data, build1, build2)
    return render_to_response(
        "dashboard_app/filter_compare_matches.html", {
            'test_run_info': test_run_info,
            'bread_crumb_trail': BreadCrumbTrail.leading_to(
                compare_pmqa_results,
                pathname=pathname,
                device_type=device_type,
                build1=build1,
                build2=build2),
        }, RequestContext(request))
Example #46
0
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)
    template = get_template("dashboard_app/mybundlestreams.html")
    return HttpResponse(
        template.render(
            {
                'bread_crumb_trail':
                BreadCrumbTrail.leading_to(mybundlestreams),
                "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),
            },
            request=request))
def compare_matches(request, username, name, tag1, tag2):
    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()
    filter_data = filter.as_data()
    test_run_info = compare_filter_matches(request, filter_data, tag1, tag2)
    return render_to_response(
        "dashboard_app/filter_compare_matches.html", {
            'test_run_info':
            test_run_info,
            'bread_crumb_trail':
            BreadCrumbTrail.leading_to(compare_matches,
                                       name=name,
                                       username=username,
                                       tag1=tag1,
                                       tag2=tag2),
        }, RequestContext(request))
Example #48
0
def testset(request, job, ts, pk, case):
    job = get_restricted_job(request.user, pk=job, request=request)
    test_suite = get_object_or_404(TestSuite, name=pk, job=job)
    test_set = get_object_or_404(TestSet, name=ts, suite=test_suite)
    test_cases = TestCase.objects.filter(name=case, test_set=test_set)
    template = loader.get_template("lava_results_app/case.html")
    return HttpResponse(
        template.render(
            {
                "bread_crumb_trail": BreadCrumbTrail.leading_to(
                    testset, pk=pk, job=job.id, ts=ts, case=case
                ),
                "job": job,
                "suite": test_suite,
                "job_link": pklink(job),
                "test_cases": test_cases,
            },
            request=request,
        )
    )
Example #49
0
def test_run_hardware_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_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
            },
            request=request))
Example #50
0
File: views.py Project: slawr/lava
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,
        )
    )
Example #51
0
def suite(request, job, pk):
    job = get_object_or_404(TestJob, pk=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)
    return render_to_response(
        "lava_results_app/suite.html", {
            'bread_crumb_trail':
            BreadCrumbTrail.leading_to(suite, pk=pk, job=job.id),
            'job':
            job,
            'job_link':
            pklink(job),
            'suite_name':
            pk,
            'suite_table':
            suite_table,
        }, RequestContext(request))
Example #52
0
def compare_matches(request, username, name, tag1, tag2):
    try:
        filter = TestRunFilter.objects.get(owner__username=username, name=name)
    except TestRunFilter.DoesNotExist:
        raise Http404("Filter ~%s/%s not found." % (username, name))
    if not request.user.is_superuser:
        if not filter.public and filter.owner != request.user:
            raise PermissionDenied()
    filter_data = filter.as_data()
    test_run_info = compare_filter_matches(request, filter_data, tag1, tag2)
    return render_to_response(
        "dashboard_app/filter_compare_matches.html", {
            'test_run_info':
            test_run_info,
            'bread_crumb_trail':
            BreadCrumbTrail.leading_to(compare_matches,
                                       name=name,
                                       username=username,
                                       tag1=tag1,
                                       tag2=tag2),
        }, RequestContext(request))
Example #53
0
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

    return render_to_response(
        'dashboard_app/image_report_chart_detail.html', {
            'image_chart':
            image_chart,
            'xaxis_attribute_changed':
            xaxis_attribute_changed,
            'bread_crumb_trail':
            BreadCrumbTrail.leading_to(image_chart_detail, name=name, id=id),
        }, RequestContext(request))
Example #54
0
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),
                                      request=request)
    failed_definitions = []
    yaml_dict = OrderedDict()

    if hasattr(job, "testdata"):
        for data in job.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,
                "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_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)

    return render_to_response(
        'dashboard_app/image_chart_filter_detail.html', {
            'chart_filter': chart_filter,
            'bread_crumb_trail': BreadCrumbTrail.leading_to(
                image_chart_filter_detail, name=name, id=id, slug=slug),
        }, RequestContext(request)
    )
Example #56
0
def query_custom(request):

    content_type = Query.get_content_type(request.GET.get("entity"))

    if content_type.model_class() not in QueryCondition.RELATION_MAP:
        raise InvalidContentTypeError(
            "Wrong table name in entity param. Please refer to query docs.")

    conditions = Query.parse_conditions(content_type,
                                        request.GET.get("conditions"))
    view = QueryCustomResultView(
        content_type=content_type,
        conditions=conditions,
        request=request,
        model=content_type.model_class(),
        table_class=QUERY_CONTENT_TYPE_TABLE[content_type.model_class()])

    try:
        table = QUERY_CONTENT_TYPE_TABLE[content_type.model_class()](
            None, request.user, view.get_table_data())
    except FieldError:
        raise InvalidConditionsError("Conditions URL incorrect: Field does "
                                     "not exist. Please refer to query docs.")

    config = RequestConfig(request, paginate={"per_page": table.length})
    config.configure(table)
    template = loader.get_template('lava_results_app/query_custom.html')
    return HttpResponse(
        template.render(
            {
                'query_table': table,
                'conditions': conditions,
                '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_custom),
                'context_help': ['lava-queries-charts'],
            },
            request=request))
Example #57
0
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))
Example #58
0
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_detail(request, pathname, content_sha1):
    """
    Detail about a bundle from a particular stream
    """
    bundle_stream = get_object_or_404(BundleStream, pathname=pathname)
    bundle = get_object_or_404(Bundle, bundle_stream=bundle_stream, content_sha1=content_sha1)
    try:
        next_bundle = Bundle.objects.filter(bundle_stream=bundle_stream, id__lt=bundle.id)[0]
    except IndexError:
        next_bundle = None
    try:
        previous_bundle = Bundle.objects.filter(bundle_stream=bundle_stream, id__gt=bundle.id).reverse()[0]
    except IndexError:
        previous_bundle = None
    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",
        {
            'bundle_table': bundle_table,
            'bread_crumb_trail': BreadCrumbTrail.leading_to(
                bundle_detail,
                pathname=pathname,
                content_sha1=content_sha1),
            "terms_data": bundle_table.prepare_terms_data(view),
            "search_data": bundle_table.prepare_search_data(view),
            "discrete_data": bundle_table.prepare_discrete_data(view),
            "times_data": bundle_table.prepare_times_data(view),
            "site": Site.objects.get_current(),
            "bundle": bundle,
            "bundle_stream": bundle_stream,
            "next_bundle": next_bundle,
            "previous_bundle": previous_bundle,
        },
        RequestContext(request))
Example #60
0
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),
                             request=request)
    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,
        ))