Example #1
0
def advance_search(request, tmpl='search/advanced_search.html'):
    """View of /advance-search/"""
    errors = None
    data = request.GET
    target = data.get('target')
    plan_form = PlanForm(data)
    case_form = CaseForm(data)
    run_form = RunForm(data)
    # Update MultipleModelChoiceField on each form dynamically
    plan_form.populate(data)
    case_form.populate(data)
    run_form.populate(data)
    all_forms = (plan_form, case_form, run_form)
    errors = [f.errors for f in all_forms if not f.is_valid()]
    if errors or not data:
        PRODUCT_CHOICE = [(p.pk, p.name) for p in cached_entities('product')]
        PLAN_TYPE_CHOICES = cached_entities('testplantype')
        errors = fmt_errors(errors)
        return render_to_response(tmpl,
                                  locals(),
                                  context_instance=RequestContext(request))

    start = time.time()
    results = query(request, plan_form.cleaned_data, run_form.cleaned_data,
                    case_form.cleaned_data, target)
    results = order_targets(target, results, data)
    end = time.time()
    timecost = round(end - start, 3)
    queries = fmt_queries(*[f.cleaned_data for f in all_forms])
    queries['Target'] = target
    return render_results(request, results, timecost, queries)
Example #2
0
def advance_search(request, tmpl='search/advanced_search.html'):
    '''
    View of /advance-search/
    '''
    errors      = None
    data        = request.GET
    target      = data.get('target')
    plan_form   = PlanForm(data)
    case_form   = CaseForm(data)
    run_form    = RunForm(data)
    # Update MultipleModelChoiceField on each form dynamically
    plan_form.populate(data)
    case_form.populate(data)
    run_form.populate(data)
    all_forms   = (plan_form, case_form, run_form)
    errors      = [f.errors for f in all_forms if not f.is_valid()]
    if errors or not data:
        PRODUCT_CHOICE = [
            (p.pk, p.name) for p in cached_entities('product')
        ]
        PLAN_TYPE_CHOICES = cached_entities('testplantype')
        errors = fmt_errors(errors)
        return render_to_response(tmpl, locals(),
                                  context_instance=RequestContext(request))

    start = time.time()
    results = query(request, plan_form.cleaned_data,
        run_form.cleaned_data, case_form.cleaned_data, target)
    results = order_targets(target, results, data)
    end = time.time()
    timecost = round(end - start, 3)
    queries = fmt_queries(*[f.cleaned_data for f in all_forms])
    queries['Target'] = target
    return render_results(request, results, timecost, queries)
Example #3
0
def view_test_run_report(request):
    templates = {
        'per_build_report': 'report/caserun_report_per_build.html',
        'per_tester_report': 'report/caserun_report_per_tester.html',
        'per_priority_report': 'report/caserun_report_per_priority.html',
        'per_plan_tag_report': 'report/testrun_report_per_plan_tag.html',
        'per_plan_build_report': 'report/testrun_report_per_plan_build.html',
        'runs_with_rates_per_plan_tag': 'report/testrun_report_by_plan_tag_with_rates.html',
        'runs_with_rates_per_plan_build': 'report/testrun_report_by_plan_build_with_rates.html',
    }
    errors  = None
    queries = request.GET
    data    = {}
    report_type = queries.get('report_type')
    PRODUCT_CHOICE = [
            (p.pk, p.name) for p in cached_entities('product')
        ]
    if queries:
        run_form = RunForm(queries)
        run_form.populate(queries)
        if run_form.is_valid():
            queries = run_form.cleaned_data
            data = test_run_report(queries, report_type)
        else:
            errors = run_form.errors
    tmpl = templates.get(report_type, 'report/common/search_run.html')
    queries = fmt_queries(queries)
    request_path = remove_from_request_path(request, 'report_type')
    if request_path:
        path_without_build = remove_from_request_path(request_path, 'r_build')
    data.update(locals())
    return direct_to_template(request, tmpl, data)
Example #4
0
def advance_search(request):
    """View of /advance-search/"""
    data = request.GET
    target = data.get('target')
    plan_form = PlanForm(data)
    case_form = CaseForm(data)
    run_form = RunForm(data)
    # Update MultipleModelChoiceField on each form dynamically
    plan_form.populate(data)
    case_form.populate(data)
    run_form.populate(data)
    all_forms = (plan_form, case_form, run_form)

    errors = []
    for form in all_forms:
        if form.is_valid():
            errors.append(form.errors)

    if errors or not data:
        product_choice = []
        for product in cached_entities('product'):
            product_choice.append((product.pk, product.name))
        plan_type_choices = cached_entities('plantype')  # pylint: disable=unused-variable
        errors = _fmt_errors(errors)
        priorities = Priority.objects.filter(  # pylint: disable=unused-variable
            is_active=True).order_by('value')

        return render(request, 'search/advanced_search.html', locals())

    start = time.time()
    results = _query(plan_form.cleaned_data, run_form.cleaned_data,
                     case_form.cleaned_data, target)
    results = order_targets(target, results, data)
    end = time.time()
    timecost = round(end - start, 3)
    queries = []
    for form in all_forms:
        queries.append(form.cleaned_data)
    queries = fmt_queries(*queries)
    queries['Target'] = target
    return _render_results(request, results, timecost, queries)
Example #5
0
    def populate(self, data):
        status_choice = [(s.pk, s.name) for s in cached_entities('TestCaseStatus')]
        self.fields['cs_status'].choices = status_choice

        priority_choice = [(p.pk, p.value) for p in cached_entities('Priority')]
        self.fields['cs_priority'].choices = priority_choice

        prod_pks = data.getlist('cs_product')
        prod_pks = [k for k in prod_pks if k]
        if prod_pks:
            qs = Product.objects.filter(pk__in=prod_pks)
            self.fields['cs_product'].queryset = qs
        comp_pks = data.getlist('cs_component')
        comp_pks = [k for k in comp_pks if k]
        if comp_pks:
            qs = Component.objects.filter(pk__in=comp_pks)
            self.fields['cs_component'].queryset = qs
        cat_pks = data.getlist('cs_category')
        cat_pks = [k for k in cat_pks if k]
        if cat_pks:
            qs = Category.objects.filter(pk__in=cat_pks)
            self.fields['cs_category'].queryset = qs
Example #6
0
    def populate(self, data):
        status_choices = []
        for test_case_status in cached_entities('TestCaseStatus'):
            status_choices.append((test_case_status.pk, test_case_status.name))
        self.fields['cs_status'].choices = status_choices

        priority_choices = []
        for priority in cached_entities('Priority'):
            priority_choices.append((priority.pk, priority.value))
        self.fields['cs_priority'].choices = priority_choices

        product_pks = []
        for product_pk in data.getlist('cs_product'):
            if product_pk:
                product_pks.append(product_pk)

        if product_pks:
            self.fields['cs_product'].queryset = Product.objects.filter(
                pk__in=product_pks)

        component_pks = []
        for component_pk in data.getlist('cs_component'):
            if component_pk:
                component_pks.append(component_pk)

        if component_pks:
            self.fields['cs_component'].queryset = Component.objects.filter(
                pk__in=component_pks)

        category_pks = []
        for category_pk in data.getlist('cs_category'):
            if category_pk:
                category_pks.append(category_pk)

        if category_pks:
            self.fields['cs_category'].queryset = Category.objects.filter(
                pk__in=category_pks)
Example #7
0
def view_test_run_report(request):
    templates = {
        'per_build_report':
        'report/caserun_report_per_build.html',
        'per_tester_report':
        'report/caserun_report_per_tester.html',
        'per_priority_report':
        'report/caserun_report_per_priority.html',
        'per_plan_tag_report':
        'report/testrun_report_per_plan_tag.html',
        'per_plan_build_report':
        'report/testrun_report_per_plan_build.html',
        'runs_with_rates_per_plan_tag':
        'report/testrun_report_by_plan_tag_with_rates.html',
        'runs_with_rates_per_plan_build':
        'report/testrun_report_by_plan_build_with_rates.html',
    }
    errors = None
    queries = request.GET
    data = {}
    report_type = queries.get('report_type')
    PRODUCT_CHOICE = [(p.pk, p.name) for p in cached_entities('product')]
    if queries:
        run_form = RunForm(queries)
        run_form.populate(queries)
        if run_form.is_valid():
            queries = run_form.cleaned_data
            data = test_run_report(queries, report_type)
        else:
            errors = run_form.errors
    tmpl = templates.get(report_type, 'report/common/search_run.html')
    queries = fmt_queries(queries)
    request_path = remove_from_request_path(request, 'report_type')
    if request_path:
        path_without_build = remove_from_request_path(request_path, 'r_build')
    data.update(locals())
    return render_to_response(tmpl,
                              data,
                              context_instance=RequestContext(request))