forked from MarseyWorld/MarseyWorld
fdsfds
parent
5fdd807363
commit
9dbcbc9cd5
|
@ -399,7 +399,8 @@ class SaveRelationship(Base):
|
||||||
|
|
||||||
__tablename__="save_relationship"
|
__tablename__="save_relationship"
|
||||||
|
|
||||||
id=Column(Integer, primary_key=true)
|
id=Column(Integer, primary_key=True)
|
||||||
user_id=Column(Integer, ForeignKey("users.id"))
|
user_id=Column(Integer)
|
||||||
submission_id=Column(Integer, ForeignKey("submissions.id"))
|
submission_id=Column(Integer)
|
||||||
|
comment_id=Column(Integer)
|
||||||
type=Column(Integer)
|
type=Column(Integer)
|
|
@ -537,7 +537,7 @@ class User(Base):
|
||||||
|
|
||||||
def saved_comment_idlist(self):
|
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))
|
comments = g.db.query(Comment.id).options(lazyload('*')).filter(Comment.id.in_(saved))
|
||||||
|
|
||||||
if self.admin_level == 0:
|
if self.admin_level == 0:
|
||||||
|
|
|
@ -844,10 +844,10 @@ def save_comment(cid, v):
|
||||||
|
|
||||||
comment=get_comment(cid)
|
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:
|
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)
|
g.db.add(new_save)
|
||||||
try: g.db.commit()
|
try: g.db.commit()
|
||||||
except: g.db.rollback()
|
except: g.db.rollback()
|
||||||
|
@ -862,7 +862,7 @@ def unsave_comment(cid, v):
|
||||||
|
|
||||||
comment=get_comment(cid)
|
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:
|
if save:
|
||||||
g.db.delete(save)
|
g.db.delete(save)
|
||||||
|
|
Loading…
Reference in New Issue