예제 #1
0
파일: tests.py 프로젝트: avukonke/jmbo
 def setUp(self):
     country = Country(name="South Africa", country_code="ZA")
     country.save()
     self.ct = City(name="Cape Town",
                    country=country,
                    coordinates=fromstr('POINT(18.423218 -33.925839)',
                                        srid=4326))
     self.ct.save()
     loc1 = Location(city=self.ct,
                     country=country,
                     coordinates=fromstr('POINT(18.41 -33.91)', srid=4326),
                     name='loc1')
     loc1.save()
     self.model = ModelBase(title="title1", location=loc1)
     self.model.save()
예제 #2
0
 def setUp(self):
     country = Country(name="South Africa", country_code="ZA")
     country.save()
     self.ct = City(
         name="Cape Town",
         country=country,
         coordinates=fromstr('POINT(18.423218 -33.925839)', srid=4326)
     )
     self.ct.save()
     loc1 = Location(
         city=self.ct,
         country=country,
         coordinates=fromstr('POINT(18.41 -33.91)', srid=4326),
         name='loc1'
     )
     loc1.save()
     self.model = ModelBase(title="title1", location=loc1)
     self.model.save()
예제 #3
0
파일: tasks.py 프로젝트: praekelt/ummeli
def create_task(campaign, r):
    t = TomTomMicroTask(poi_id=r['POI_ID'])
    loc = Location()
    # srid is the ID for the coordinate system, 4326
    # specifies longitude/latitude coordinates
    loc.coordinates = fromstr("POINT (%s %s)" % (r['X'], r['Y']), srid=4326)
    city = get_city(position=loc.coordinates)

    if not city:
        logger.error('Unable to create task: %s - %s. Could not obtain city from coordinates. (%s, %s)',
            r['NAME'], r['POI_ID'], r['Y'], r['X'])
        return

    loc.city = city
    loc.country = city.country
    loc.save()

    t.title = r['NAME']
    t.description = '%s %s' % (r['NAME_ALT'], r['ADDRESS'])
    t.category = r['CAT_NAME']
    t.location = loc
    t.tel_1 = r['TEL_NR']
    t.tel_2 = r['TEL_NR2']
    t.fax = r['FAX_NR']
    t.email = r['E_MAIL']
    t.website = r['WEBSITE']

    t.city = r['CITY']
    t.suburb = r['SUBURB']
    t.owner = campaign.owner
    t.campaign = campaign
    t.save()

    t.province.add(Province.from_str(r['PROVINCE']))
    t.sites.add(Site.objects.get_current())

    t.publish()