Skip to content

Commit 76994d5

Browse files
committed
Hf
1 parent ca1d383 commit 76994d5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CommentModel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ def __init__(self):
66
self.cryptkey = appconfig.CRYPT_KEY
77

88

9-
def comments(self):
9+
def comments(self, post):
1010

1111
db = DB()
12-
sql = '''SELECT * FROM Comment'''
12+
sql = '''SELECT * FROM Comment WHERE Post=%s'''
1313

14-
query = db.query(sql)
14+
query = db.query(sql, (post,))
1515
comments = query.fetchall()
1616

1717
db.close()

controllers/fe.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ def read(slug=None):
2929
tag = TagModel()
3030
post = PostModel()
3131
comment = CommentModel()
32+
id = post.getPostBySlug(slug)
3233
if request.method == "POST":
3334

3435
if 'comment' in request.form:
35-
id = post.getPostBySlug(slug)
36+
3637
comment.addcomment(request.form['comment'], request.form['email'], request.form['nick'], id)
3738

38-
return render_template("home/read.html", tags=tag.tags(), post=post.post(slug), comments = comment.comments())
39+
return render_template("home/read.html", tags=tag.tags(), post=post.post(slug), comments = comment.comments(id))
3940

4041
#helper methods
4142

0 commit comments

Comments
 (0)