def post(self): user = User.logged_in_user() try: if user: payload = request.json or {} post_key = payload.get('key') title = payload.get('title') text = payload.get('text') published = payload.get('published') image = payload.get('image') post = Node.get_by_id(post_key) post.title = title post.text = text post.published = published post.save() if image: try: if image: image = image[image.index(',') + 1:] with open(os.getcwd() + '/app' + post.images[0],"wb") as f: f.write(image.decode('base64')) except Exception, e: print str(e) return {'status': 'error', 'message': 'Update the data but image could not be saved'} return {'status': 'success', 'node': post.__dict__, 'message': 'Successfully updated the post'} else:
def post(self): user = User.logged_in_user() if user: print "Logging out", user.id if user.logout_user(): return {'status': 'success', 'message': 'Logout successfull'} return {'status': 'error', 'message': 'Something went bad'}
def post(self): user = User.logged_in_user() if user: payload = request.json or {} comment = payload.get('comment') post_key = payload.get('key') author = Node.get_by_id(user.id) post = Node.get_by_id(post_key) comment_node = Service.create_comment(author, comment, post) return {'status': 'success', 'node': comment_node.__dict__, 'message': 'Successfully posted the comment'} else: return {'status': 'error', 'message': 'Please login first.'}
def post(self): user = User.logged_in_user() try: if user: payload = request.json or {} post_key = payload.get('key') name = payload.get('name') username= payload.get('username') email= payload.get('email') phone= payload.get('phone') address= payload.get('address') facebook= payload.get('facebook') linkedin = payload.get('linkedin') _type = payload.get('type') details = payload.get('details') image = payload.get('image') profile = Node.get_by_id(post_key) profile.name = name profile.username = username profile.email = email profile.phone = phone profile.address = address profile.facebook = facebook profile.linkedin = linkedin profile.type = _type profile.details = details profile.save() if image: try: if image: image = image[image.index(',') + 1:] with open(os.getcwd() + '/app' + post.images[0],"wb") as f: f.write(image.decode('base64')) except Exception, e: print str(e) return {'status': 'error', 'message': 'Update the data but image could not be saved'} return {'status': 'success', 'node': profile.__dict__, 'message': 'Successfully updated the post'} else: