diff --git a/files/classes/submission.py b/files/classes/submission.py index 3ae1d7a6c..884958bf5 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -346,7 +346,7 @@ class Submission(Base): @lazy def realtitle(self, v): - if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): + if self.club and not (v and v.paid_dues) and not (v and v.admin_level > 1): if v: return random.choice(TROLLTITLES).format(username=v.username) else: return 'COUNTRY CLUB MEMBERS ONLY' elif self.title_html: title = self.title_html @@ -358,7 +358,7 @@ class Submission(Base): @lazy def plaintitle(self, v): - if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): + if self.club and not (v and v.paid_dues) and not (v and v.admin_level > 1): if v: return random.choice(TROLLTITLES).format(username=v.username) else: return 'COUNTRY CLUB MEMBERS ONLY' else: title = self.title diff --git a/files/classes/user.py b/files/classes/user.py index 7c9db480f..c69e55899 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -177,7 +177,7 @@ class User(Base): @property @lazy def paid_dues(self): - return self.admin_level == 6 or self.club_allowed or (self.truecoins > int(environ.get("DUES").strip()) and not self.club_banned) + return self.admin_level > 1 or self.club_allowed or (self.truecoins > int(environ.get("DUES").strip()) and not self.club_banned) def any_block_exists(self, other): diff --git a/files/helpers/get.py b/files/helpers/get.py index a2dc660a8..a9f778f1b 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -209,7 +209,7 @@ def get_comments(cids, v=None, load_parent=False): blocked.c.id, ).filter(Comment.id.in_(cids)) - if not (v and v.shadowbanned) and not (v and v.admin_level == 6): + if not (v and v.shadowbanned) and not (v and v.admin_level > 1): comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None) comments = comments.join( diff --git a/files/routes/admin.py b/files/routes/admin.py index c75abd90b..720f2b565 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -21,7 +21,7 @@ SITE_NAME = environ.get("SITE_NAME", "").strip() @app.get("/name//") -@admin_level_required(6) +@admin_level_required(2) def changename(v, id, name): if request.host != 'pcmemes.net': abort(403) user = g.db.query(User).filter_by(id=int(id)).first() @@ -33,7 +33,7 @@ def changename(v, id, name): return "User not found!" @app.get("/coins//") -@admin_level_required(6) +@admin_level_required(2) def addcoins(v, id, coins): if request.host != 'pcmemes.net': abort(403) user = g.db.query(User).filter_by(id=int(id)).first() @@ -45,7 +45,7 @@ def addcoins(v, id, coins): return "User not found!" @app.get("/truescore") -@admin_level_required(6) +@admin_level_required(2) def truescore(v): users = g.db.query(User).order_by(User.truecoins.desc()).limit(25).all() return render_template("truescore.html", v=v, users=users) @@ -53,9 +53,9 @@ def truescore(v): @app.post("/@/revert_actions") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) def revert_actions(v, username): - if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.id in [1,28,30,995,2513,3333]) or ('rama' not in request.host and 'pcm' not in request.host): + if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): user = get_user(username) if not user: abort(404) @@ -78,7 +78,7 @@ def revert_actions(v, username): @app.post("/@/club_allow") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) def club_allow(v, username): u = get_user(username, v=v) @@ -109,7 +109,7 @@ def club_allow(v, username): @app.post("/@/club_ban") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) def club_ban(v, username): u = get_user(username, v=v) @@ -139,9 +139,9 @@ def club_ban(v, username): @app.post("/@/make_admin") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) def make_admin(v, username): - if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.id in [1,28,30,995,2513,3333]) or ('rama' not in request.host and 'pcm' not in request.host): + if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): user = get_user(username) if not user: abort(404) user.admin_level = 6 @@ -152,9 +152,9 @@ def make_admin(v, username): @app.post("/@/remove_admin") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) def remove_admin(v, username): - if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.id in [1,28,30,995,2513,3333]) or ('rama' not in request.host and 'pcm' not in request.host): + if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): user = get_user(username) if not user: abort(404) user.admin_level = 0 @@ -165,9 +165,9 @@ def remove_admin(v, username): @app.post("/@/make_fake_admin") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) def make_fake_admin(v, username): - if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.id in [1,28,30,995,2513,3333]) or ('rama' not in request.host and 'pcm' not in request.host): + if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): user = get_user(username) if not user: abort(404) user.admin_level = 1 @@ -178,9 +178,9 @@ def make_fake_admin(v, username): @app.post("/@/remove_fake_admin") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) def remove_fake_admin(v, username): - if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.id in [1,28,30,995,2513,3333]) or ('rama' not in request.host and 'pcm' not in request.host): + if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): user = get_user(username) if not user: abort(404) user.admin_level = 0 @@ -191,9 +191,9 @@ def remove_fake_admin(v, username): @app.post("/admin/monthly") @limiter.limit("1/day") -@admin_level_required(6) +@admin_level_required(2) def monthly(v): - if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.id in [1,28,30,995,2513,3333]) or ('rama' not in request.host and 'pcm' not in request.host): + if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id for u in g.db.query(User).filter(User.patron > 0).all(): if u.patron == 1: procoins = 2000 @@ -211,7 +211,7 @@ def monthly(v): @app.get('/admin/rules') -@admin_level_required(6) +@admin_level_required(2) def get_rules(v): try: @@ -224,7 +224,7 @@ def get_rules(v): @app.post('/admin/rules') @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def post_rules(v): @@ -248,7 +248,7 @@ def post_rules(v): @app.get("/admin/shadowbanned") @auth_required def shadowbanned(v): - if not (v and v.admin_level == 6): abort(404) + if not (v and v.admin_level > 1): abort(404) users = [x for x in g.db.query(User).filter(User.shadowbanned != None).all()] return render_template("banned.html", v=v, users=users) @@ -256,7 +256,7 @@ def shadowbanned(v): @app.get("/admin/agendaposters") @auth_required def agendaposters(v): - if not (v and v.admin_level == 6): abort(404) + if not (v and v.admin_level > 1): abort(404) users = [x for x in g.db.query(User).filter_by(agendaposter = True).all()] return render_template("banned.html", v=v, users=users) @@ -333,7 +333,7 @@ def admin_home(v): return render_template("admin/admin_home.html", v=v, x=x) @app.post("/admin/disablesignups") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def disablesignups(v): with open('./disablesignups', 'r') as f: content = f.read() @@ -585,7 +585,7 @@ def admin_removed(v): @app.post("/agendaposter/") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def agendaposter(user_id, v): user = g.db.query(User).filter_by(id=user_id).first() @@ -638,7 +638,7 @@ def agendaposter(user_id, v): @app.post("/shadowban/") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def shadowban(user_id, v): user = g.db.query(User).filter_by(id=user_id).first() @@ -664,7 +664,7 @@ def shadowban(user_id, v): @app.post("/unshadowban/") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def unshadowban(user_id, v): user = g.db.query(User).filter_by(id=user_id).first() @@ -689,7 +689,7 @@ def unshadowban(user_id, v): @app.post("/admin/verify/") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def verify(user_id, v): user = g.db.query(User).filter_by(id=user_id).first() @@ -708,7 +708,7 @@ def verify(user_id, v): @app.post("/admin/unverify/") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def unverify(user_id, v): user = g.db.query(User).filter_by(id=user_id).first() @@ -728,7 +728,7 @@ def unverify(user_id, v): @app.post("/admin/title_change/") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def admin_title_change(user_id, v): @@ -762,7 +762,7 @@ def admin_title_change(user_id, v): @app.post("/ban_user/") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def ban_user(user_id, v): @@ -837,7 +837,7 @@ def ban_user(user_id, v): @app.post("/unban_user/") @limiter.limit("1/second") -@admin_level_required(6) +@admin_level_required(2) @validate_formkey def unban_user(user_id, v): @@ -1074,7 +1074,7 @@ def admin_distinguish_comment(c_id, v): return html @app.get("/admin/dump_cache") -@admin_level_required(6) +@admin_level_required(2) def admin_dump_cache(v): cache.clear() return {"message": "Internal cache cleared."} diff --git a/files/routes/awards.py b/files/routes/awards.py index 3f4712555..1d5e072a6 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -598,10 +598,10 @@ def award_comment(cid, v): else: return redirect("/") @app.get("/admin/awards") -@admin_level_required(6) +@admin_level_required(2) def admin_userawards_get(v): - if request.host == 'rdrama.net' and v.id not in [1,28,30,995,2513,3333]: render_template("admin/awards.html", awards=list(AWARDS2.values()), v=v) + if request.host == 'rdrama.net' and v.admin_level != 3: render_template("admin/awards.html", awards=list(AWARDS2.values()), v=v) return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v) @app.post("/admin/awards") @@ -650,7 +650,7 @@ def admin_userawards_post(v): g.db.commit() - if request.host == 'rdrama.net' and v.id not in [1,28,30,995,2513,3333]: render_template("admin/awards.html", awards=list(AWARDS2.values()), v=v) + if request.host == 'rdrama.net' and v.admin_level != 3: render_template("admin/awards.html", awards=list(AWARDS2.values()), v=v) return render_template("admin/awards.html", awards=list(AWARDS.values()), v=v) diff --git a/files/routes/comments.py b/files/routes/comments.py index 884b7f0fe..f01899c8e 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -46,7 +46,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): if comment.post and comment.post.club and not (v and v.paid_dues): 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) + 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 > 1) : abort(403) if not pid: if comment.parent_submission: pid = comment.parent_submission @@ -90,7 +90,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): blocked.c.id, ) - if not (v and v.shadowbanned) and not (v and v.admin_level == 6): + if not (v and v.shadowbanned) and not (v and v.admin_level > 1): comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None) comments=comments.filter( @@ -842,16 +842,16 @@ def toggle_pin_comment(cid, v): if comment.is_pinned: if comment.is_pinned.startswith("t:"): abort(403) else: - if v.admin_level == 6 or comment.is_pinned.endswith(" (OP)"): comment.is_pinned = None + if v.admin_level > 1 or comment.is_pinned.endswith(" (OP)"): comment.is_pinned = None else: abort(403) else: - if v.admin_level == 6: comment.is_pinned = v.username + if v.admin_level > 1: comment.is_pinned = v.username else: comment.is_pinned = v.username + " (OP)" g.db.add(comment) g.db.flush() - if v.admin_level == 6: + if v.admin_level > 1: ma=ModAction( kind="pin_comment" if comment.is_pinned else "unpin_comment", user_id=v.id, diff --git a/files/routes/front.py b/files/routes/front.py index e47a8157a..a4ccb8eae 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -28,7 +28,7 @@ def notifications(v): messages = request.values.get('messages', False) modmail = request.values.get('modmail', False) posts = request.values.get('posts', False) - if modmail and v.admin_level == 6: + if modmail and v.admin_level > 1: comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all() next_exists = (len(comments) > 25) comments = comments[:25] @@ -299,7 +299,7 @@ def changeloglist(v=None, sort="new", page=1 ,t="all"): Submission.author_id.notin_(blocked) ) - admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level == 6).all()] + admins = [x[0] for x in g.db.query(User.id).filter(User.admin_level > 1).all()] posts = posts.filter(Submission.title.ilike('_changelog%'), Submission.author_id.in_(admins)) if t != 'all': diff --git a/files/routes/posts.py b/files/routes/posts.py index 7ce39ee1e..bf9bfc29d 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -118,7 +118,7 @@ def post_id(pid, anything=None, v=None): post = get_post(pid, v=v) - if post.club and not (v and v.paid_dues) or post.private and not (v and (v.id == post.author_id or v.admin_level == 6)): abort(403) + if post.club and not (v and v.paid_dues) or post.private and not (v and (v.id == post.author_id or v.admin_level > 1)): abort(403) if v: votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() @@ -134,7 +134,7 @@ def post_id(pid, anything=None, v=None): blocked.c.id, ) - if not (v and v.shadowbanned) and not (v and v.admin_level == 6): + if not (v and v.shadowbanned) and not (v and v.admin_level > 1): comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None) comments=comments.filter( @@ -214,7 +214,7 @@ def edit_post(pid, v): p = get_post(pid) - if p.author_id != v.id and not (v.admin_level == 6 and v.id in [1,28,30,995,2513,3333]): abort(403) + if p.author_id != v.id and not (v.admin_level > 1 and v.admin_level > 2): abort(403) title = request.values.get("title", "").strip() body = request.values.get("body", "").strip() @@ -936,7 +936,7 @@ def submit_post(v): cache.delete_memoized(frontlist) cache.delete_memoized(User.userpagelisting) - if v.admin_level == 6 and ("[changelog]" in new_post.title or "(changelog)" in new_post.title): + if v.admin_level > 1 and ("[changelog]" in new_post.title or "(changelog)" in new_post.title): send_message(f"http://{site}{new_post.permalink}") cache.delete_memoized(changeloglist) diff --git a/files/routes/search.py b/files/routes/search.py index 44a59ef76..7fdcaa771 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -59,7 +59,7 @@ def searchposts(v): posts = g.db.query(Submission.id) - if not (v and v.admin_level == 6): posts = posts.filter(Submission.private == False) + if not (v and v.admin_level > 1): posts = posts.filter(Submission.private == False) if 'q' in criteria: words=criteria['q'].split() diff --git a/files/routes/static.py b/files/routes/static.py index ce4618e2a..bbe9faad8 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -15,7 +15,7 @@ site_name = environ.get("SITE_NAME").strip() def static_rules(v): if not path.exists(f'./{site_name} rules.html'): - if v and v.admin_level == 6: + if v and v.admin_level > 1: return render_template('norules.html', v=v) else: abort(404) @@ -174,7 +174,7 @@ def log(v): page=int(request.args.get("page",1)) - if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all() + if v and v.admin_level > 1: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all() else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub", ModAction.kind!="check").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all() next_exists=len(actions)>25 diff --git a/files/templates/admin/awards.html b/files/templates/admin/awards.html index ae28df17c..a7c7e159d 100644 --- a/files/templates/admin/awards.html +++ b/files/templates/admin/awards.html @@ -63,7 +63,7 @@

-	{% if 'rdrama.net' not in request.host or v.id in [1,995,2513] %}
+	{% if 'rdrama.net' not in request.host or v.admin_level > 2 %}
 		
 	{% endif %}
 {% endblock %}
\ No newline at end of file
diff --git a/files/templates/comments.html b/files/templates/comments.html
index b5dcb6912..b9401a897 100644
--- a/files/templates/comments.html
+++ b/files/templates/comments.html
@@ -33,7 +33,7 @@
 
 
 
-{% if v and v.admin_level == 6 %}
+{% if v and v.admin_level > 1 %}
 	
 {% endif %}
 
@@ -173,7 +173,7 @@
 {% set downs=c.downvotes %}
 {% set score=ups-downs %}
 
-{% if v and (v.shadowbanned or v.admin_level == 6) %}
+{% if v and (v.shadowbanned or v.admin_level > 1) %}
 	{% set replies=c.replies3 %}
 {% else %}
 	{% set replies=c.replies %}
@@ -291,7 +291,7 @@
 				{% endif %}
 				{% if c.active_flags %}{{c.active_flags}} Reports{% endif %}
 				{% if c.over_18 %}+18{% endif %}
-				{% if v and v.admin_level==6 and c.author.shadowbanned %}{% endif %}
+				{% if v and v.admin_level> 1 and c.author.shadowbanned %}{% endif %}
 				{% if c.is_pinned %}{% endif %}
 				{% if c.distinguish_level %}{% endif %}
 				{% if c.is_op %}{% endif %}
@@ -319,7 +319,7 @@
 				

 				
    {% for f in c.ordered_flags %} -
  • {{f.user.username}}{% if f.reason %}: {{f.reason | safe}}{% endif %} {% if v.admin_level==6 %}[remove]{% endif %}
  • +
  • {{f.user.username}}{% if f.reason %}: {{f.reason | safe}}{% endif %} {% if v.admin_level> 1 %}[remove]{% endif %}
  • {% endfor %}
@@ -461,7 +461,7 @@ {% endif %} {% endif %} - {% if v and v.admin_level==6 and v.id==c.author_id %} + {% if v and v.admin_level> 1 and v.id==c.author_id %} Undistinguish Distinguish {% endif %} @@ -496,7 +496,7 @@ Mark +18 {% endif %} - {% if v and v.admin_level==6 and v.id != c.author_id %} + {% if v and v.admin_level> 1 and v.id != c.author_id %} Unban user Ban user {% endif %} @@ -661,7 +661,7 @@ Unmark +18 {% endif %} - {% if v and (c.post and v.admin_level == 6) %} + {% if v and (c.post and v.admin_level > 1) %} {% if c.author_id != v.id %} Ban user Unban user @@ -689,7 +689,7 @@ {% if v %} {% include "gif_modal.html" %} {% include "emoji_modal.html" %} - {% if v.admin_level == 6 %} + {% if v.admin_level > 1 %} {% include "ban_modal.html" %} {% endif %} diff --git a/files/templates/header.html b/files/templates/header.html index 994cf289d..30f8db4f7 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -63,7 +63,7 @@ - {% if v and v.admin_level==6 %} + {% if v and v.admin_level> 1 %} diff --git a/files/templates/notifications.html b/files/templates/notifications.html index 1999f56f6..fb87f91b7 100644 --- a/files/templates/notifications.html +++ b/files/templates/notifications.html @@ -30,7 +30,7 @@ Messages - {% if v.admin_level==6 %} + {% if v.admin_level> 1 %}