From 9dbcbc9cd5e3e05358673734508399b979b1efa5 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 10 Oct 2021 06:25:34 +0200 Subject: [PATCH] fdsfds --- files/classes/submission.py | 7 ++++--- files/classes/user.py | 2 +- files/routes/comments.py | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 214beee0e..8c4a9071d 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -399,7 +399,8 @@ class SaveRelationship(Base): __tablename__="save_relationship" - id=Column(Integer, primary_key=true) - user_id=Column(Integer, ForeignKey("users.id")) - submission_id=Column(Integer, ForeignKey("submissions.id")) + id=Column(Integer, primary_key=True) + user_id=Column(Integer) + submission_id=Column(Integer) + comment_id=Column(Integer) type=Column(Integer) \ No newline at end of file diff --git a/files/classes/user.py b/files/classes/user.py index db38b250d..460af97bd 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -537,7 +537,7 @@ class User(Base): def saved_comment_idlist(self): - saved = [x[0] for x in g.db.query(SaveRelationship.submission_id).options(lazyload('*')).filter(SaveRelationship.user_id == self.id).all()] + saved = [x[0] for x in g.db.query(SaveRelationship.comment_id).options(lazyload('*')).filter(SaveRelationship.user_id == self.id).all()] comments = g.db.query(Comment.id).options(lazyload('*')).filter(Comment.id.in_(saved)) if self.admin_level == 0: diff --git a/files/routes/comments.py b/files/routes/comments.py index 2e04063d8..c4df73b7f 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -844,10 +844,10 @@ def save_comment(cid, v): comment=get_comment(cid) - save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() + save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id, type=2).first() if not save: - new_save=SaveRelationship(user_id=v.id, submission_id=comment.id, type=2) + new_save=SaveRelationship(user_id=v.id, comment_id=comment.id, type=2) g.db.add(new_save) try: g.db.commit() except: g.db.rollback() @@ -862,7 +862,7 @@ def unsave_comment(cid, v): comment=get_comment(cid) - save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=comment.id, type=2).first() + save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id, type=2).first() if save: g.db.delete(save)