diff --git a/files/classes/user.py b/files/classes/user.py index 9696f9300c..7c5ad1d5d5 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -262,7 +262,7 @@ class User(Base): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) + posts = posts.order_by(Submission.upvotes/Submission.downvotes + Submission.downvotes/Submission.upvotes) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": diff --git a/files/routes/admin.py b/files/routes/admin.py index 81ce2429bb..5e2bc07bdf 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -990,7 +990,11 @@ def admin_title_change(user_id, v): user=g.db.query(User).filter_by(id=user.id).one_or_none() user.customtitle=new_name if request.values.get("locked"): user.flairchanged = int(time.time()) + 2629746 - else: user.flairchanged = None + else: + user.flairchanged = None + badge = user.has_badge(96) + if badge: g.db.delete(badge) + g.db.add(user) if user.flairchanged: kind = "set_flair_locked" diff --git a/files/routes/front.py b/files/routes/front.py index c3dd291339..fea8457480 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -323,7 +323,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) + posts = posts.order_by(Submission.upvotes/Submission.downvotes + Submission.downvotes/Submission.upvotes) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": @@ -435,7 +435,7 @@ def changeloglist(v=None, sort="new", page=1 ,t="all"): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) + posts = posts.order_by(Submission.upvotes/Submission.downvotes + Submission.downvotes/Submission.upvotes) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": @@ -499,7 +499,7 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) + comments = comments.order_by(Comment.upvotes/Comment.downvotes + Comment.downvotes/Comment.upvotes) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom": diff --git a/files/routes/posts.py b/files/routes/posts.py index 327fc1f9a5..f67932c809 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -179,7 +179,7 @@ def post_id(pid, anything=None, v=None, sub=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) + comments = comments.order_by(Comment.upvotes/Comment.downvotes + Comment.downvotes/Comment.upvotes) elif sort == "top": comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": @@ -198,7 +198,7 @@ def post_id(pid, anything=None, v=None, sub=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) + comments = comments.order_by(Comment.upvotes/Comment.downvotes + Comment.downvotes/Comment.upvotes) elif sort == "top": comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": @@ -307,7 +307,7 @@ def viewmore(v, pid, sort, offset): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) + comments = comments.order_by(Comment.upvotes/Comment.downvotes + Comment.downvotes/Comment.upvotes) elif sort == "top": comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": @@ -324,7 +324,7 @@ def viewmore(v, pid, sort, offset): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) + comments = comments.order_by(Comment.upvotes/Comment.downvotes + Comment.downvotes/Comment.upvotes) elif sort == "top": comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": diff --git a/files/routes/search.py b/files/routes/search.py index b99d19f683..a02c4f5677 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -149,7 +149,7 @@ def searchposts(v): elif sort == "old": posts = posts.order_by(Submission.created_utc.asc()) elif sort == "controversial": - posts = posts.order_by(-1 * Submission.upvotes * Submission.downvotes * Submission.downvotes) + posts = posts.order_by(Submission.upvotes/Submission.downvotes + Submission.downvotes/Submission.upvotes) elif sort == "top": posts = posts.order_by(Submission.downvotes - Submission.upvotes) elif sort == "bottom": @@ -255,7 +255,7 @@ def searchcomments(v): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) + comments = comments.order_by(Comment.upvotes/Comment.downvotes + Comment.downvotes/Comment.upvotes) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom": diff --git a/files/routes/users.py b/files/routes/users.py index b8a791c873..468b925868 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -857,7 +857,7 @@ def u_username_comments(username, v=None): elif sort == "old": comments = comments.order_by(Comment.created_utc.asc()) elif sort == "controversial": - comments = comments.order_by(-1 * Comment.upvotes * Comment.downvotes * Comment.downvotes) + comments = comments.order_by(Comment.upvotes/Comment.downvotes + Comment.downvotes/Comment.upvotes) elif sort == "top": comments = comments.order_by(Comment.downvotes - Comment.upvotes) elif sort == "bottom":