예제 #1
0
    def handle(self, *args, **options):

        if len(args) <= 0:
            raise CommandError('please specify file name')

        if not os.path.exists(args[0]):
            raise CommandError("file %s doesn't exist" % args[0])

        fullgeojson = {"type": "FeatureCollection", "features": []}
        fullgeojson["features"] = [Place.export_feature(p) for p in Place.objects.all() if Place.export_feature(p) != None]

        fullpath = os.path.join(args[0], 'full.geojson')
 
        with open(fullpath, 'w') as f:
            json.dump(fullgeojson, f, indent=4)

        print "Geojson was created successfuly"
예제 #2
0
 def test_export_feature(self):
     
     c = Client()
     c.login(username="******", password="******")
     response = c.post('/vote/', {'id': str(self.pm.id), 'positive': 'True'})
     response = c.post('/vote/', {'id': str(self.pm1.id), 'positive': 'True'})
     response = c.post('/vote/', {'id': str(self.pm2.id), 'positive': 'false'})
     c.logout()
     
     c.login(username="******", password="******")
     response = c.post('/vote/', {'id': str(self.pm.id), 'positive': 'True'})
     response = c.post('/vote/', {'id': str(self.pm1.id), 'positive': 'false'})
     response = c.post('/vote/', {'id': str(self.pm2.id), 'positive': 'false'})
     c.logout()
     
     place = Place.objects.get(vendor_id=1000)
     
     feature = Place.export_feature(place)
     print feature
     
     self.assertEqual(1,1)