Example #1
0
    def post(self):
        user = social.get_current_user()
        dev_id = self.request.get('device_id')
        default = self.request.get('default')
        if bool(default):
            device = self.set_default_device(dev_id)
        device = model.device_by(user, dev_id)
        device.name = self.request.get("name") or device.name

        serialization.json_dump(self.response, device.script_properties())
Example #2
0
 def get(self):
     dev_id = self.request.get('device_id')
     user = social.get_current_user()
     if dev_id is None or dev_id == '':
         devices = model.Device.filter_by_user(user).fetch(100)
         result = [{'id': dev.key().id(), 'name': dev.name, 'default': dev.default} for dev in devices]
     else:
         device = model.device_by(user, dev_id)
         result = device.script_properties()
     serialization.json_dump(self.response,result)
Example #3
0
 def delete(self):
     user = social.get_current_user()
     dev_id = self.request.get('device_id')
     device = model.device_by(user, dev_id)
     if device:
         urls = model.Url.all().filter("device =", device)
         urls = db.GqlQuery("SELECT __key__ FROM Url WHERE device = :1", device)
         db.delete(urls)
         device.delete()
         serialization.json_dump(self.response, {'status': 'ok'})
     else:
         log.info("Unable to delete device. Device: '%s' not found", dev_id)
         serialization.json_dump(self.response, {'status': 'error'})
Example #4
0
def post_url(user, url_value, url_title='', url_favicon='', dev_id=None):
    device = None
    if not dev_id is None:
        device = model.device_by(user, dev_id)
    url = model.Url()
    url.device = device
    url.value = url_value
    url.favicon = url_favicon
    url.title = url_title[:50]
    url.user = user
    if len(url.value) > 200:
        h = hashlib.sha1()
        h.update(url.value)
        url.hash = h.hexdigest()
    #push notifications were turned off
    #url.pushed = urban_airmail.send_push_notification(url.device.token, url.value)
    url.put()
    return url