view pending submitted marseys and hats perms

master
justcool393 2022-10-05 19:55:54 -07:00
parent ae0c215af3
commit 0349862531
2 changed files with 8 additions and 6 deletions

View File

@ -134,6 +134,8 @@ PERMS = { # Minimum admin_level to perform action.
'USER_SHADOWBAN': 2, 'USER_SHADOWBAN': 2,
'POST_TO_CHANGELOG': 1, 'POST_TO_CHANGELOG': 1,
'BYPASS_PIN_LIMIT': 3, 'BYPASS_PIN_LIMIT': 3,
'VIEW_PENDING_SUBMITTED_MARSEYS': 3,
'VIEW_PENDING_SUBMITTED_HATS': 3,
} }
FEATURES = { FEATURES = {

View File

@ -22,7 +22,7 @@ def asset_submissions(path):
@app.get("/submit/marseys") @app.get("/submit/marseys")
@auth_required @auth_required
def submit_marseys(v): 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() marseys = g.db.query(Marsey).filter(Marsey.submitter_id != None).all()
else: else:
marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all() 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() username = request.values.get('author').lower().strip()
def error(error): 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() else: marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all()
for marsey in marseys: for marsey in marseys:
marsey.author = g.db.query(User.username).filter_by(id=marsey.author_id).one()[0] 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.add(marsey)
g.db.flush() 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() else: marseys = g.db.query(Marsey).filter(Marsey.submitter_id == v.id).all()
for marsey in marseys: for marsey in marseys:
marsey.author = g.db.query(User.username).filter_by(id=marsey.author_id).one()[0] 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") @app.get("/submit/hats")
@auth_required @auth_required
def submit_hats(v): 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() else: hats = g.db.query(HatDef).filter(HatDef.submitter_id == v.id).all()
return render_template("submit_hats.html", v=v, hats=hats) return render_template("submit_hats.html", v=v, hats=hats)
@ -200,7 +200,7 @@ def submit_hat(v):
username = request.values.get('author').strip() username = request.values.get('author').strip()
def error(error): 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() 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 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() 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() 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!") return render_template("submit_hats.html", v=v, hats=hats, msg=f"'{name}' submitted successfully!")