From 0349862531bb285b169f1cb976c33be195fefb5a Mon Sep 17 00:00:00 2001 From: justcool393 Date: Wed, 5 Oct 2022 19:55:54 -0700 Subject: [PATCH] view pending submitted marseys and hats perms --- files/helpers/const.py | 2 ++ files/routes/asset_submissions.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index a9e77d430..edf44e4b8 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -134,6 +134,8 @@ PERMS = { # Minimum admin_level to perform action. 'USER_SHADOWBAN': 2, 'POST_TO_CHANGELOG': 1, 'BYPASS_PIN_LIMIT': 3, + 'VIEW_PENDING_SUBMITTED_MARSEYS': 3, + 'VIEW_PENDING_SUBMITTED_HATS': 3, } FEATURES = { diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index b4aaf88f0..e03829e6a 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -22,7 +22,7 @@ def asset_submissions(path): @app.get("/submit/marseys") @auth_required def submit_marseys(v): - if v.admin_level > 2: + if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_MARSEYS']: marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all() else: marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all() @@ -44,7 +44,7 @@ def submit_marsey(v): username = request.values.get('author').lower().strip() def error(error): - if v.admin_level > 2: marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all() + if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_MARSEYS']: marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all() else: marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all() for marsey in marseys: marsey.author = g.db.query(User.username).filter_by(id=marsey.author_id).one()[0] @@ -82,7 +82,7 @@ def submit_marsey(v): g.db.add(marsey) g.db.flush() - if v.admin_level > 2: marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all() + if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_MARSEYS']: marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all() else: marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all() for marsey in marseys: marsey.author = g.db.query(User.username).filter_by(id=marsey.author_id).one()[0] @@ -186,7 +186,7 @@ def remove_marsey(v, name): @app.get("/submit/hats") @auth_required def submit_hats(v): - if v.admin_level > 2: hats = g.db.query(HatDef).filter(HatDef.submitter_id != None).all() + if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_HATS']: hats = g.db.query(HatDef).filter(HatDef.submitter_id != None).all() else: hats = g.db.query(HatDef).filter(HatDef.submitter_id == v.id).all() return render_template("submit_hats.html", v=v, hats=hats) @@ -200,7 +200,7 @@ def submit_hat(v): username = request.values.get('author').strip() def error(error): - if v.admin_level > 2: hats = g.db.query(HatDef).filter(HatDef.submitter_id != None).all() + if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_HATS']: hats = g.db.query(HatDef).filter(HatDef.submitter_id != None).all() else: hats = g.db.query(HatDef).filter(HatDef.submitter_id == v.id).all() return render_template("submit_hats.html", v=v, hats=hats, error=error, name=name, description=description, username=username), 400 @@ -245,7 +245,7 @@ def submit_hat(v): g.db.commit() - if v.admin_level > 2: hats = g.db.query(HatDef).filter(HatDef.submitter_id != None).all() + if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_HATS']: hats = g.db.query(HatDef).filter(HatDef.submitter_id != None).all() else: hats = g.db.query(HatDef).filter(HatDef.submitter_id == v.id).all() return render_template("submit_hats.html", v=v, hats=hats, msg=f"'{name}' submitted successfully!")