From 38e0af00dc06f0d4c5d9672b2c786ae7bf9be860 Mon Sep 17 00:00:00 2001 From: Fulgen301 Date: Fri, 26 Jul 2019 13:50:12 +0200 Subject: Add comment voting --- database.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'database.py') 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) -- cgit v1.2.3-54-g00ecf