From a5799b222e4f0bdafc20716eaeeb9a93dbd16601 Mon Sep 17 00:00:00 2001 From: justcool393 Date: Sat, 22 Oct 2022 15:37:22 -0500 Subject: [PATCH] hats: fix 2 500s (SQL errors) --- files/routes/asset_submissions.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index fcef24e59..600be8d0a 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -101,7 +101,11 @@ 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 = g.db.get(cls, 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 {asset} '{name}' doesn't exist!") return asset @@ -171,7 +175,11 @@ 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 = g.db.get(cls, 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!") if v.id not in (asset.submitter_id, AEVANN_ID, CARP_ID): @@ -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