hats: fix 2 500s (SQL errors)

master
justcool393 2022-10-22 15:37:22 -05:00
parent 60dd29bc6b
commit a5799b222e
1 changed files with 11 additions and 2 deletions

View File

@ -101,6 +101,10 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
abort(403, f"Only Carp can approve {asset_type}!")
name = name.strip()
if make_lower: name = name.lower()
asset = None
if cls == HatDef:
asset = g.db.query(cls).filter_by(name=name).one_or_none()
else:
asset = g.db.get(cls, name)
if not asset:
abort(404, f"This {asset} '{name}' doesn't exist!")
@ -171,6 +175,10 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
name = name.strip()
if not name:
abort(400, f"You need to specify a {type_name}!")
asset = None
if cls == HatDef:
asset = g.db.query(cls).filter_by(name=name).one_or_none()
else:
asset = g.db.get(cls, name)
if not asset:
abort(404, f"This {type_name} '{name}' doesn't exist!")
@ -270,6 +278,7 @@ if SITE not in ('pcmemes.net', 'watchpeopledie.tv'):
try:
hat.price = int(request.values.get('price'))
if hat.price < 0: raise ValueError("Invalid hat price")
except:
abort(400, "Invalid hat price")
hat.name = new_name