From 82282cc8a4824d08fd3ec09e8784659651784fb0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 3 Sep 2022 05:58:43 +0200 Subject: [PATCH] check if user owns the hat alrdy or not --- files/routes/hats.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/routes/hats.py b/files/routes/hats.py index 3d9542a81..df25caea5 100644 --- a/files/routes/hats.py +++ b/files/routes/hats.py @@ -28,6 +28,9 @@ def buy_hat(v, hat_id): hat = g.db.query(HatDef).filter_by(id=hat_id).one_or_none() if not hat: return {"error": "Hat not found!"} + existing = g.db.query(Hat).filter_by(user_id=v.id, hat_id=hat.id).one_or_none() + if existing: return {"error": "You already own this hat!"} + if request.values.get("mb"): if v.procoins < hat.price: return {"error": "Not enough marseybux."}, 400 v.procoins -= hat.price