def post(self): logging.info('LoginHandler...') request = simplejson.loads(self.request.body) uid = request['fb_uid'] if uid == None: responseWithError(self.response.out, 'uid field is required') return #Get Talkyuser object if it exists or create new one query = TalkyUser.all() query.filter('fb_uid = ', uid) if query.count() > 1 : responseWithError(self.response.out, 'Query fb user\'s number > 1') return userAccount = query.get() if userAccount == None: logging.info('get result') userAccount = TalkyUser(fb_uid = uid) userAccount.put() logging.info('Create an UserAccoun TalkyUser for fb_string %s...', uid) key = userAccount.key() tid = key.id() response = {'success':True, 'talky_uid':tid} self.response.headers['Content-Type'] = 'application/json; charset=utf-8' self.response.out.write(simplejson.dumps(response))
def post(self): logging.info('GetPostHandler...') request = simplejson.loads(self.request.body) talky_uid = int(request['talky_uid']) user = TalkyUser.get_by_id(talky_uid) if user == None: logging.info('user is None') logging.info(user.spot.name) if user.spot == None: logging.info('user.spot is None') query = UserPost.all() query.filter('spotName = ', user.spot.name) posts = query.fetch(limit = 10) response = { 'success':True, 'posts':[] } for post in posts: postData = { 'owner':post.owner.fb_uid, 'id':post.key().id(), 'date_time':serializeDateTime(post.dateTime), 'content':post.content, } response['posts'].append(postData) self.response.out.write(simplejson.dumps(response))
def post(self): logging.info('SendReplyHandler...') request = simplejson.loads(self.request.body) userId = int(request['talky_uid']) postId = int(request['post_id']) content = request['content'] owner = TalkyUser.get_by_id(userId) post = UserPost.get_by_id(postId) postReply = PostReply(owner=owner, post=post, content=content) key = postReply.put() response = { 'success':True, 'reply_id':key.id() } self.response.headers['Content-Type'] = 'application/json; charset=utf-8' self.response.out.write(simplejson.dumps(response)) logging.info('DONE')
def post(self): logging.info('CreatePostHandler...') request = simplejson.loads(self.request.body) talky_uid = int(request['talky_uid']) user = TalkyUser.get_by_id(talky_uid) content = request['content'] post = UserPost(content=content, owner=user, spot=user.spot.key()) post.spotName = user.spot.name; key = post.put() response = { 'success':True, 'post_id':key.id() } self.response.headers['Content-Type'] = 'application/json; charset=utf-8' self.response.out.write(simplejson.dumps(response))
def post(self): logging.info('CheckinHandler...') request = simplejson.loads(self.request.body) talky_uid = int(request['talky_uid']) spot_id = int(request['spot_id']) user = TalkyUser.get_by_id(talky_uid) spot = Spot.get_by_id(spot_id) user.spot = spot.key() user.put() response = { 'success':True, 'checkin_times':1, 'user_list':[] } self.response.out.write(simplejson.dumps(response)) logging.info('CHECK-IN ... OK')