fix updating nickname #57

This commit is contained in:
weeman 2021-11-22 20:19:23 +01:00
parent 9dc9761a1a
commit 1287893698
Signed by untrusted user: weeman
GPG Key ID: 34F0524D4DA694A1
2 changed files with 3 additions and 0 deletions

View File

@ -133,6 +133,7 @@ def update_profile(user_id: int):
profile = Profile(user=user, nickname=user.auth_id) profile = Profile(user=user, nickname=user.auth_id)
db.session.add(profile) db.session.add(profile)
profile.nickname = request.json.get("nickname", "")
profile.pronouns = request.json.get("pronouns", "") profile.pronouns = request.json.get("pronouns", "")
profile.volunteerwork = request.json.get("volunteerwork", "") profile.volunteerwork = request.json.get("volunteerwork", "")
profile.availability_status = request.json.get("availability_status", False) profile.availability_status = request.json.get("availability_status", False)

View File

@ -31,6 +31,7 @@ class TestProfileEndpoint(ApiTest):
token = self.login("peter", "geheim")["token"] token = self.login("peter", "geheim")["token"]
data = { data = {
"nickname": "Hebbert",
"pronouns": "Monsieur", "pronouns": "Monsieur",
"volunteerwork": "ja", "volunteerwork": "ja",
"availability_status": False, "availability_status": False,
@ -110,6 +111,7 @@ class TestProfileEndpoint(ApiTest):
with app.app_context(): with app.app_context():
user = User.query.filter(User.id == 1).first() user = User.query.filter(User.id == 1).first()
profile = user.profile profile = user.profile
self.assertEqual("Hebbert", profile.nickname)
self.assertEqual("Monsieur", profile.pronouns) self.assertEqual("Monsieur", profile.pronouns)
self.assertEqual("ja", profile.volunteerwork) self.assertEqual("ja", profile.volunteerwork)
self.assertEqual(False, profile.availability_status) self.assertEqual(False, profile.availability_status)