def post(self, tid): tid = request.form.get("tid") content = request.form.get("content") topic = get_topic(tid) sender, receiver = get_topic_users(g.current_user.id, topic.id) if not topic or not sender or not receiver: return redirect(url_for("topic.index")) make_reply(sender, receiver, topic, content) # clean cache clean_cache(g.current_user.id, receiver.uid, topic.id) backend.delete("topic:user_topic:%d:%d" % (g.current_user.id, topic.id)) backend.delete("topic:user_topic:%d:%d" % (receiver.uid, topic.id)) return redirect(url_for("topic.view", tid=tid))
def post(self, uid): if uid == g.current_user.id: return redirect(url_for('topic.index')) who = get_user(uid) to_uid = request.form.get('to_uid') title = request.form.get('title') content = request.form.get('content') if not who: #TODO return error code # check other params return render_template('topic.create.html', uid=uid) topic = make_topic(g.current_user.id, to_uid, title, content) #clean cache clean_cache(g.current_user.id, uid, topic.id) return redirect(url_for('topic.index'))