Beispiel #1
0
 def to_entity(self, dbm):
     if self.form_model.is_registration_form():
         location = self.cleaned_data.get(LOCATION_TYPE_FIELD_CODE)
         return entity.create_entity(dbm=dbm, entity_type=self.entity_type,
                                     location=location,
                                     short_code=self.short_code,
                                     geometry=convert_to_geometry(self.cleaned_data.get(GEO_CODE)))
     return entity.get_by_short_code(dbm, self.short_code, self.entity_type)
Beispiel #2
0
 def test_case_when_location_is_present_and_geo_code_is_present_for_entity_creation(
         self):
     location_hierarchy = ['pune', 'mh', 'india']
     answers = {
         GEO_CODE: (-12, 60),
         LOCATION_TYPE_FIELD_CODE: location_hierarchy
     }
     self.assertEquals(
         (location_hierarchy, convert_to_geometry((TEST_LAT, TEST_LONG))),
         self.location.process_entity_creation(answers))
Beispiel #3
0
 def to_entity(self, dbm):
     if self.form_model.is_registration_form():
         location = self.cleaned_data.get(LOCATION_TYPE_FIELD_CODE)
         return entity.create_entity(dbm=dbm,
                                     entity_type=self.entity_type,
                                     location=location,
                                     short_code=self.short_code,
                                     geometry=convert_to_geometry(
                                         self.cleaned_data.get(GEO_CODE)))
     return entity.get_by_short_code(dbm, self.short_code, self.entity_type)
Beispiel #4
0
 def test_case_when_location_is_not_present_and_geo_code_is_present_for_entity_creation(
         self):
     answers = {GEO_CODE: (-12, 60), 'q': "sdasd"}
     self.assertEquals((TEST_LOCATION_HIERARCHY_FOR_GEO_CODE,
                        convert_to_geometry((TEST_LAT, TEST_LONG))),
                       self.location.process_entity_creation(answers))
Beispiel #5
0
 def test_should_convert_lat_long_to_geometry(self):
     lat = 19
     long = 91
     geometry = convert_to_geometry((lat, long))
     self.assertEqual(geometry['type'], 'Point')
     self.assertEqual(geometry['coordinates'], [lat, long])
Beispiel #6
0
 def test_should_return_none_for_empty_values(self):
     geometry = convert_to_geometry(None)
     self.assertTrue(geometry is None)
Beispiel #7
0
 def hierarchy_geometry_location_handler(self, geo_code, location_hierarchy):
     geometry = convert_to_geometry(self._get_geo_code_from_location_hierarchy(location_hierarchy))
     return location_hierarchy, geometry
Beispiel #8
0
 def hierarchy_geometry_geo_code_handler(self, geo_code, location_hierarchy):
     lat, long = geo_code
     location_hierarchy = self.location_tree.get_location_hierarchy_for_geocode(lat=lat,
                                                                                long=long)
     return location_hierarchy, convert_to_geometry(geo_code)
Beispiel #9
0
 def hierarchy_geometry_location_geo_code_handler(self, geo_code, location_hierarchy):
     return location_hierarchy, convert_to_geometry(geo_code)