def blog_add(): form = request.form.to_dict() if request.method == 'POST': u = current_user() print('blog_add form = <{}>'.format(form)) b = Blog.new(form=form, user_id=u.id) return redirect(url_for('.blog_index')) return render_template('blog/blog_add.html', form=form)
def weibo_add(): form = request.get_json() u = current_user() print('/api/weibo/add form = <{}>'.format(form)) w = Weibo.new(form=form, user_id=u.id) w_json = w.to_json() print('weibo add w_json = <{}>'.format(w_json)) w_json['username'] = w.get_username() return jsonify(w_json)
def weibo_comment_add(): form = request.get_json() u = current_user() print('/api/weibo_comment/add form = <{}>'.format(form)) wc = WeiboComment.new(form=form, user_id=u.id) wc_json = wc.to_json() print('weibo comment add w_json = <{}>'.format(wc_json)) wc_json['username'] = wc.get_username() return jsonify(wc_json)
def f(*args, **kwargs): print('blog comment ownner required') print('args = <{}>'.format(args)) print('kwargs = <{}>'.format(kwargs)) u = current_user() if request.method == 'GET': bc_id = request.args.get('id') else: bc_id = request.form['id'] bc = BlogComment.find_one(id=bc_id) print('blog comment = <{}>'.format(bc)) if bc.user_id == u.id: return func(*args, **kwargs) else: return redirect('/blog/index')
def f(*args, **kwargs): print('weibo comment ownner required') print('args = <{}>'.format(args)) print('kwargs = <{}>'.format(kwargs)) u = current_user() if request.method == 'GET': wc_id = request.args.get('id') else: wc_id = request.get_json()['id'] wc = WeiboComment.find_one(id=wc_id) print('weibo comment = <{}>'.format(wc)) if wc.user_id == u.id: return func(*args, **kwargs) else: return redirect(url_for('.weibo_index'))
def f(*args, **kwargs): print('weibo ownner required') print('args = <{}>'.format(args)) print('kwargs = <{}>'.format(kwargs)) u = current_user() if request.method == 'GET': weibo_id = request.args.get('id') else: print('request form = <{}>'.format(request.get_json())) weibo_id = request.get_json()['id'] weibo = Weibo.find_one(id=weibo_id) print('weibo = <{}>'.format(weibo)) if weibo.user_id == u.id: return func(*args, **kwargs) else: return redirect(url_for('.weibo_index'))
def blog_comment_add(): form = request.form.to_dict() u = current_user() print('blog_add form = <{}>'.format(form)) bc = BlogComment.new(form=form, user_id=u.id) return redirect('/blog/detail/{}'.format(form['blog_id']))