master
Aevann1 2021-10-10 06:25:34 +02:00
parent 5fdd807363
commit 9dbcbc9cd5
3 changed files with 8 additions and 7 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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)