def read(username, slug): if 'user' in session: n = session['user'] post = query.getPost(username, slug) user = query.getUser(username) if user and post: if request.method=='POST': query.newComment(username,slug,request.form['text'],session['user']) comments = query.getComments(username, slug) print comments return render_template('post.html', n=n, post=post, user=user, comments=comments) else: return render_template('error.html')
def comment(username, slug): cusername = request.form['username'] body = request.form['body'] if query.newComment(username, slug, body, cusername): return redirect('/%s/%s' % username, slug) else: return render_template('error.html', error='comment creation failed')
def read(username, slug): if 'user' in session: n = session['user'] post = query.getPost(username, slug) user = query.getUser(username) if user and post: if request.method == 'POST': query.newComment(username, slug, request.form['text'], session['user']) comments = query.getComments(username, slug) print comments return render_template('post.html', n=n, post=post, user=user, comments=comments) else: return render_template('error.html')