本文整理汇总了Python中tola.util.getCountry函数的典型用法代码示例。如果您正苦于以下问题:Python getCountry函数的具体用法?Python getCountry怎么用?Python getCountry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCountry函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RRIMAPublicDashboard
def RRIMAPublicDashboard(request,id=0):
## retrieve program
model = Program
program_id = id
getProgram = Program.objects.all().filter(id=program_id)
## retrieve the coutries the user has data access for
countries = getCountry(request.user)
#retrieve projects for a program
getProjects = ProjectAgreement.objects.all()##.filter(program__id=1, program__country__in=1)
pageText = {}
pageText['pageTitle'] = "Refugee Response and Migration News"
pageText['projectSummary'] = {}
pageNews = JupyterNotebooks.objects.all().filter(very_custom_dashboard="RRIMA")
pageMap = [{"latitude":39.9334, "longitude":32.8597, "location_name":"Ankara","site_contact":"Sonal Shinde, Migration Response Director, [email protected]", "site_description":"Migration Response Coordination","region_name":"Turkey"},
{"latitude":38.4237, "longitude":27.1428, "location_name":"Izmir","site_contact":"Tracy Lucas, Emergency Program Manager, ECHO Aegean Response, [email protected]", "site_description":"Cash, Information Dissemination, Youth, Protection", "region_name":"Turkey"},
{"latitude":37.0660, "longitude":37.3781, "location_name":"Gaziantep","site_contact":"Jihane Nami, Director of Programs Turkey, [email protected]", "site_description":"Cash, NFI, Shelter, Protection, Information Dissemination","region_name":"Turkey"},
{"latitude":39.2645, "longitude":26.2777, "location_name":"Lesvos", "site_contact":"Chiara Bogoni, Island Emergency Program Manager, [email protected]", "site_description":"Cash, Youth Programs, Food","region_link":"Greece"},
{"latitude":37.9838, "longitude":23.7275, "location_name":"Athens", "site_contact":"Josh Kreger, Team Leader - Greece, [email protected] and Kaja Wislinska, Team Leader - Athens and Mainland, [email protected]","site_description":"Cash, Youth Psychosocial Support, Legal Support","region_link":"Greece","region_link":"Greece"},
{"latitude":44.7866, "longitude":20.4489, "location_name":"Belgrade","site_contact":"Radovan Jovanovic, Team Leader - Balkans, [email protected]","site_description":"SIM Card Distribution, Information Dissemination","region_name":"Balkans"}]
# Borrowed data for bar graph
colorPalettes = {
'bright':['#82BC00','#C8C500','#10A400','#CF102E','#DB5E11','#A40D7A','#00AFA8','#1349BB','#FFD200 ','#FF7100','#FFFD00','#ABABAB','#7F7F7F','#7B5213','#C18A34'],
'light':['#BAEE46','#FDFB4A','#4BCF3D','#F2637A','#FFA268','#C451A4','#4BC3BE','#5B7FCC','#9F54CC','#FFE464','#FFA964','#FFFE64','#D7D7D7','#7F7F7F','#D2A868','#FFD592']
};
return render(request, 'customdashboard/rrima_dashboard.html',
{'pageText': pageText, 'pageNews': pageNews, 'pageMap': pageMap, 'countries': countries })
示例2: __init__
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_method = 'post'
self.request = kwargs.pop('request')
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-sm-2'
self.helper.field_class = 'col-sm-6'
self.helper.form_error_title = 'Form Errors'
self.helper.error_text_inline = True
self.helper.help_text_inline = True
self.helper.html5_required = True
self.helper.layout = Layout(
HTML("""<br/>"""),
'name', 'url', Field('description', rows="3", css_class='input-xlarge'),'file_field',
'project','program',
FormActions(
Submit('submit', 'Save', css_class='btn-default'),
Reset('reset', 'Reset', css_class='btn-warning')
)
)
super(DocumentationForm, self).__init__(*args, **kwargs)
#override the program queryset to use request.user for country
countries = getCountry(self.request.user)
self.fields['project'].queryset = ProjectAgreement.objects.filter(program__country__in=countries)
self.fields['program'].queryset = Program.objects.filter(country__in=countries)
示例3: programIndicatorReport
def programIndicatorReport(request, program=0):
"""
Show LIST of indicators with a filtered search view using django-tables2
and django-filter
"""
program = int(program)
countries = getCountry(request.user)
getPrograms = Program.objects.all().filter(funding_status="Funded", country__in=countries).distinct()
getIndicators = Indicator.objects.all().filter(program__id=program).select_related().order_by('level', 'number')
getProgram = Program.objects.get(id=program)
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)
"""
getIndicators = Indicator.objects.all().filter(
Q(indicator_type__icontains=request.GET["search"]) |
Q(name__icontains=request.GET["search"]) |
Q(number__icontains=request.GET["search"]) |
Q(definition__startswith=request.GET["search"])
).filter(program__id=program).select_related().order_by('level','number')
# 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/grid_report.html", {'getIndicators': getIndicators, 'getPrograms': getPrograms, 'getProgram': getProgram, 'form': FilterForm(), 'helper': FilterForm.helper})
示例4: indicator_data_report
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})
示例5: DefaultCustomDashboard
def DefaultCustomDashboard(request,id=0,status=0):
"""
This is used as the workflow program dashboard
# of agreements, approved, rejected, waiting, archived and total for dashboard
http://127.0.0.1:8000/customdashboard/65/
"""
program_id = id
countries = getCountry(request.user)
#transform to list if a submitted country
selected_countries_list = Country.objects.all().filter(program__id=program_id)
getQuantitativeDataSums = CollectedData.objects.filter(indicator__program__id=program_id,achieved__isnull=False, indicator__key_performance_indicator=True).exclude(achieved=None,targeted=None).order_by('indicator__number').values('indicator__number','indicator__name','indicator__id').annotate(targets=Sum('targeted'), actuals=Sum('achieved')).exclude(achieved=None,targeted=None)
getFilteredName=Program.objects.get(id=program_id)
getProjectsCount = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries).count()
getBudgetEstimated = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries).annotate(estimated=Sum('total_estimated_budget'))
getAwaitingApprovalCount = ProjectAgreement.objects.all().filter(program__id=program_id, approval='awaiting approval', program__country__in=countries).count()
getApprovedCount = ProjectAgreement.objects.all().filter(program__id=program_id, approval='approved', program__country__in=countries).count()
getRejectedCount = ProjectAgreement.objects.all().filter(program__id=program_id, approval='rejected', program__country__in=countries).count()
getInProgressCount = ProjectAgreement.objects.all().filter(program__id=program_id).filter(Q(Q(approval='in progress') | Q(approval=None)), program__country__in=countries).count()
nostatus_count = ProjectAgreement.objects.all().filter(program__id=program_id).filter(Q(Q(approval=None) | Q(approval=""))).count()
print getInProgressCount
getSiteProfile = SiteProfile.objects.all().filter(Q(projectagreement__program__id=program_id) | Q(collecteddata__program__id=program_id))
getSiteProfileIndicator = SiteProfile.objects.all().filter(Q(collecteddata__program__id=program_id))
if (status) =='Approved':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries, approval='approved').prefetch_related('projectcomplete')
elif(status) =='Rejected':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries, approval='rejected').prefetch_related('projectcomplete')
elif(status) =='In Progress':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries, approval='in progress').prefetch_related('projectcomplete')
elif(status) =='Awaiting Approval':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries, approval='awaiting approval').prefetch_related('projectcomplete')
else:
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries)
get_project_completed = []
getProjectsComplete = ProjectComplete.objects.all()
for project in getProjects:
for complete in getProjectsComplete:
if complete.actual_budget != None:
if project.id == complete.project_agreement_id:
get_project_completed.append(project)
return render(request, "customdashboard/customdashboard/visual_dashboard.html", {'getSiteProfile':getSiteProfile, 'getBudgetEstimated': getBudgetEstimated, 'getQuantitativeDataSums': getQuantitativeDataSums,
'country': countries, 'getAwaitingApprovalCount':getAwaitingApprovalCount,
'getFilteredName': getFilteredName,'getProjects': getProjects, 'getApprovedCount': getApprovedCount,
'getRejectedCount': getRejectedCount, 'getInProgressCount': getInProgressCount,'nostatus_count': nostatus_count,
'getProjectsCount': getProjectsCount, 'selected_countries_list': selected_countries_list,
'getSiteProfileIndicator': getSiteProfileIndicator, 'get_project_completed': get_project_completed})
示例6: collecteddata_import
def collecteddata_import(request):
"""
Import collected data from Tola Tables
:param request:
:return:
"""
owner = request.user
# get the TolaTables URL and token from the sites object
service = TolaSites.objects.get(site_id=1)
# add filter to get just the users tables only
user_filter_url = service.tola_tables_url + "&owner__username=" + str(owner)
shared_filter_url = service.tola_tables_url + "&shared__username=" + str(owner)
user_json = get_table(user_filter_url)
shared_json = get_table(shared_filter_url)
if type(shared_json) is not dict:
data = user_json + shared_json
else:
data = user_json
if request.method == "POST":
id = request.POST["service_table"]
filter_url = service.tola_tables_url + "&id=" + id
data = get_table(filter_url)
# Get Data Info
for item in data:
name = item["name"]
url = item["data"]
remote_owner = item["owner"]["username"]
# send table ID to count items in data
count = getTableCount(url, id)
# get the users country
countries = getCountry(request.user)
check_for_existence = TolaTable.objects.all().filter(name=name, owner=owner)
if check_for_existence:
result = "error"
else:
create_table = TolaTable.objects.create(
name=name, owner=owner, remote_owner=remote_owner, table_id=id, url=url, unique_count=count
)
create_table.country.add(countries[0].id)
create_table.save()
result = "success"
# send result back as json
message = result
return HttpResponse(json.dumps(message), content_type="application/json")
# 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/collecteddata_import.html", {"getTables": data})
示例7: get
def get(self, request, *args, **kwargs):
## retrieve program
model = Program
## retrieve the countries the user has data access for
countries = getCountry(request.user)
dashboard_id = int(self.kwargs['pk'])
getDashboardListComponents = DashboardComponent.objects.all().filter(componentset=dashboard_id)
return render(request, self.template_name, {'getDashboardListComponents': getDashboardListComponents})
示例8: queryset
def queryset(self, request, queryset):
"""
Returns the filtered queryset based on the value
provided in the query string and retrievable via
`self.value()`.
"""
# Filter by logged in users allowable countries
user_countries = getCountry(request.user)
#if not request.user.user.is_superuser:
return queryset.filter(country__in=user_countries)
示例9: indicator_data_report
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})
示例10: get
def get(self, request, *args, **kwargs):
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).exclude(collecteddata__isnull=True)
getCollectedData = None
collected_sum = None
#filter by program or inidcator or both
if int(self.kwargs['indicator']) != 0:
getCollectedData = CollectedData.objects.all().filter(indicator__id=self.kwargs['indicator'])
collected_sum = CollectedData.objects.filter(indicator__id=self.kwargs['indicator']).aggregate(Sum('targeted'),Sum('achieved'))
elif int(self.kwargs['indicator']) == 0 and int(self.kwargs['program']) != 0:
getCollectedData = CollectedData.objects.all().filter(program=self.kwargs['program'])
collected_sum = CollectedData.objects.filter(program=self.kwargs['program']).aggregate(Sum('targeted'),Sum('achieved'))
#redress indicator query based on submitted program
getIndicators = Indicator.objects.select_related().filter(program=self.kwargs['program']).exclude(collecteddata__isnull=True)
elif int(self.kwargs['indicator']) != 0 and int(self.kwargs['program']) != 0:
getCollectedData = CollectedData.objects.all().filter(program=self.kwargs['program'],indicator__id=self.kwargs['indicator'])
collected_sum = CollectedData.objects.filter(program=self.kwargs['program'],indicator__id=self.kwargs['indicator']).aggregate(Sum('targeted'),Sum('achieved'))
#redress indicator query based on submitted program
getIndicators = Indicator.objects.select_related().filter(program=self.kwargs['program']).exclude(collecteddata__isnull=True)
elif int(self.kwargs['indicator']) == 0 and int(self.kwargs['program']) == 0:
getCollectedData = CollectedData.objects.all().filter(indicator__country__in=countries)
collected_sum = CollectedData.objects.filter(indicator__country__in=countries).aggregate(Sum('targeted'),Sum('achieved'))
#get details about the filtered indicator or program
try:
filter_indicator = Indicator.objects.get(id=self.kwargs['indicator'])
except Indicator.DoesNotExist:
filter_indicator = None
try:
filter_program = Program.objects.get(id=self.kwargs['program'])
except Program.DoesNotExist:
filter_program = None
#TEMP CODE to migrate inidcators for Afghanistan that do not have programs but have Agreements
if getCollectedData:
for data in getCollectedData:
set_program = None
if data.program is None and data.agreement:
try:
program_from_agreement = ProjectAgreement.objects.get(id=data.agreement.id)
set_program = program_from_agreement.program
except ProjectAgreement.DoesNotExist:
set_program = None
if set_program:
update=CollectedData.objects.filter(id=data.pk).update(program=set_program)
#END TEMP CODE
return render(request, self.template_name, {'getCollectedData': getCollectedData, 'getPrograms': getPrograms, 'getIndicators':getIndicators,'filter_program':filter_program,'filter_indicator': filter_indicator, 'collected_sum': collected_sum})
示例11: get
def get(self, request, *args, **kwargs):
countries = getCountry(request.user)
getPrograms = Program.objects.all().filter(country__in=countries, funding_status="Funded").distinct()
if int(self.kwargs['pk']) == 0:
getProgramsIndicator = Program.objects.all().filter(funding_status="Funded", country__in=countries).order_by('name').annotate(indicator_count=Count('indicator'))
else:
getProgramsIndicator = Program.objects.all().filter(id=self.kwargs['pk']).order_by('name').annotate(indicator_count=Count('indicator'))
return render(request, self.template_name, {'getPrograms': getPrograms, 'getProgramsIndicator': getProgramsIndicator})
示例12: indicator_report
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,
},
)
示例13: RRIMAJupyterView1
def RRIMAJupyterView1(request,id=0):
"""
RRIMA custom dashboard TODO: Migrate this to the existing configurable dashboard
:param request:
:param id:
:return:
"""
model = Program
program_id = 1#id ##USE TURKEY PROGRAM ID HERE
# getProgram = Program.objects.all().filter(id=program_id)
## retrieve the coutries the user has data access for
countries = getCountry(request.user)
with open('static/rrima.html') as myfile: data = "\n".join(line for line in myfile)
return HttpResponse(data)
示例14: DefaultCustomDashboard
def DefaultCustomDashboard(request,id=0,sector=0,status=0):
"""
# of agreements, approved, rejected, waiting, archived and total for dashboard
"""
program_id = id
countries = getCountry(request.user)
#transform to list if a submitted country
selected_countries_list = Country.objects.all().filter(program__id=program_id)
getQuantitativeDataSums = CollectedData.objects.all().filter(indicator__program__id=program_id,achieved__isnull=False, indicator__key_performance_indicator=True).exclude(achieved=None,targeted=None).order_by('indicator__number').values('indicator__number','indicator__name','indicator__id').annotate(targets=Sum('targeted'), actuals=Sum('achieved'))
getFilteredName=Program.objects.get(id=program_id)
getProjectStatus = ProjectStatus.objects.all()
getProjectsCount = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries).count()
getBudgetEstimated = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries).annotate(estimated=Sum('total_estimated_budget'))
getAwaitingApprovalCount = ProjectAgreement.objects.all().filter(program__id=program_id, approval='', program__country__in=countries).count()
getApprovedCount = ProjectAgreement.objects.all().filter(program__id=program_id, approval='approved', program__country__in=countries).count()
getRejectedCount = ProjectAgreement.objects.all().filter(program__id=program_id, approval='rejected', program__country__in=countries).count()
getInProgressCount = ProjectAgreement.objects.all().filter(program__id=program_id, approval='in progress', program__country__in=countries).count()
getSiteProfile = SiteProfile.objects.all().filter(Q(projectagreement__program__id=program_id) | Q(collecteddata__program__id=program_id))
getSiteProfileIndicator = SiteProfile.objects.all().filter(Q(collecteddata__program__id=program_id))
if (status) =='Approved':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries,approval='approved')
elif(status) =='Rejected':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries,approval='rejected')
elif(status) =='In Progress':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries,approval='in progress')
elif(status) =='Awaiting Approval':
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries,approval='awaiting approval')
else:
getProjects = ProjectAgreement.objects.all().filter(program__id=program_id, program__country__in=countries)
getCustomDashboard = CustomDashboard.objects.all()
return render(request, "customdashboard/visual_dashboard.html", {'getSiteProfile':getSiteProfile, 'getBudgetEstimated': getBudgetEstimated, 'getQuantitativeDataSums': getQuantitativeDataSums,
'country': countries, 'getProjectStatus': getProjectStatus, 'getAwaitingApprovalCount':getAwaitingApprovalCount,
'getFilteredName': getFilteredName,'getProjects': getProjects, 'getApprovedCount': getApprovedCount,
'getRejectedCount': getRejectedCount, 'getInProgressCount': getInProgressCount,
'getCustomDashboard': getCustomDashboard, 'getProjectsCount': getProjectsCount, 'selected_countries_list': selected_countries_list,
'getSiteProfileIndicator': getSiteProfileIndicator})
示例15: programIndicatorReport
def programIndicatorReport(request, program=0):
"""
This is the GRID report or indicator plan for a program. Shows a simple list of indicators sorted by level
and number. Lives in the "Indicator" home page as a link.
URL: indicators/program_report/[program_id]/
:param request:
:param program:
:return:
"""
program = int(program)
countries = getCountry(request.user)
getPrograms = Program.objects.all().filter(funding_status="Funded", country__in=countries).distinct()
getIndicators = Indicator.objects.all().filter(program__id=program).select_related().order_by("level", "number")
getProgram = Program.objects.get(id=program)
getIndicatorTypes = IndicatorType.objects.all()
if request.method == "GET" and "search" in request.GET:
# list1 = list()
# for obj in filtered:
# list1.append(obj)
getIndicators = (
Indicator.objects.all()
.filter(
Q(indicator_type__icontains=request.GET["search"])
| Q(name__icontains=request.GET["search"])
| Q(number__icontains=request.GET["search"])
| Q(definition__startswith=request.GET["search"])
)
.filter(program__id=program)
.select_related()
.order_by("level", "number")
)
# 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/grid_report.html",
{
"getIndicators": getIndicators,
"getPrograms": getPrograms,
"getProgram": getProgram,
"form": FilterForm(),
"helper": FilterForm.helper,
"getIndicatorTypes": getIndicatorTypes,
},
)