コード例 #1
0
ファイル: delivery.py プロジェクト: ekush/commcare-hq
 def data_providers(self):
     data_providers = [
         DeliverySubmissionData(config=self.report_config,
                                css_class='row_chart_all'),
     ]
     config = self.report_config
     if config['location_id']:
         location = SQLLocation.objects.get(
             location_id=config['location_id'])
         if location.location_type.name.upper() in [
                 'REGION', 'MSDZONE', 'MOHSW'
         ]:
             data_providers.append(
                 DeliveryData(config=config, css_class='row_chart_all'))
             data_providers.append(
                 LeadTimeHistory(config=config, css_class='row_chart_all'))
         elif location.location_type.name.upper() == 'FACILITY':
             return [
                 InventoryHistoryData(config=config),
                 RandRHistory(config=config),
                 Notes(config=config),
                 RecentMessages(config=config),
                 RegistrationData(config=dict(loc_type='FACILITY',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='DISTRICT',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='REGION', **config),
                                  css_class='row_chart_all')
             ]
         else:
             data_providers.append(
                 DeliveryStatus(config=config, css_class='row_chart_all'))
     return data_providers
コード例 #2
0
 def data_providers(self):
     config = self.report_config
     if self.location:
         if self.location.location_type.name.upper() == 'FACILITY':
             self.use_datatables = True
             return [
                 InventoryHistoryData(config=config),
                 RandRHistory(config=config),
                 Notes(config=config),
                 RecentMessages(config=config),
                 RegistrationData(config=dict(loc_type='FACILITY',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='DISTRICT',
                                              **config),
                                  css_class='row_chart_all'),
                 RegistrationData(config=dict(loc_type='REGION', **config),
                                  css_class='row_chart_all')
             ]
         else:
             self.use_datatables = False
             return [
                 RandRSubmissionData(config=config),
                 DistrictSummaryData(config=config),
                 SohSubmissionData(config=config),
                 DeliverySubmissionData(config=config),
                 ProductAvailabilitySummary(config=config,
                                            css_class='row_chart_all')
             ]
     else:
         return []
コード例 #3
0
ファイル: delivery.py プロジェクト: ekush/commcare-hq
    def rows(self):
        data = DeliverySubmissionData(config=self.config,
                                      css_class='row_chart_all').rows

        if data:
            dg = data[0]
            percent_format = lambda x, y: x * 100 / (y or 1)

            return [
                [
                    _('Didn\'t Respond'),
                    '%d' % dg.not_responding,
                    '%.1f%%' % percent_format(dg.not_responding, dg.total)
                ],
                [
                    _('Not Received'),
                    '%d' % dg.not_received,
                    '%.1f%%' % percent_format(dg.not_received, dg.total)
                ],
                [
                    _('Received'),
                    '%d' % dg.received,
                    '%.1f%%' % percent_format(dg.received, dg.total)
                ],
                [_('Total'), '%d' % dg.total, '100%'],
            ]