Exemplo n.º 1
0
def indicator_report(request, program=0, indicator=0, type=0):
    """
    This is the indicator library report.  List of all indicators across a country or countries filtered by
    program.  Lives in the "Report" navigation.
    URL: indicators/report/0/
    :param request:
    :param program:
    :return:
    """
    countries = getCountry(request.user)
    getPrograms = Program.objects.all().filter(funding_status="Funded", country__in=countries).distinct()

    getIndicatorTypes = IndicatorType.objects.all()

    if int(program) != 0:
        getIndicators = Indicator.objects.all().filter(program__id=program).select_related()

    elif int(type) != 0:
        getIndicators = Indicator.objects.all().filter(indicator_type=type).select_related()

    else:
        getIndicators = Indicator.objects.all().select_related().filter(program__country__in=countries)

    table = IndicatorTable(getIndicators)
    table.paginate(page=request.GET.get("page", 1), per_page=20)

    if request.method == "GET" and "search" in request.GET:
        queryset = Indicator.objects.filter(
            Q(indicator_type__indicator_type__contains=request.GET["search"])
            | Q(name__contains=request.GET["search"])
            | Q(number__contains=request.GET["search"])
            | Q(number__contains=request.GET["search"])
            | Q(sector__sector__contains=request.GET["search"])
            | Q(definition__contains=request.GET["search"])
        )
        table = IndicatorTable(queryset)

    RequestConfig(request).configure(table)

    # send the keys and vars from the json data to the template along with submitted feed info and silos for new form
    return render(
        request,
        "indicators/report.html",
        {
            "program": program,
            "get_agreements": table,
            "getPrograms": getPrograms,
            "form": FilterForm(),
            "helper": FilterForm.helper,
            "getIndicatorTypes": getIndicatorTypes,
        },
    )
Exemplo n.º 2
0
def indicator_report(request, program=0):
    """
    This is the indicator library report.  List of all indicators across a country or countries filtered by
    program.  Lives in the "Report" navigation.
    URL: indicators/report/0/
    :param request:
    :param program:
    :return:
    """
    countries = getCountry(request.user)
    getPrograms = Program.objects.all().filter(funding_status="Funded", country__in=countries).distinct()

    if int(program) == 0:
        getIndicators = Indicator.objects.all().select_related().filter(country__in=countries)
    else:
        getIndicators = Indicator.objects.all().filter(program__id=program).select_related()

    table = IndicatorTable(getIndicators)
    table.paginate(page=request.GET.get('page', 1), per_page=20)

    if request.method == "GET" and "search" in request.GET:
        #list1 = list()
        #for obj in filtered:
        #    list1.append(obj)
        """
         fields = (indicator_type, name, number, source, definition, disaggregation, baseline, lop_target, means_of_verification, data_collection_method, responsible_person,
                    method_of_analysis, information_use, reporting_frequency, comments, program, sector, approved_by, approval_submitted_by, create_date, edit_date)
        """
        queryset = Indicator.objects.filter(
                                           Q(indicator_type__indicator_type__contains=request.GET["search"]) |
                                           Q(name__contains=request.GET["search"]) | Q(number__contains=request.GET["search"]) |
                                           Q(number__contains=request.GET["search"]) | Q(sector__sector__contains=request.GET["search"]) |
                                           Q(definition__contains=request.GET["search"])
                                          )
        table = IndicatorTable(queryset)

    RequestConfig(request).configure(table)

    # send the keys and vars from the json data to the template along with submitted feed info and silos for new form
    return render(request, "indicators/report.html", {'program': program, 'get_agreements': table, 'getPrograms': getPrograms, 'form': FilterForm(), 'helper': FilterForm.helper})
Exemplo n.º 3
0
def indicator_report(request, program=0):
    """
    This is the indicator library report.  List of all indicators across a country or countries filtered by
    program.  Lives in the "Report" navigation.
    URL: indicators/report/0/
    :param request:
    :param program:
    :return:
    """
    countries = getCountry(request.user)
    getPrograms = Program.objects.all().filter(
        funding_status="Funded", country__in=countries).distinct()

    if int(program) == 0:
        getIndicators = Indicator.objects.all().select_related().filter(
            country__in=countries)
    else:
        getIndicators = Indicator.objects.all().filter(
            program__id=program).select_related()

    table = IndicatorTable(getIndicators)
    table.paginate(page=request.GET.get('page', 1), per_page=20)

    if request.method == "GET" and "search" in request.GET:
        #list1 = list()
        #for obj in filtered:
        #    list1.append(obj)
        """
         fields = (indicator_type, name, number, source, definition, disaggregation, baseline, lop_target, means_of_verification, data_collection_method, responsible_person,
                    method_of_analysis, information_use, reporting_frequency, comments, program, sector, approved_by, approval_submitted_by, create_date, edit_date)
        """
        queryset = Indicator.objects.filter(
            Q(indicator_type__indicator_type__contains=request.GET["search"])
            | Q(name__contains=request.GET["search"])
            | Q(number__contains=request.GET["search"])
            | Q(number__contains=request.GET["search"])
            | Q(sector__sector__contains=request.GET["search"])
            | Q(definition__contains=request.GET["search"]))
        table = IndicatorTable(queryset)

    RequestConfig(request).configure(table)

    # send the keys and vars from the json data to the template along with submitted feed info and silos for new form
    return render(
        request, "indicators/report.html", {
            'program': program,
            'get_agreements': table,
            'getPrograms': getPrograms,
            'form': FilterForm(),
            'helper': FilterForm.helper
        })