Exemple #1
0
def _view_sector_manager_assistant_homepage(request, roles, responsibilities):
    primary_role = roles[0]

    primary_sector = responsibilities[0].sectors.all()[0]
    primary_master_plans = [
        smp.master_plan for smp in SectorMasterPlan.objects.filter(
            sector=responsibilities[0].sectors.all()[0])
    ]

    responsible_programs = responsibilities[0].programs.all()

    # Report
    for program in responsible_programs:
        program.approving_submissions = ReportSubmission.objects.filter(
            program=program,
            report__need_checkup=True,
            state=SUBMITTED_ACTIVITY)
        (late_report_count, rejected_report_count
         ) = report_functions.get_program_warning_report_count(program)
        program.late_report_count = late_report_count
        program.rejected_report_count = rejected_report_count

    return render_response(
        request, 'page_user/user_sector_assistant_dashboard.html', {
            'responsibilities': responsibilities,
            'roles': roles,
            'primary_role': primary_role,
            'primary_sector': primary_sector,
            'primary_master_plans': primary_master_plans,
            'responsible_programs': responsible_programs
        })
Exemple #2
0
def _view_sector_manager_assistant_homepage(request, roles, responsibilities):
    primary_role = roles[0]
    
    primary_sector = responsibilities[0].sectors.all()[0]
    primary_master_plans = [smp.master_plan for smp in SectorMasterPlan.objects.filter(sector=responsibilities[0].sectors.all()[0])]
    
    responsible_programs = responsibilities[0].programs.all()
    
    # Report
    for program in responsible_programs:
        program.approving_submissions = ReportSubmission.objects.filter(program=program, report__need_checkup=True, state=SUBMITTED_ACTIVITY)
        (late_report_count, rejected_report_count) = report_functions.get_program_warning_report_count(program)
        program.late_report_count = late_report_count
        program.rejected_report_count = rejected_report_count
    
    return render_response(request, 'page_user/user_sector_assistant_dashboard.html', {'responsibilities':responsibilities, 'roles':roles, 'primary_role':primary_role, 'primary_sector':primary_sector, 'primary_master_plans':primary_master_plans, 'responsible_programs':responsible_programs})
Exemple #3
0
def view_program_overview(request, program_id):
    program = get_object_or_404(Program, pk=program_id)
    current_date = date.today()
    current_projects = Project.objects.filter(program=program, start_date__lte=current_date, end_date__gte=current_date)
    
    # REPORT
    
    if permission.access_obj(request.user, 'program report submission warning', program):
        (late_report_count, rejected_report_count) = report_functions.get_program_warning_report_count(program)
    else:
        late_report_count = 0
        rejected_report_count = 0
    
    recent_reports = ReportSubmission.objects.filter(program=program).filter(Q(state=APPROVED_ACTIVITY) | (Q(state=SUBMITTED_ACTIVITY) & (Q(report__need_approval=False) | Q(report__need_checkup=False)))).order_by('-submitted_on')[:settings.RECENT_REPORTS_ON_PROGRAM_OVERVIEW]
    
    # BUDGET
    late_budget_schedules = BudgetSchedule.objects.filter(program=program, schedule_on__lt=current_date, claimed_on=None)
    
    # TODO - KPI -- Current KPI value
    
    return render_page_response(request, 'overview', 'page_program/program_overview.html', {'program':program, 'current_projects':current_projects, 'late_report_count':late_report_count, 'rejected_report_count':rejected_report_count, 'recent_reports':recent_reports, 'late_budget_schedules':late_budget_schedules})
Exemple #4
0
def view_master_plan_overview(request, master_plan_ref_no):
    master_plan = get_object_or_404(MasterPlan, ref_no=master_plan_ref_no)
    
    sectors = [smp.sector for smp in SectorMasterPlan.objects.filter(master_plan=master_plan).order_by('sector__ref_no')]
    
    programs_with_late_report = []
    programs_with_rejected_report = []
    programs_with_late_budget_claim = []
    
    for program in Program.objects.filter(plan__master_plan=master_plan):
        
        # REPORT
        (late_submission_count, rejected_submission_count) = report_functions.get_program_warning_report_count(program)
        
        if late_submission_count: programs_with_late_report.append(program)
        if rejected_submission_count: programs_with_rejected_report.append(program)
        
        # BUDGET
        late_claim_budget_amount = 0
        
        late_budget_schedules = budget_functions.get_late_budget_schedule_for_program(program)
        for schedule in late_budget_schedules:
            late_claim_budget_amount = late_claim_budget_amount + schedule.grant_budget
        
        if late_budget_schedules:
            program.late_claim_budget_amount = late_claim_budget_amount
            programs_with_late_budget_claim.append(program)
    
    # KPI
    current_date = date.today()
    (current_quarter, current_quarter_year) = utilities.find_quarter(current_date)
    
    if current_quarter == 1:
        last_quarter = 4
        last_quarter_year = current_quarter_year - 1
    else:
        last_quarter = current_quarter -1
        last_quarter_year = current_quarter_year
    
    kpi_progress = {'current_quarter':current_quarter, 'current_quarter_year':current_quarter_year, 'last_quarter':last_quarter, 'last_quarter_year':last_quarter_year}
    
    current_kpi_progress = kpi_functions.get_kpi_progress_for_master_plan_overview(master_plan, None, current_quarter, current_quarter_year)
    last_kpi_progress = kpi_functions.get_kpi_progress_for_master_plan_overview(master_plan, None, last_quarter, last_quarter_year)
    
    if current_kpi_progress != '' or last_kpi_progress != '':
        kpi_progress['no_category'] = {'current':current_kpi_progress, 'last':last_kpi_progress}
    else:
        kpi_progress['no_category'] = None
    
    kpi_categories = DomainKPICategory.objects.filter(master_plan=master_plan)
    kpi_progress_categories = []
    for kpi_category in kpi_categories:
        current_kpi_progress = kpi_functions.get_kpi_progress_for_master_plan_overview(master_plan, kpi_category, current_quarter, current_quarter_year)
        last_kpi_progress = kpi_functions.get_kpi_progress_for_master_plan_overview(master_plan, kpi_category, last_quarter, last_quarter_year)
        
        if current_kpi_progress != '' or last_kpi_progress != '':
            kpi_progress_categories.append({'kpi_category':kpi_category, 'current':current_kpi_progress, 'last':last_kpi_progress})
    
    kpi_progress['kpi_progress_categories'] = kpi_progress_categories
    
    return render_page_response(request, 'overview', 'page_sector/master_plan_overview.html', {'master_plan': master_plan, 'sectors':sectors, 'programs_with_late_report':programs_with_late_report, 'programs_with_rejected_report':programs_with_rejected_report, 'programs_with_late_budget_claim':programs_with_late_budget_claim, 'kpi_progress':kpi_progress})