• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.getCountry函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tola.util.getCountry函数的典型用法代码示例。如果您正苦于以下问题:Python getCountry函数的具体用法?Python getCountry怎么用?Python getCountry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getCountry函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 }) 
开发者ID:mercycorps,项目名称:TolaActivity,代码行数:34,代码来源:views.py


示例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)
开发者ID:AugustMiller,项目名称:TolaActivity,代码行数:30,代码来源:forms.py


示例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})
开发者ID:AugustMiller,项目名称:TolaActivity,代码行数:29,代码来源:views.py


示例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})
开发者ID:minedamnesia,项目名称:TolaActivity,代码行数:57,代码来源:views.py


示例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})
开发者ID:toladata,项目名称:TolaActivity,代码行数:56,代码来源:views.py


示例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})
开发者ID:mercycorps,项目名称:TolaActivity,代码行数:56,代码来源:views.py


示例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})
开发者ID:toladata,项目名称:TolaActivity,代码行数:10,代码来源:views.py


示例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)
开发者ID:toladata,项目名称:TolaActivity,代码行数:10,代码来源:admin.py


示例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})
开发者ID:AugustMiller,项目名称:TolaActivity,代码行数:55,代码来源:views.py


示例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})
开发者ID:AugustMiller,项目名称:TolaActivity,代码行数:54,代码来源:views.py


示例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})
开发者ID:minedamnesia,项目名称:TolaActivity,代码行数:11,代码来源:views.py


示例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,
        },
    )
开发者ID:mercycorps,项目名称:TolaActivity,代码行数:52,代码来源:views.py


示例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)
开发者ID:toladata,项目名称:TolaActivity,代码行数:16,代码来源:views.py


示例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})
开发者ID:minedamnesia,项目名称:TolaActivity,代码行数:47,代码来源:views.py


示例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,
        },
    )
开发者ID:mercycorps,项目名称:TolaActivity,代码行数:47,代码来源:views.py


示例16: get

    def get(self, request, *args, **kwargs):

        if int(kwargs["id"]) == 0:
            del kwargs["id"]
        if int(kwargs["indicator_type"]) == 0:
            del kwargs["indicator_type"]
        if int(kwargs["program"]) == 0:
            del kwargs["program"]

        countries = getCountry(request.user)

        queryset = Indicator.objects.filter(**kwargs).filter(program__country__in=countries)

        indicator = IndicatorResource().export(queryset)
        response = HttpResponse(indicator.csv, content_type="application/ms-excel")
        response["Content-Disposition"] = "attachment; filename=indicator.csv"
        return response
开发者ID:mercycorps,项目名称:TolaActivity,代码行数:17,代码来源:views.py


示例17: __init__

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.request = kwargs.pop('request')
        self.helper.form_method = 'post'
        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.add_input(Submit('submit', 'Save'))

        super(TrainingAttendanceForm, self).__init__(*args, **kwargs)

        countries = getCountry(self.request.user)
        self.fields['project_agreement'].queryset = ProjectAgreement.objects.filter(program__country__in=countries)
        self.fields['program'].queryset = Program.objects.filter(country__in=countries)
开发者ID:toladata,项目名称:TolaActivity,代码行数:18,代码来源:forms.py


示例18: indicator_report

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})
开发者ID:minedamnesia,项目名称:TolaActivity,代码行数:40,代码来源:views.py



注:本文中的tola.util.getCountry函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python devices.Device类代码示例发布时间:2022-05-27
下一篇:
Python tokenizer.Tokenizer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap