def test_get_location_filter_state(self): config = get_location_filter(self.state.location_id, self.domain_name) self.assertEqual(config, { 'aggregation_level': 2, u'state_id': self.state.location_id }) self.assertEqual(get_location_level(config['aggregation_level']), 'district')
def test_get_location_filter_district(self): config = get_location_filter(self.district.location_id, self.domain_name) self.assertEqual(config, { 'aggregation_level': 3, 'district_id': self.district.location_id, 'state_id': self.state.location_id }) self.assertEqual(get_location_level(config['aggregation_level']), 'block')
def test_get_location_filter_supervisor(self): config = get_location_filter(self.supervisor.location_id, self.domain_name) self.assertEqual(config, { 'aggregation_level': 5, 'supervisor_id': self.supervisor.location_id, 'block_id': self.block.location_id, 'district_id': self.district.location_id, 'state_id': self.state.location_id }) self.assertEqual(get_location_level(config['aggregation_level']), 'awc')
def test_get_location_filter_block(self): config = get_location_filter(self.block.location_id, self.domain_name) self.assertEqual( config, { 'aggregation_level': 4, u'block_id': self.block.location_id, u'district_id': self.district.location_id, u'state_id': self.state.location_id }) self.assertEqual(get_location_level(config['aggregation_level']), 'supervisor')
def test_get_location_filter_awc(self): config = get_location_filter(self.awc.location_id, self.domain_name) self.assertEqual( config, { 'aggregation_level': 6, 'awc_id': self.awc.location_id, 'supervisor_id': self.supervisor.location_id, 'block_id': self.block.location_id, 'district_id': self.district.location_id, 'state_id': self.state.location_id }) self.assertEqual(get_location_level(config['aggregation_level']), 'awc')
def rows(self): if self.config['location_id']: filters = get_location_filter(self.config['location_id'], self.config['domain']) if filters.get('aggregation_level') > 1: filters['aggregation_level'] -= 1 filters['month'] = date(self.config['year'], self.config['month'], 1) awc_data = AggAwc.objects.filter( **filters).values('cases_person').order_by('month').first() return [[ "Total Population of the project:", awc_data.get('cases_person') if awc_data else 0 ]]
def rows(self): if self.config['location_id']: filters = get_location_filter(self.config['location_id'], self.config['domain']) if filters.get('aggregation_level') > 1: filters['aggregation_level'] -= 1 filters['month'] = date(self.config['year'], self.config['month'], 1) awc_data = AggAwc.objects.filter(**filters).values( 'num_awcs', 'num_launched_awcs', 'awc_num_open').order_by('month').first() return [[ 'No. of AWCs', awc_data.get('num_awcs') if awc_data else None, awc_data.get('num_launched_awcs') if awc_data else None, awc_data.get('awc_num_open') if awc_data else None ]]