def indicator_data_report(request, id=0, program=0): """ This is the Indicator Visual report for each indicator and program. Displays a list collected data entries and sums it at the bottom. Lives in the "Reports" navigation. URL: indicators/data/[indicator_id]/[program_id]/ :param request: :param id: Indicator ID :param program: :return: """ countries = getCountry(request.user) getPrograms = Program.objects.all().filter(funding_status="Funded", country__in=countries).distinct() getIndicators = Indicator.objects.select_related().filter(country__in=countries) indicator_name = None program_name = None q = None #Build query based on filters and search if int(id) != 0: getSiteProfile = Indicator.objects.all().filter(id=id).select_related() q = { 'indicator__id': id } indicator_name = Indicator.objects.get(id=id).name else: getSiteProfile = SiteProfile.objects.all().select_related() q = { 'indicator__country__in': countries, } if int(program) != 0: getSiteProfile = SiteProfile.objects.all().filter(projectagreement__program__id=program).select_related() program_name = Program.objects.get(id=program).name q = { 'program__id':program, 'agreement__program__id': program, } #redress the indicator list based on program getIndicators = Indicator.objects.select_related().filter(program=program) if request.method == "GET" and "search" in request.GET: queryset = CollectedData.objects.filter(**q).filter( Q(agreement__project_name__contains=request.GET["search"]) | Q(description__icontains=request.GET["search"]) | Q(indicator__name__contains=request.GET["search"]) ).select_related() else: queryset = CollectedData.objects.all().filter(**q).select_related() #pass query to table and configure table = IndicatorDataTable(queryset) table.paginate(page=request.GET.get('page', 1), per_page=20) 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/data_report.html", {'getQuantitativeData':queryset,'countries':countries, 'getSiteProfile':getSiteProfile, 'table': table,'getPrograms':getPrograms, 'getIndicators': getIndicators, 'form': FilterForm(), 'helper': FilterForm.helper, 'id': id,'program':program,'indicator_name':indicator_name, 'program_name': program_name})
def indicator_data_report(request, id=0, program=0): """ Show LIST of indicator based quantitative outputs with a filtered search view using django-tables2 and django-filter """ countries = getCountry(request.user) getPrograms = Program.objects.all().filter(funding_status="Funded", country__in=countries).distinct() getIndicators = Indicator.objects.select_related().filter(country__in=countries) indicator_name = None program_name = None q = None #Build query based on filters and search if int(id) != 0: getSiteProfile = Indicator.objects.all().filter(id=id).select_related() q = { 'indicator__id': id } indicator_name = Indicator.objects.get(id=id).name else: getSiteProfile = SiteProfile.objects.all().select_related() q = { 'indicator__country__in': countries, } if int(program) != 0: getSiteProfile = SiteProfile.objects.all().filter(projectagreement__program__id=program).select_related() program_name = Program.objects.get(id=program).name q = { 'program__id':program, 'agreement__program__id': program, } #redress the indicator list based on program getIndicators = Indicator.objects.select_related().filter(program=program) if request.method == "GET" and "search" in request.GET: """ fields = ('targeted', 'achieved', 'description', 'indicator', 'agreement', 'complete') """ queryset = CollectedData.objects.filter(**q).filter( Q(agreement__project_name__contains=request.GET["search"]) | Q(description__icontains=request.GET["search"]) | Q(indicator__name__contains=request.GET["search"]) ).select_related() else: queryset = CollectedData.objects.all().filter(**q).select_related() #pass query to table and configure table = IndicatorDataTable(queryset) table.paginate(page=request.GET.get('page', 1), per_page=20) 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/data_report.html", {'getQuantitativeData':queryset,'countries':countries, 'getSiteProfile':getSiteProfile, 'table': table,'getPrograms':getPrograms, 'getIndicators': getIndicators, 'form': FilterForm(), 'helper': FilterForm.helper, 'id': id,'program':program,'indicator_name':indicator_name, 'program_name': program_name})
def indicator_data_report(request, id=0, program=0): """ Show LIST of indicator based quantitative outputs with a filtered search view using django-tables2 and django-filter """ countries = getCountry(request.user) getPrograms = Program.objects.all().filter( funding_status="Funded", country__in=countries).distinct() getIndicators = Indicator.objects.select_related().filter( country__in=countries) indicator_name = None program_name = None q = None #Build query based on filters and search if int(id) != 0: getSiteProfile = Indicator.objects.all().filter(id=id).select_related() q = {'indicator__id': id} indicator_name = Indicator.objects.get(id=id).name else: getSiteProfile = SiteProfile.objects.all().select_related() q = { 'indicator__country__in': countries, } if int(program) != 0: getSiteProfile = SiteProfile.objects.all().filter( projectagreement__program__id=program).select_related() program_name = Program.objects.get(id=program).name q = { 'program__id': program, 'agreement__program__id': program, } #redress the indicator list based on program getIndicators = Indicator.objects.select_related().filter( program=program) if request.method == "GET" and "search" in request.GET: """ fields = ('targeted', 'achieved', 'description', 'indicator', 'agreement', 'complete') """ queryset = CollectedData.objects.filter(**q).filter( Q(agreement__project_name__contains=request.GET["search"]) | Q(description__icontains=request.GET["search"]) | Q(indicator__name__contains=request.GET["search"]) ).select_related() else: queryset = CollectedData.objects.all().filter(**q).select_related() #pass query to table and configure table = IndicatorDataTable(queryset) table.paginate(page=request.GET.get('page', 1), per_page=20) 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/data_report.html", { 'getQuantitativeData': queryset, 'countries': countries, 'getSiteProfile': getSiteProfile, 'table': table, 'getPrograms': getPrograms, 'getIndicators': getIndicators, 'form': FilterForm(), 'helper': FilterForm.helper, 'id': id, 'program': program, 'indicator_name': indicator_name, 'program_name': program_name })
def indicator_data_report(request, id=0, program=0, type=0): """ This is the Indicator Visual report for each indicator and program. Displays a list collected data entries and sums it at the bottom. Lives in the "Reports" navigation. URL: indicators/data/[id]/[program]/[type] :param request: :param id: Indicator ID :param program: Program ID :param type: Type ID :return: """ countries = getCountry(request.user) getPrograms = Program.objects.all().filter(funding_status="Funded", country__in=countries).distinct() getIndicators = Indicator.objects.select_related().filter(program__country__in=countries) getTypes = IndicatorType.objects.all() indicator_name = None program_name = None type_name = None q = {"indicator__id__isnull": False} z = None # Build query based on filters and search if int(id) != 0: getSiteProfile = Indicator.objects.all().filter(id=id).select_related() indicator_name = Indicator.objects.get(id=id).name z = {"indicator__id": id} else: getSiteProfile = SiteProfile.objects.all().select_related() z = {"indicator__program__country__in": countries} if int(program) != 0: getSiteProfile = SiteProfile.objects.all().filter(projectagreement__program__id=program).select_related() program_name = Program.objects.get(id=program).name q = {"program__id": program} # redress the indicator list based on program getIndicators = Indicator.objects.select_related().filter(program=program) if int(type) != 0: type_name = IndicatorType.objects.get(id=type).indicator_type q = {"indicator__indicator_type__id": type} if z: q.update(z) print q if request.method == "GET" and "search" in request.GET: queryset = ( CollectedData.objects.filter(**q) .filter( Q(agreement__project_name__contains=request.GET["search"]) | Q(description__icontains=request.GET["search"]) | Q(indicator__name__contains=request.GET["search"]) ) .select_related() ) else: queryset = CollectedData.objects.all().filter(**q).select_related() # pass query to table and configure table = IndicatorDataTable(queryset) table.paginate(page=request.GET.get("page", 1), per_page=20) 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/data_report.html", { "getQuantitativeData": queryset, "countries": countries, "getSiteProfile": getSiteProfile, "getPrograms": getPrograms, "getIndicators": getIndicators, "getTypes": getTypes, "form": FilterForm(), "helper": FilterForm.helper, "id": id, "program": program, "type": type, "indicator": id, "indicator_name": indicator_name, "type_name": type_name, "program_name": program_name, }, )
def indicator_data_report(request, id=0, program=0): """ This is the Indicator Visual report for each indicator and program. Displays a list collected data entries and sums it at the bottom. Lives in the "Reports" navigation. URL: indicators/data/[indicator_id]/[program_id]/ :param request: :param id: Indicator ID :param program: :return: """ countries = getCountry(request.user) getPrograms = Program.objects.all().filter( funding_status="Funded", country__in=countries).distinct() getIndicators = Indicator.objects.select_related().filter( country__in=countries) indicator_name = None program_name = None q = None #Build query based on filters and search if int(id) != 0: getSiteProfile = Indicator.objects.all().filter(id=id).select_related() q = {'indicator__id': id} indicator_name = Indicator.objects.get(id=id).name else: getSiteProfile = SiteProfile.objects.all().select_related() q = { 'indicator__country__in': countries, } if int(program) != 0: getSiteProfile = SiteProfile.objects.all().filter( projectagreement__program__id=program).select_related() program_name = Program.objects.get(id=program).name q = { 'program__id': program, 'agreement__program__id': program, } #redress the indicator list based on program getIndicators = Indicator.objects.select_related().filter( program=program) if request.method == "GET" and "search" in request.GET: queryset = CollectedData.objects.filter(**q).filter( Q(agreement__project_name__contains=request.GET["search"]) | Q(description__icontains=request.GET["search"]) | Q(indicator__name__contains=request.GET["search"]) ).select_related() else: queryset = CollectedData.objects.all().filter(**q).select_related() #pass query to table and configure table = IndicatorDataTable(queryset) table.paginate(page=request.GET.get('page', 1), per_page=20) 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/data_report.html", { 'getQuantitativeData': queryset, 'countries': countries, 'getSiteProfile': getSiteProfile, 'table': table, 'getPrograms': getPrograms, 'getIndicators': getIndicators, 'form': FilterForm(), 'helper': FilterForm.helper, 'id': id, 'program': program, 'indicator_name': indicator_name, 'program_name': program_name })