Example #1
0
    def create(self, Webapp2Instance, name, model, pin):
        user = self()

        latlon = LatLon.getCurrentPosition(Webapp2Instance)
        user.lat = latlon['lat']
        user.lon = latlon['lon']

        user.name = name
        user.model = model
        user.pin = pin

        Counter.increment('mobilecounter')
        user.identifier = Hash.sha256(str(Counter.getValue('mobilecounter')))

        user.put()

        return response.reply({'identifier': user.identifier})
Example #2
0
 def getNearbyDevices(self, Webapp2Instance, radius=None, model=None):
     output = []
     latlon = LatLon.getCurrentPosition(Webapp2Instance)
     devices = Mobile.all()
     if model:
         devices = devices.filter('model =', model)
     for device in devices:
         distance = LatLon.getDistance(latlon, {
             'lat': device.lat,
             'lon': device.lon
         })
         if radius == None or distance <= radius:
             output.append({
                 'identifier': device.identifier,
                 'distance': distance,
                 'name': device.name,
                 'model': device.model
             })
     return response.reply({'devices': output})
Example #3
0
 def create(self, Webapp2Instance, name, model, pin):
   user = self()
   
   latlon = LatLon.getCurrentPosition(Webapp2Instance)
   user.lat = latlon['lat']
   user.lon = latlon['lon']
   
   user.name = name
   user.model = model
   user.pin = pin
   
   Counter.increment('mobilecounter')
   user.identifier = Hash.sha256(str(Counter.getValue('mobilecounter')))
   
   user.put()
   
   return response.reply({
     'identifier': user.identifier
   })
Example #4
0
 def getNearbyDevices(self, Webapp2Instance, radius=None, model=None):
   output = []
   latlon = LatLon.getCurrentPosition(Webapp2Instance)
   devices = Mobile.all()
   if model:
     devices = devices.filter('model =', model)
   for device in devices:
     distance = LatLon.getDistance(latlon, {
       'lat': device.lat,
       'lon': device.lon
     })
     if radius==None or distance<=radius:
       output.append({
         'identifier': device.identifier,
         'distance': distance,
         'name': device.name,
         'model': device.model
       })
   return response.reply({
     'devices': output
   })