diff --git a/files/classes/user.py b/files/classes/user.py index 4a16ba17a..1d1427242 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -93,6 +93,7 @@ class User(Base, Stndrd, Age_times): is_banned = Column(Integer, default=0) unban_utc = Column(Integer, default=0) ban_reason = Column(String) + club_banned = Column(Boolean, default=False) login_nonce = Column(Integer, default=0) reserved = Column(String(256)) coins = Column(Integer, default=0) @@ -224,6 +225,11 @@ class User(Base, Stndrd, Age_times): comments = comments.options(contains_eager(Comment.post)) + if not v: + comments = comments.filter(Submission.club == False) + elif v.admin_level < 3 and (v.coins < 750 or v.club_banned): + comments = comments.filter(Submission.club == False) + now = int(time.time()) if t == 'hour': cutoff = now - 3600 diff --git a/files/routes/admin.py b/files/routes/admin.py index 9d04b20b4..1a252cc76 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -45,6 +45,28 @@ def revert_actions(v, username): return {"message": "Admin actions reverted!"} +@app.post("/@/club_ban") +@admin_level_required(6) +def toggle_club_ban(v, username): + + u = get_user(username, v=v) + + if not u: + abort(404) + + if u.admin_level >= v.admin_level: + return {"error": "noob"} + + u.club_banned = not u.club_banned + + for x in u.alts: + x.club_banned = not x.club_banned + + return { + "message": f"@{username} has been kicked from the country club. Deserved." if u.club_banned else f"@{username}'s ban from club removed" + } + + @app.post("/@/make_admin") @admin_level_required(6) def make_admin(v, username): diff --git a/files/routes/comments.py b/files/routes/comments.py index 76db76bb3..a890e0a61 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -41,7 +41,11 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): comment = get_comment(cid, v=v) - if comment.post and comment.post.club and not (v and v.coins > 150): abort(403) + if comment.post and comment.post.club: + if not v: + abort(403) + elif v.admin_level < 3 and (v.coins < 750 or v.club_banned): + abort(403) if not comment.parent_submission and not (v and (comment.author.id == v.id or comment.sentto == v.id)) and not (v and v.admin_level == 6) : abort(403) diff --git a/files/routes/front.py b/files/routes/front.py index 7c4223fcd..46d2fd1a4 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -376,10 +376,11 @@ def random_post(v): def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", **kwargs): posts = g.db.query(Submission).options(lazyload('*')) + cc_idlist = g.db.query(Submission.id).filter(Submission.club == True).subquery() posts = posts.subquery() - comments = g.db.query(Comment).options(lazyload('*')) + comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission.notin_(cc_idlist)) if v and v.admin_level <= 3: blocking = g.db.query( diff --git a/files/routes/login.py b/files/routes/login.py index c8776c68f..27b0b0439 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -362,7 +362,8 @@ def sign_up_post(v): created_utc=int(time.time()), referred_by=ref_id or None, ban_evade = int(any([x.is_banned and not x.unban_utc for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])), - agendaposter = any([x.agendaposter for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]) + agendaposter = any([x.agendaposter for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]), + club_banned=any([x.club_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]) ) g.db.add(new_user) diff --git a/files/routes/posts.py b/files/routes/posts.py index 218dfe3ad..0075c15db 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -33,7 +33,7 @@ def toggle_club(pid, v): post = get_post(pid) - if not post.author_id == v.id and not v.admin_level >= 3: abort(403) + if not (post.author_id == v.id and not v.club_banned) or not v.admin_level >= 3: abort(403) post.club = not post.club g.db.add(post) @@ -88,18 +88,6 @@ def post_id(pid, anything=None, v=None): if v: defaultsortingcomments = v.defaultsortingcomments else: defaultsortingcomments = "top" sort=request.args.get("sort", defaultsortingcomments) - - - - - - - - - - - - try: pid = int(pid) except: @@ -108,7 +96,12 @@ def post_id(pid, anything=None, v=None): post = get_post(pid, v=v) - if post.club and not (v and v.coins > 150): abort(403) + if post.club: + if not v: + abort(403) + elif v.admin_level < 3 and (v.coins < 750 or v.club_banned): + abort(403) + if v: votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() diff --git a/files/templates/submit.html b/files/templates/submit.html index d384415dc..ae48219b6 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -375,10 +375,10 @@ - {% if v.admin_level == 6 or v.coins > 150 %} + {% if v.admin_level == 6 or (v.coins >= 750 and not v.club_banned) %}
- +
{% endif %}
diff --git a/files/templates/userpage.html b/files/templates/userpage.html
index efb5f6738..bc021696d 100644
--- a/files/templates/userpage.html
+++ b/files/templates/userpage.html
@@ -327,6 +327,12 @@
 							
 							
 						
+
+						{% if u.club_banned %}
+						
+						{% else %}
+						
+						{% endif %}
 					{% endif %}
 					

 					

User ID: {{u.id}}

@@ -505,6 +511,13 @@ {% if v.admin_level > 1 %} + + {% if u.club_banned %} + + {% else %} + + {% endif %} +