forked from rDrama/rDrama
don't count deleted posts and comments
parent
894011335b
commit
747ccf5dab
|
@ -582,7 +582,11 @@ def api_comment(v):
|
||||||
|
|
||||||
cache.delete_memoized(comment_idlist)
|
cache.delete_memoized(comment_idlist)
|
||||||
|
|
||||||
v.comment_count = g.db.query(Comment).filter(Comment.author_id == v.id, Comment.parent_submission != None).count()
|
v.comment_count = g.db.query(Comment).filter(
|
||||||
|
Comment.author_id == v.id,
|
||||||
|
Comment.parent_submission != None,
|
||||||
|
Comment.deleted_utc == 0
|
||||||
|
).count()
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
c.voted = 1
|
c.voted = 1
|
||||||
|
@ -794,6 +798,13 @@ def delete_comment(cid, v):
|
||||||
|
|
||||||
cache.delete_memoized(comment_idlist)
|
cache.delete_memoized(comment_idlist)
|
||||||
|
|
||||||
|
g.db.flush()
|
||||||
|
v.comment_count = g.db.query(Comment).filter(
|
||||||
|
Comment.author_id == v.id,
|
||||||
|
Comment.parent_submission != None,
|
||||||
|
Comment.deleted_utc == 0
|
||||||
|
).count()
|
||||||
|
g.db.add(v)
|
||||||
|
|
||||||
return {"message": "Comment deleted!"}
|
return {"message": "Comment deleted!"}
|
||||||
|
|
||||||
|
@ -814,6 +825,13 @@ def undelete_comment(cid, v):
|
||||||
|
|
||||||
cache.delete_memoized(comment_idlist)
|
cache.delete_memoized(comment_idlist)
|
||||||
|
|
||||||
|
g.db.flush()
|
||||||
|
v.comment_count = g.db.query(Comment).filter(
|
||||||
|
Comment.author_id == v.id,
|
||||||
|
Comment.parent_submission != None,
|
||||||
|
Comment.deleted_utc == 0
|
||||||
|
).count()
|
||||||
|
g.db.add(v)
|
||||||
|
|
||||||
return {"message": "Comment undeleted!"}
|
return {"message": "Comment undeleted!"}
|
||||||
|
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ def submit_post(v, sub=None):
|
||||||
post.comment_count += 1
|
post.comment_count += 1
|
||||||
post.replies = [c]
|
post.replies = [c]
|
||||||
|
|
||||||
v.post_count = g.db.query(Submission).filter_by(author_id=v.id).count()
|
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
if v.id == PIZZASHILL_ID:
|
if v.id == PIZZASHILL_ID:
|
||||||
|
@ -1234,11 +1234,10 @@ def submit_post(v, sub=None):
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}')
|
@limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{request.host}-{session.get("lo_user")}')
|
||||||
@auth_required
|
@auth_required
|
||||||
def delete_post_pid(pid, v):
|
def delete_post_pid(pid, v):
|
||||||
|
|
||||||
post = get_post(pid)
|
post = get_post(pid)
|
||||||
if post.author_id != v.id:
|
if post.author_id != v.id: abort(403)
|
||||||
abort(403)
|
|
||||||
|
|
||||||
|
if not post.deleted_utc:
|
||||||
post.deleted_utc = int(time.time())
|
post.deleted_utc = int(time.time())
|
||||||
post.is_pinned = False
|
post.is_pinned = False
|
||||||
post.stickied = None
|
post.stickied = None
|
||||||
|
@ -1248,6 +1247,9 @@ def delete_post_pid(pid, v):
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
cache.delete_memoized(User.userpagelisting)
|
cache.delete_memoized(User.userpagelisting)
|
||||||
|
|
||||||
|
g.db.flush()
|
||||||
|
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
|
||||||
|
g.db.add(v)
|
||||||
|
|
||||||
return {"message": "Post deleted!"}
|
return {"message": "Post deleted!"}
|
||||||
|
|
||||||
|
@ -1258,12 +1260,17 @@ def delete_post_pid(pid, v):
|
||||||
def undelete_post_pid(pid, v):
|
def undelete_post_pid(pid, v):
|
||||||
post = get_post(pid)
|
post = get_post(pid)
|
||||||
if post.author_id != v.id: abort(403)
|
if post.author_id != v.id: abort(403)
|
||||||
|
|
||||||
|
if post.deleted_utc:
|
||||||
post.deleted_utc = 0
|
post.deleted_utc = 0
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
cache.delete_memoized(User.userpagelisting)
|
cache.delete_memoized(User.userpagelisting)
|
||||||
|
|
||||||
|
g.db.flush()
|
||||||
|
v.post_count = g.db.query(Submission).filter_by(author_id=v.id, deleted_utc=0).count()
|
||||||
|
g.db.add(v)
|
||||||
|
|
||||||
return {"message": "Post undeleted!"}
|
return {"message": "Post undeleted!"}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue