Skip to content

Commit

Permalink
fix bug at update user setting
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavomm19 committed Dec 4, 2023
1 parent 430e88c commit b36a44c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions breathecode/authenticate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
SyncGithubUsersForm)
from .models import (AppUserAgreement, CredentialsFacebook, CredentialsGithub, CredentialsGoogle,
CredentialsSlack, GitpodUser, OptionalScopeSet, Profile, ProfileAcademy, Role, Scope,
Token, UserInvite, GithubAcademyUser, AcademyAuthSettings)
Token, UserInvite, GithubAcademyUser, AcademyAuthSettings, UserSetting)
from .serializers import (AppUserSerializer, AuthSerializer, GetGitpodUserSerializer,
GetProfileAcademySerializer, GetProfileAcademySmallSerializer, GetProfileSerializer,
GitpodUserSmallSerializer, MemberPOSTSerializer, MemberPUTSerializer,
Expand Down Expand Up @@ -832,7 +832,9 @@ def put(self, request):
except User.DoesNotExist:
raise ValidationException('You don\'t have a user', slug='user-not-found', code=403)

serializer = UserSettingsSerializer(request.user, data=request.data, context={'request': request})
settings, created = UserSetting.objects.get_or_create(user_id=request.user.id)

serializer = UserSettingsSerializer(settings, data=request.data, context={'request': request})
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)
Expand Down

0 comments on commit b36a44c

Please sign in to comment.