Exemplo n.º 1
0
def dashboard(request):
    mp = MonthPager(request)
    base_facilities, location = get_facilities_and_location(request)

    dg = DeliveryGroups(mp.month, facs=base_facilities)
    sub_data = SupplyPointStatusBreakdown(base_facilities,
                                          month=mp.month,
                                          year=mp.year)
    msd_sub_count = submitted_to_msd(
        district_supply_points_below(location, dg.processing()), mp.month,
        mp.year)
    return render_to_response(
        "tanzania/dashboard.html",
        {
            "sub_data": sub_data,
            "graph_width": 300,
            "graph_height": 300,
            "dg": dg,
            "month_pager": mp,
            "msd_sub_count": msd_sub_count,
            "facs":
            list(base_facilities
                 ),  # Not named 'facilities' so it won't trigger the selector
            "districts": _user_districts(request.user),
            "regions": _user_regions(request.user),
            "location": location,
            "destination_url": "tz_dashboard"
        },
        context_instance=RequestContext(request))
Exemplo n.º 2
0
def reporting(request):
    facs, location = get_facilities_and_location(request)
    mp = MonthPager(request)
    dg = DeliveryGroups(mp.month, facs=facs)
    bd = SupplyPointStatusBreakdown(facs, mp.year, mp.month)
    ot = randr_on_time_reporting(dg.submitting(), mp.year, mp.month)

    tables, products, product_set, show = _generate_soh_tables(request, facs, mp)

    return render_to_response("tanzania/new-reports.html",
        {
          "location": location,
          "month_pager": mp,
          "districts": _user_districts(request.user),
          "regions": _user_regions(request.user),
          "facs": facs,
          "product_set": product_set,
          "products": products,
          "tables": tables,
          "show": show,
          "dg": dg,
          "bd": bd,
          "on_time": ot,
          "reporting_percentage": (float(len(bd.submitted)) / float(len(dg.submitting())) * 100) if len(dg.submitting()) else 0.0,
          "on_time_percentage": (float(len(ot)) / float(len(bd.submitted)) * 100) if len(bd.submitted) else 0.0,
          "supervision_table": SupervisionTable(object_list=dg.submitting().select_related(), request=request,
                                                month=mp.month, year=mp.year, prefix="supervision"),
          "randr_status_table": RandRStatusTable(object_list=dg.submitting().select_related(), request=request, month=mp.month, year=mp.year),
          "delivery_status_table": DeliveryStatusTable(object_list=dg.delivering().select_related(), request=request, month=mp.month, year=mp.year),
          "randr_history_table": RandRReportingHistoryTable(object_list=dg.submitting().select_related(), request=request,
                                                    month=mp.month, year=mp.year, prefix="randr_history"),
          "destination_url": "reports"
        },
        context_instance=RequestContext(request))
Exemplo n.º 3
0
def dashboard(request):
    mp = MonthPager(request)
    base_facilities, location = get_facilities_and_location(request)
    
    dg = DeliveryGroups(mp.month, facs=base_facilities)
    sub_data = SupplyPointStatusBreakdown(base_facilities, month=mp.month, year=mp.year)
    msd_sub_count = submitted_to_msd(district_supply_points_below(location, dg.processing()), mp.month, mp.year)
    return render_to_response("tanzania/dashboard.html",
                              {"sub_data": sub_data,
                               "graph_width": 300,
                               "graph_height": 300,
                               "dg": dg,
                               "month_pager": mp,
                               "msd_sub_count": msd_sub_count,
                               "facs": list(base_facilities), # Not named 'facilities' so it won't trigger the selector
                               "districts": _user_districts(request.user),
                               "regions": _user_regions(request.user),
                               "location": location,
                               "destination_url": "tz_dashboard"
                               },
                               
                              context_instance=RequestContext(request))
Exemplo n.º 4
0
 def reset_context(self):
     # Stuff common to all the reports.
     self.context = self.base_context.copy()
     self.facs, self.location = get_facilities_and_location(self.request)
     self.mp = MonthPager(self.request)
     self.dg = DeliveryGroups(self.mp.month, facs=self.facs)
     self.bd = SupplyPointStatusBreakdown(self.facs, self.mp.year,
                                          self.mp.month)
     report_list = [{
         "name": r.name,
         "slug": r.slug
     } for r in REPORT_LIST]  # hack to get around 1.3 brokenness
     self.context.update({
         "facs":
         self.facs,
         "month_pager":
         self.mp,
         "location":
         self.location,
         "level":
         self.location.type.name,
         "dg":
         self.dg,
         "bd":
         self.bd,
         "report_list":
         report_list,
         "slug":
         self.slug,
         "name":
         self.name,
         "destination_url":
         reverse('new_reports', args=(self.slug, )),
         "nav_mode":
         "direct-param",
     })
Exemplo n.º 5
0
def reporting(request):
    facs, location = get_facilities_and_location(request)
    mp = MonthPager(request)
    dg = DeliveryGroups(mp.month, facs=facs)
    bd = SupplyPointStatusBreakdown(facs, mp.year, mp.month)
    ot = randr_on_time_reporting(dg.submitting(), mp.year, mp.month)

    tables, products, product_set, show = _generate_soh_tables(
        request, facs, mp)

    return render_to_response("tanzania/new-reports.html", {
        "location":
        location,
        "month_pager":
        mp,
        "districts":
        _user_districts(request.user),
        "regions":
        _user_regions(request.user),
        "facs":
        facs,
        "product_set":
        product_set,
        "products":
        products,
        "tables":
        tables,
        "show":
        show,
        "dg":
        dg,
        "bd":
        bd,
        "on_time":
        ot,
        "reporting_percentage":
        (float(len(bd.submitted)) / float(len(dg.submitting())) *
         100) if len(dg.submitting()) else 0.0,
        "on_time_percentage": (float(len(ot)) / float(len(bd.submitted)) *
                               100) if len(bd.submitted) else 0.0,
        "supervision_table":
        SupervisionTable(object_list=dg.submitting().select_related(),
                         request=request,
                         month=mp.month,
                         year=mp.year,
                         prefix="supervision"),
        "randr_status_table":
        RandRStatusTable(object_list=dg.submitting().select_related(),
                         request=request,
                         month=mp.month,
                         year=mp.year),
        "delivery_status_table":
        DeliveryStatusTable(object_list=dg.delivering().select_related(),
                            request=request,
                            month=mp.month,
                            year=mp.year),
        "randr_history_table":
        RandRReportingHistoryTable(
            object_list=dg.submitting().select_related(),
            request=request,
            month=mp.month,
            year=mp.year,
            prefix="randr_history"),
        "destination_url":
        "reports"
    },
                              context_instance=RequestContext(request))