Skip to content

Commit

Permalink
Retrieve from master database if profile does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisRayM committed Oct 9, 2020
1 parent 7c0a8e0 commit 8a22e4c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions onadata/apps/api/viewsets/connect_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rest_framework.exceptions import ParseError
from rest_framework.response import Response
from rest_framework import mixins
from multidb.pinning import use_master

from onadata.apps.api.models.odk_token import ODKToken
from onadata.apps.api.models.temp_token import TempToken
Expand Down Expand Up @@ -46,8 +47,8 @@ def user_profile_w_token_response(request, status):
except UserProfile.DoesNotExist:
user_profile = cache.get(
f'{USER_PROFILE_PREFIX}{request.user.username}')
if not user_profile:
user_profile, __ = UserProfile.objects.get_or_create(
with use_master:
user_profile, _ = UserProfile.objects.get_or_create(
user=request.user)
cache.set(
f'{USER_PROFILE_PREFIX}{request.user.username}',
Expand Down

0 comments on commit 8a22e4c

Please sign in to comment.