Exemplo n.º 1
0
def all(request):
    """Read the test runs from database and display them."""
    SUB_MODULE_NAME = "runs"

    query_result = len(request.GET) > 0

    if list(request.GET.items()):
        search_form = SearchRunForm(request.GET)
        if request.GET.get('product'):
            search_form.populate(product_id=request.GET['product'])
        else:
            search_form.populate()

        search_form.is_valid()
    else:
        search_form = SearchRunForm()

    return render(request,
                  'run/all.html',
                  context={
                      'module': MODULE_NAME,
                      'sub_module': SUB_MODULE_NAME,
                      'query_result': query_result,
                      'search_form': search_form,
                  })
Exemplo n.º 2
0
    def get_context_data(self, **kwargs):
        form = SearchRunForm(self.request.GET)
        form.populate(product_id=self.request.GET.get('product'))

        return {
            'form': form,
        }
Exemplo n.º 3
0
Arquivo: views.py Projeto: fmca/Kiwi
def search(request):
    form = SearchRunForm(request.GET)
    form.populate(product_id=request.GET.get('product'))

    context_data = {
        'form': form,
    }
    return render(request, 'testruns/search.html', context_data)
Exemplo n.º 4
0
def search(request):  # pylint: disable=missing-permission-required
    form = SearchRunForm(request.GET)
    form.populate(product_id=request.GET.get('product'))

    context_data = {
        'form': form,
    }
    return render(request, 'testruns/search.html', context_data)
Exemplo n.º 5
0
def search_runs(request):
    """Search test runs"""
    search_form = SearchRunForm(request.GET)
    product_id = request.GET.get('product')
    search_form.populate(product_id=int(product_id) if product_id else None)

    runs = TestRun.objects.none()

    if search_form.is_valid():
        runs = (TestRun.list(search_form.cleaned_data).select_related(
            'manager', 'default_tester',
            'build', 'plan', 'build__product').only(
                'run_id', 'summary', 'manager__username', 'default_tester__id',
                'default_tester__username', 'plan__name',
                'build__product__name', 'stop_date',
                'product_version__value').extra(
                    select={'cases_count': RawSQL.total_num_caseruns}))

    column_names = [
        '',
        'run_id',
        'summary',
        'manager__username',
        'default_tester__username',
        'build__product__name',
        'product_version__value',
        'env_groups',
        'cases_count',
        'stop_date',
        'completed',
    ]

    dt = DataTableResult(request.GET,
                         runs,
                         column_names,
                         default_order_key='-pk')
    response_data = dt.get_response_data()
    calculate_associated_data(response_data['querySet'])

    if 'sEcho' in request.GET:
        resp_data = (get_template('run/common/json_runs.txt').render(
            response_data, request))
        return JsonResponse(json.loads(resp_data))
    else:
        return render(request,
                      'run/all.html',
                      context={
                          'module': MODULE_NAME,
                          'sub_module': 'runs',
                          'object_list': response_data['querySet'],
                          'search_form': search_form,
                          'total_count': runs.count()
                      })
Exemplo n.º 6
0
def ajax_search(request, template_name='run/common/json_runs.txt'):
    """Response request to search test runs from Search Runs"""
    search_form = SearchRunForm(request.GET)
    if request.GET.get('product'):
        search_form.populate(product_id=request.GET['product'])
    else:
        search_form.populate()

    if search_form.is_valid():
        trs = TestRun.list(search_form.cleaned_data)
        trs = trs.select_related(
            'manager', 'default_tester', 'plan',
            'build').only('run_id', 'summary', 'manager__username',
                          'default_tester__id', 'default_tester__username',
                          'plan__name', 'env_value', 'build__product__name',
                          'stop_date', 'product_version__value')

        # Further optimize by adding caserun attributes:
        column_names = [
            '',
            'run_id',
            'summary',
            'manager__username',
            'default_tester__username',
            'plan',
            'build__product__name',
            'product_version',
            'total_num_caseruns',
            'stop_date',
            'completed',
        ]

        data_table_result = DataTableResult(request.GET, trs, column_names)
        response_data = data_table_result.get_response_data()
        searched_runs = response_data['querySet']

        # Get associated statistics data
        run_ids = [run.pk for run in searched_runs]
        qs = TestCaseRun.objects.filter(
            run__in=run_ids).values('run').annotate(cases_count=Count('case'))
        cases_subtotal = magic_convert(qs,
                                       key_name='run',
                                       value_name='cases_count')

        for run in searched_runs:
            run_id = run.pk
            cases_count = cases_subtotal.get(run_id, 0)
            run.nitrate_stats = {
                'cases': cases_count,
            }
    else:
        response_data = {
            'sEcho': int(request.GET.get('sEcho', 0)),
            'iTotalRecords': 0,
            'iTotalDisplayRecords': 0,
            'runs': TestRun.objects.none(),
        }

    json_data = render_to_string(template_name, response_data, request=request)
    return HttpResponse(json_data, content_type='application/json')
Exemplo n.º 7
0
Arquivo: views.py Projeto: xbln/Kiwi
def all(request, template_name='run/all.html'):
    '''Read the test runs from database and display them.'''
    query_result = len(request.GET) > 0

    if request.GET:
        search_form = SearchRunForm(request.GET)
        if request.GET.get('product'):
            search_form.populate(product_id=request.GET['product'])
        else:
            search_form.populate()

        search_form.is_valid()
    else:
        search_form = SearchRunForm()

    context_data = {
        'query_result': query_result,
        'search_form': search_form,
    }
    return render(request, template_name, context_data)
Exemplo n.º 8
0
def get_all(request):
    """Read the test runs from database and display them."""
    query_result = len(request.GET) > 0

    if request.GET:
        search_form = SearchRunForm(request.GET)
        search_form.populate(product_id=request.GET.get('product'))
        search_form.is_valid()
    else:
        search_form = SearchRunForm()

    context_data = {
        'query_result': query_result,
        'search_form': search_form,
    }
    return render(request, 'run/all.html', context_data)