From 2610cb7600a1b6111065e065a3e5891fd0a8d39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B3nimo=20Mendes?= <39437433+JeronimoMendes@users.noreply.github.com> Date: Mon, 30 May 2022 15:58:33 +0100 Subject: [PATCH] =?UTF-8?q?Hotfix=201.0.1=20=F0=9F=94=A7=20-=20Fix=20misal?= =?UTF-8?q?igned=20`Profile`=20and=20`User`=20id=20(#217)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change user serializer to show profile id * Change profile page to use profile id not user id * Bump version --- backend/api/serializer.py | 5 ++++- frontend/package.json | 2 +- frontend/src/pages/ProfilePage.js | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/api/serializer.py b/backend/api/serializer.py index 6b2375d5..387e6e20 100644 --- a/backend/api/serializer.py +++ b/backend/api/serializer.py @@ -14,11 +14,14 @@ class UserSerializer(serializers.ModelSerializer): username = serializers.ReadOnlyField() mod = serializers.BooleanField(source="is_staff") admin = serializers.BooleanField(source="is_superuser") + profile = serializers.IntegerField(source='profile.id') class Meta: model = User - fields = ("id", "username", "email", "mod", "admin") + fields = ("id", "profile", "username", "email", "mod", "admin") + def get_profile(self): + profile = Profile.objects.get(user=self.id) class XPEventSerializer(serializers.ModelSerializer): class Meta: diff --git a/frontend/package.json b/frontend/package.json index ea266227..b24f9221 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.0.0", + "version": "1.0.1", "private": true, "scripts": { "start": "react-scripts start", diff --git a/frontend/src/pages/ProfilePage.js b/frontend/src/pages/ProfilePage.js index 5b18aa0c..9bf36ecf 100644 --- a/frontend/src/pages/ProfilePage.js +++ b/frontend/src/pages/ProfilePage.js @@ -27,8 +27,8 @@ const ProfilePage = () => { useEffect(() => { getUser((res1) => { - getProfile(res1.data.id, (res2) => { - getXpEvents(res1.data.id, (res3) => { + getProfile(res1.data.profile, (res2) => { + getXpEvents(res1.data.profile, (res3) => { setXpEvents(res3.data); setLoading(false); });