forked from rDrama/rDrama
master
parent
bf612179cc
commit
ec9797ff18
|
@ -23,7 +23,7 @@ class Comment(Base):
|
||||||
created_utc = Column(Integer)
|
created_utc = Column(Integer)
|
||||||
edited_utc = Column(Integer, default=0)
|
edited_utc = Column(Integer, default=0)
|
||||||
is_banned = Column(Boolean, default=False)
|
is_banned = Column(Boolean, default=False)
|
||||||
ghost = Column(Boolean)
|
ghost = Column(Boolean, default=False)
|
||||||
bannedfor = Column(Boolean)
|
bannedfor = Column(Boolean)
|
||||||
distinguish_level = Column(Integer, default=0)
|
distinguish_level = Column(Integer, default=0)
|
||||||
deleted_utc = Column(Integer, default=0)
|
deleted_utc = Column(Integer, default=0)
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Submission(Base):
|
||||||
thumburl = Column(String)
|
thumburl = Column(String)
|
||||||
is_banned = Column(Boolean, default=False)
|
is_banned = Column(Boolean, default=False)
|
||||||
bannedfor = Column(Boolean)
|
bannedfor = Column(Boolean)
|
||||||
ghost = Column(Boolean)
|
ghost = Column(Boolean, default=False)
|
||||||
views = Column(Integer, default=0)
|
views = Column(Integer, default=0)
|
||||||
deleted_utc = Column(Integer, default=0)
|
deleted_utc = Column(Integer, default=0)
|
||||||
distinguish_level = Column(Integer, default=0)
|
distinguish_level = Column(Integer, default=0)
|
||||||
|
|
|
@ -257,7 +257,7 @@ class User(Base):
|
||||||
posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False)
|
posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False)
|
||||||
|
|
||||||
if not (v and (v.admin_level > 1 or v.id == self.id)):
|
if not (v and (v.admin_level > 1 or v.id == self.id)):
|
||||||
posts = posts.filter_by(deleted_utc=0, is_banned=False, private=False, ghost=None)
|
posts = posts.filter_by(deleted_utc=0, is_banned=False, private=False, ghost=False)
|
||||||
|
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
if t == 'hour':
|
if t == 'hour':
|
||||||
|
|
|
@ -64,7 +64,7 @@ def searchposts(v):
|
||||||
|
|
||||||
|
|
||||||
if 'author' in criteria:
|
if 'author' in criteria:
|
||||||
posts = posts.filter(Submission.ghost == None)
|
posts = posts.filter(Submission.ghost == False)
|
||||||
author = get_user(criteria['author'])
|
author = get_user(criteria['author'])
|
||||||
if not author: return {"error": "User not found"}
|
if not author: return {"error": "User not found"}
|
||||||
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
|
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
|
||||||
|
@ -211,7 +211,7 @@ def searchcomments(v):
|
||||||
comments = g.db.query(Comment.id).filter(Comment.parent_submission != None)
|
comments = g.db.query(Comment.id).filter(Comment.parent_submission != None)
|
||||||
|
|
||||||
if 'author' in criteria:
|
if 'author' in criteria:
|
||||||
comments = comments.filter(Comment.ghost == None)
|
comments = comments.filter(Comment.ghost == False)
|
||||||
author = get_user(criteria['author'])
|
author = get_user(criteria['author'])
|
||||||
if not author: return {"error": "User not found"}
|
if not author: return {"error": "User not found"}
|
||||||
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
|
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
|
||||||
|
|
|
@ -109,9 +109,9 @@ def downvoters(v, username):
|
||||||
def upvoting(v, username):
|
def upvoting(v, username):
|
||||||
id = get_user(username).id
|
id = get_user(username).id
|
||||||
|
|
||||||
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==None, Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==False, Vote.vote_type==1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
||||||
|
|
||||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==None, CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==False, CommentVote.vote_type==1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||||
|
|
||||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||||
|
|
||||||
|
@ -133,9 +133,9 @@ def upvoting(v, username):
|
||||||
def downvoting(v, username):
|
def downvoting(v, username):
|
||||||
id = get_user(username).id
|
id = get_user(username).id
|
||||||
|
|
||||||
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==None, Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
votes = g.db.query(Submission.author_id, func.count(Submission.author_id)).join(Vote, Vote.submission_id==Submission.id).filter(Submission.ghost==False, Vote.vote_type==-1, Vote.user_id==id).group_by(Submission.author_id).order_by(func.count(Submission.author_id).desc()).all()
|
||||||
|
|
||||||
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==None, CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
votes2 = g.db.query(Comment.author_id, func.count(Comment.author_id)).join(CommentVote, CommentVote.comment_id==Comment.id).filter(Comment.ghost==False, CommentVote.vote_type==-1, CommentVote.user_id==id).group_by(Comment.author_id).order_by(func.count(Comment.author_id).desc()).all()
|
||||||
|
|
||||||
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ def u_username_comments(username, v=None):
|
||||||
comments = g.db.query(Comment.id).filter(Comment.author_id == u.id, Comment.parent_submission != None)
|
comments = g.db.query(Comment.id).filter(Comment.author_id == u.id, Comment.parent_submission != None)
|
||||||
|
|
||||||
if not v or (v.id != u.id and v.admin_level == 0):
|
if not v or (v.id != u.id and v.admin_level == 0):
|
||||||
comments = comments.filter(Comment.deleted_utc == 0, Comment.is_banned == False, Comment.ghost == None)
|
comments = comments.filter(Comment.deleted_utc == 0, Comment.is_banned == False, Comment.ghost == False)
|
||||||
|
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
if t == 'hour':
|
if t == 'hour':
|
||||||
|
|
Loading…
Reference in New Issue