Ejemplo n.º 1
0
 def affected_areas(self):
     with_disasters = flatten(self.queryset.values_list('locations'))
     return len(set(with_disasters))
Ejemplo n.º 2
0
 def get_location(self, obj):
     locations = Location.objects(id__in=obj.target_locations)
     if locations.filter(type='subcounty'):
         return locations
     districts_children = [district.children() for district in locations]
     return flatten(districts_children)
Ejemplo n.º 3
0
 def affected_areas(self):
     with_disasters = flatten(self.queryset.values_list('locations'))
     return len(set(with_disasters))
Ejemplo n.º 4
0
 def get_location(self, obj):
     locations = Location.objects(id__in=obj.target_locations)
     if locations.filter(type='subcounty'):
         return locations
     districts_children = [district.children() for district in locations]
     return flatten(districts_children)
Ejemplo n.º 5
0
 def test_empty_is_discarded_when_flatten_list(self):
     list_=[[1,2],[], [4,5,6], [], [8,9]]
     self.assertEqual([1,2,4,5,6,8,9], flatten(list_))
Ejemplo n.º 6
0
 def test_flatten_list(self):
     list_=[[1,2,3],[4,5,6], [7], [8,9]]
     self.assertEqual([1,2,3,4,5,6,7,8,9], flatten(list_))