def delike(tweet_id): user = current_user() t = Tweet.find(tweet_id) if Tweet.check_token(): t.delike(user.id) user.delike_tweet(tweet_id) return redirect( url_for('.detail', tweet_id=tweet_id, token=gg.token[user.id]))
def wrapper(rq): tweet_id = int(rq.query.get('id', -1)) t = Tweet.find(tweet_id) user = current_user(rq) if t is not None and t.user_id == user.id: response_msg = route_func(rq) else: response_msg = redirect('/login') return response_msg
def edit(tweet_id): user = current_user() if Tweet.check_token(): # tweet_id = int(request.args.get('id', -1)) t = Tweet.find(tweet_id) Tweet.check_id(id=tweet_id) return render_template('tweet/tweet_edit.html', t=t, token=gg.token[user.id], user=user)
def edit(request): u = current_user(request) tweet_id = int(request.query.get('id', -1)) t = Tweet.find(tweet_id) if u.id == t.user_id: body = template('tweet_edit.html', tweet_id=t.id, tweet_content=t.content) return http_response(body) return redirect('/tweet/index?user_id={}'.format(u.id))
def delete(request): u = current_user(request) tweet_id = int(request.query.get('id')) t = Tweet.find(tweet_id) if u.id == t.user_id: # 这里只是删除了tweet,但是其所拥有的comment的deleted字段变成False t.remove(tweet_id) for c in t.comments(): c.deleted = True c.save() # redirect有必要加query吗 return redirect('/tweet/index?user_id={}'.format(u.id))
def edit(tweet_id): u = current_user() token = request.args.get('token') if Tweet.check_token(token, gg.csrf_tokens): # tweet_id = int(request.args.get('id', -1)) t = Tweet.find(tweet_id) if u.id == t.user_id: body = render_template('tweet_edit.html', tweet_id=t.id, tweet_content=t.content, token=token) return make_response(body) return redirect(url_for('.index'))
def delete(tweet_id): u = current_user() # tweet_id = int(request.args.get('id')) token = request.args.get('token') if Tweet.check_token(token, gg.csrf_tokens): # gg.delete_value() # csrf_tokens.pop(token) t = Tweet.find(tweet_id) if u.id == t.user_id: # 这里只是删除了tweet,但是其所拥有的comment的deleted字段变成False t.remove(tweet_id) for c in t.comments(): c.deleted = True c.save() # redirect有必要加query吗 # return redirect('/tweet/index?user_id={}'.format(u.id)) return redirect(url_for('.index'))
def delete(tweet_id): if Tweet.check_token(): t = Tweet.find(tweet_id) Tweet.check_id(id=tweet_id) t.remove_with_comments(tweet_id) return redirect(url_for('.index'))
def delete(rq): tweet_id = int(rq.query.get('id', -1)) t = Tweet.find(tweet_id) t.remove() return redirect('/tweet')
def update(rq): tweet_id = int(rq.query.get('id', -1)) t = Tweet.find(tweet_id) d = rq.form() t.update(d) return redirect('/tweet')
def edit(rq): tweet_id = int(rq.query.get('id', -1)) t = Tweet.find(tweet_id) body = template(env, 'edit.html', tweet=t) response_msg = make_response_msg(body=body) return response_msg