def get(self,key): res = {} user_key = self.get_secure_cookie("user_key") b_key = "%s%s" % (user_key,key) boardFollow = BoardFollow() if boardFollow.get(b_key): res['code'] = 1 res['msg'] = "您已关注过了" else: board = Board() board.key = key board.data = board.get(key) board.data['follow'] = int(board.data['follow']) + 1 board.put() boardFollow.key = b_key boardFollow.data['user'] = user_key boardFollow.data['board'] = key boardFollow.data['createTime'] = int(time.time()) boardFollow.post() res['code'] = 0 res['msg'] = "成功" print res res_str = json.dumps(res) self.write(res_str)
def formatFollowBoardData(self,key): user_key = self.get_secure_cookie("user_key") f_board = {} if user_key: f_key = "%s%s" % (user_key,key) boardFollow = BoardFollow() if boardFollow.get(f_key): f_board['rel'] = 1 f_board['str'] = "取消关注" else: f_board['rel'] = 0 f_board['str'] = "关注" else: f_board['rel'] = 0 f_board['str'] = "关注" return f_board