From 111d4f08f454d3c385c388829536af20ca3f8d69 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Mon, 22 Nov 2021 20:27:33 +0100 Subject: [PATCH] cast hours to int #56 --- ki/handlers/update_profile.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ki/handlers/update_profile.py b/ki/handlers/update_profile.py index 26a188c..06d107b 100644 --- a/ki/handlers/update_profile.py +++ b/ki/handlers/update_profile.py @@ -138,7 +138,16 @@ def update_profile(user_id: int): profile.volunteerwork = request.json.get("volunteerwork", "") profile.availability_status = request.json.get("availability_status", False) profile.availability_text = request.json.get("availability_text", "") - profile.availability_hours_per_week = request.json.get("availability_hours_per_week", 0) + + availability_hours_per_week_raw = request.json.get("availability_hours_per_week", 0) + + try: + availability_hours_per_week = int(availability_hours_per_week_raw) + except: + availability_hours_per_week = 0 + + profile.availability_hours_per_week = availability_hours_per_week + profile.freetext = request.json.get("freetext", "") profile.visible = request.json.get("visible", False)