def post(self): logging.error(dir(self.auth)) if not self.auth.user: return Response('Error: authenticate first') place_key_name = self.request.form.get('place_key_name') l = Location.all().filter('osm =', place_key_name).fetch(1) if not l: l = Location(osm=place_key_name) l.put() else: l = l[0] c = Checkin(user=self.auth.user, location=l) osmpoi = OSMPOI.get_by_key_name(place_key_name) place_name = osmpoi.name if place_name: c.place_name = place_name else: c.place_key_name = osmpoi.key().name() c.user_name = self.auth.user.username c.put() return Response('Success %s, %s' % (self.auth.user, place_key_name))
def post(self): logging.error(dir(self.auth)) if not self.auth.user: return Response('Error: authenticate first') place_key_name = self.request.form.get('place_key_name') l = Location.all().filter('osm =', place_key_name).fetch(1) if not l: l = Location(osm = place_key_name) l.put() else: l = l[0] c = Checkin(user=self.auth.user, location=l) osmpoi = OSMPOI.get_by_key_name(place_key_name) place_name = osmpoi.name if place_name: c.place_name = place_name else: c.place_key_name = osmpoi.key().name() c.user_name = self.auth.user.username c.put() return Response('Success %s, %s' % (self.auth.user, place_key_name) )
def get(self): _lng = cgi.escape(self.request.get('lng')) _lat = cgi.escape(self.request.get('lat')) _distance = 5 center = geotypes.Point(float('14.550102'), float('121.056186')) #14.553803,121.050244 #results = Location.proximity_fetch(Location.all(), center, max_results=10, max_distance=100000000) results = Location.all() public_attrs = Location.public_attributes() results_obj = [r.to_dict() for r in results] self.response.out.write(simplejson.dumps({ 'status': 'success', 'results': results_obj }))
def get(self): """The API to get the list of locations from the database. The following parameters can be specified: building - (optional) the list of locations for the building floor - (optional) the list of locations for the building and floor Returns a list of locations in JSON format. An empty list will be returned if there are no results for the specified parameters.""" locations = memcache.get(MC_LOCATIONS_KEY) if not locations: locations = list(Location.all()) memcache.set(MC_LOCATIONS_KEY, locations) building = self.request.get('building') floor = self.request.get('floor') if building: if floor: f = lambda loc: loc.building == building and loc.floor == floor else: f = lambda loc: loc.building == building locations = filter(f, locations) self.render_json([str(location) for location in locations])
def get_locations(): locations = memcache.get(MC_LOCATIONS_KEY) if not locations: locations = list(Location.all()) memcache.set(MC_LOCATIONS_KEY, locations) return locations