aboutsummaryrefslogtreecommitdiffstats
path: root/database.py
diff options
context:
space:
mode:
authorFulgen301 <tokmajigeorge@gmail.com>2019-07-26 13:50:12 +0200
committerFulgen301 <tokmajigeorge@gmail.com>2019-09-08 21:48:46 +0200
commit38e0af00dc06f0d4c5d9672b2c786ae7bf9be860 (patch)
tree05e72985557e79ec4089ed1d364f0e3cc9acfbc8 /database.py
parentd123729cc3e33d00f8b46c315cc22ca98fe3f068 (diff)
downloadparry-38e0af00dc06f0d4c5d9672b2c786ae7bf9be860.tar.gz
parry-38e0af00dc06f0d4c5d9672b2c786ae7bf9be860.zip
Add comment voting
Diffstat (limited to 'database.py')
-rw-r--r--database.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/database.py b/database.py
index 2559b0f..746078e 100644
--- a/database.py
+++ b/database.py
@@ -142,6 +142,24 @@ class Vote(Base):
"impact" : self.impact
}
+class CommentVote(Base):
+ __tablename__ = "commentvotes"
+ id = db.Column(Types.ObjectId, primary_key=True, default=ObjectId)
+ author_id = db.Column(Types.ObjectId, db.ForeignKey("users.id"))
+ comment_id = db.Column(Types.ObjectId, db.ForeignKey("comments.id"))
+ impact = db.Column(db.Integer, nullable=False)
+
+ author = relationship("User")
+ comment = relationship("Comment")
+
+ def json(self):
+ return {
+ "id" : self.id,
+ "author" : self.author.json(),
+ "comment" : self.comment.id,
+ "impact" : self.impact
+ }
+
#class Dependency(Base):
#__tablename__ = "dependencies"
#id = db.Column(db.Integer, primary_key=True, default=ObjectId)