From 1287893698a96425031bd57cb9328057a6fb18c9 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Mon, 22 Nov 2021 20:19:23 +0100 Subject: [PATCH] fix updating nickname #57 --- ki/handlers/update_profile.py | 1 + ki/test/test_profile_endpoint.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ki/handlers/update_profile.py b/ki/handlers/update_profile.py index 762935b..26a188c 100644 --- a/ki/handlers/update_profile.py +++ b/ki/handlers/update_profile.py @@ -133,6 +133,7 @@ def update_profile(user_id: int): profile = Profile(user=user, nickname=user.auth_id) db.session.add(profile) + profile.nickname = request.json.get("nickname", "") profile.pronouns = request.json.get("pronouns", "") profile.volunteerwork = request.json.get("volunteerwork", "") profile.availability_status = request.json.get("availability_status", False) diff --git a/ki/test/test_profile_endpoint.py b/ki/test/test_profile_endpoint.py index af51a5d..066aff7 100644 --- a/ki/test/test_profile_endpoint.py +++ b/ki/test/test_profile_endpoint.py @@ -31,6 +31,7 @@ class TestProfileEndpoint(ApiTest): token = self.login("peter", "geheim")["token"] data = { + "nickname": "Hebbert", "pronouns": "Monsieur", "volunteerwork": "ja", "availability_status": False, @@ -110,6 +111,7 @@ class TestProfileEndpoint(ApiTest): with app.app_context(): user = User.query.filter(User.id == 1).first() profile = user.profile + self.assertEqual("Hebbert", profile.nickname) self.assertEqual("Monsieur", profile.pronouns) self.assertEqual("ja", profile.volunteerwork) self.assertEqual(False, profile.availability_status)