def all(request): weibos = Weibo.all_json() comments = Comment.all_json() for w in weibos: w['comments'] = [] for c in comments: if c['weibo_id'] == w['id']: w['comments'].append(c) return json_response(weibos)
def all(): weibos = Weibo.all_json() comments = Comment.all_json() for weibo in weibos: weibo['comments'] = [] for comment in comments: if weibo['id'] == comment['weibo_id']: weibo['comments'].append(comment) log('这是一个微博', weibo, type(weibo)) weibo['username'] = User.one_for_id(id=weibo['user_id']).username log('这是U', User.one_for_id(id=weibo['user_id']).username) log('这是comm', weibos) return jsonify(weibos)
def comment_add(request): form = request.json() u = current_user(request) c = Comment(form) c.user_id = u.id c.save() comments = c.all_json() comment_list = [] for i in range(len(comments)): comment_list.append( dict( id=comments[i]['id'], content=comments[i]['content'], user_id=comments[i]['user_id'], weibo_id=comments[i]['weibo_id'], comment_user=User.find_by(id=comments[i]['user_id']).username)) comments = comment_list[-1] return json_response(comments)
def all(request): weibos = Weibo.all_json() comments = Comment.all_json() weibo_all = [] for w in weibos: dvyyweibo = {} dvyyweibo['weibo'] = w list = [] u = User.find_by(id=w['user_id']) dvyyweibo['username'] = u.username for c in comments: if w['id'] == c['weibo_id']: list.append(c) dvyyweibo['comment'] = list log('w_c', dvyyweibo) weibo_all.append(dvyyweibo) log('qrbuweibo', weibo_all) form = { 'weibo_comment': weibo_all, } log('xnzidm', form) return json_response(form)
def all(): comments = Comment.all_json() return jsonify(comments)
def all(request): comments = Comment.all_json() return json_response(comments)
def comment_all(request): comments = Comment.all_json() log('comments', comments) return json_response(comments)
def all(request): weibos = Weibo.all_json() comments = Comment.all_json() all = (weibos, comments) return json_response(all)