-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommentModel.py
More file actions
38 lines (23 loc) · 836 Bytes
/
Copy pathCommentModel.py
File metadata and controls
38 lines (23 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class CommentModel:
def __init__(self):
from models import Comment
self.Comment = Comment.Comment
def comments(self, post):
comments = self.Comment.query.filter_by(Post=post.Id,Parent=None).all()
if comments:
return comments
return False
def addcomment(self, comment, email, nick, post, cid=None):
from models import db
if cid:
new_comment = self.Comment(nick, email, comment, post, cid)
else:
new_comment = self.Comment(nick, email, comment, post)
db.session.add(new_comment)
db.session.commit()
return new_comment.Id
def getCommentEmail(self, id):
comments = self.Comment.query.filter_by(Id=id).first()
if comments:
return comments
return []