def update(self, d): id = self.request.get('id') params = tools.gets(self, integers=['type'], strings=['notes', 'title', 'url', 'author', 'source'], booleans=['read', 'favorite'], lists=['tags']) if id: r = self.user.get(Readable, id=id) else: # New r = Readable.CreateOrUpdate(self.user, None, **params) if r: r.Update(**params) if r.source == 'pocket': access_token = self.user.get_integration_prop('pocket_access_token') if access_token: from services import pocket if params.get('favorite') == 1: pocket.update_article(access_token, r.source_id, action='favorite') if params.get('read') == 1: pocket.update_article(access_token, r.source_id, action='archive') r.put() self.success = True self.set_response({ 'readable': r.json() if r else None })
def delete(self, d): id = self.request.get('id') r = self.user.get(Readable, id=id) if r: if r.source == 'pocket': access_token = self.user.get_integration_prop('pocket_access_token') if access_token: from services import pocket pocket.update_article(access_token, r.source_id, action='delete') r.key.delete() self.success = True self.message = "Deleted item" else: self.message = "Couldn't find item" self.set_response()