Fakultas Ilmu Komputer UI

Commit 56719bc2 authored by Kefas Satrio Bangkit Solidedantyo's avatar Kefas Satrio Bangkit Solidedantyo
Browse files

Merge branch 'adding-user-phone-number' into 'staging'

Adding user phone number

See merge request !87
parents 3954aa76 cc52de5f
Pipeline #84150 passed with stages
in 26 minutes and 12 seconds
......@@ -58,6 +58,13 @@ class CustomUserDetailsSerializer(serializers.ModelSerializer):
result['role'] = instance.groups.first().name
if instance.is_staff:
result['role'] = 'admin'
onboarding_status = UserAuthSerializer(instance).data
if onboarding_status['is_finished_onboarding'] is True\
and 'role' in onboarding_status:
phone_number = instance.diet_questionnaire.whatsapp_no
if phone_number is None:
phone_number = instance.diet_questionnaire.handphone_no
result['phone_number'] = phone_number
return result
class Meta:
......
......@@ -8,7 +8,7 @@ from dietela_quiz.models import DietProfile
from authentication.models import CustomUser
from nutritionists.models import Nutritionist
from diet_questionnaire.models import DietQuestionnaire
from authentication.serializers import CustomUserDetailsSerializer
from authentication.serializers import CustomUserDetailsSerializer,UserAuthSerializer
from django.db.models import Q
from .models import DietRecommendation
......@@ -160,6 +160,9 @@ class GetProfilesAndCSVTest(APITestCase):
users = CustomUser.objects.all()
users = users.order_by('name')
for user in users:
onboarding_status = UserAuthSerializer(user).data
if onboarding_status['is_finished_onboarding'] == True\
and onboarding_status['role']=="client":
expected_response.append({
'user': CustomUserDetailsSerializer(user).data,
'diet_profile_id': user.diet_profile.id \
......@@ -179,6 +182,9 @@ class GetProfilesAndCSVTest(APITestCase):
users = CustomUser.objects.filter(name="tesb")
users = users.order_by('name')
for user in users:
onboarding_status = UserAuthSerializer(user).data
if onboarding_status['is_finished_onboarding'] == True\
and onboarding_status['role']=="client":
expected_response.append({
'user': CustomUserDetailsSerializer(user).data,
'diet_profile_id': user.diet_profile.id \
......@@ -208,6 +214,9 @@ class GetProfilesAndCSVTest(APITestCase):
users = CustomUser.objects.filter(Q(nutritionist=1) & ~Q(email='test2@2test.com'))
expected_response = []
for user in users:
onboarding_status = UserAuthSerializer(user).data
if onboarding_status['is_finished_onboarding'] == True\
and onboarding_status['role']=="client":
expected_response.append({
'user': CustomUserDetailsSerializer(user).data,
'diet_profile_id': user.diet_profile.id \
......@@ -238,6 +247,9 @@ class GetProfilesAndCSVTest(APITestCase):
users = users.order_by('name')
expected_response = []
for user in users:
onboarding_status = UserAuthSerializer(user).data
if onboarding_status['is_finished_onboarding'] == True\
and onboarding_status['role']=="client":
expected_response.append({
'user': CustomUserDetailsSerializer(user).data,
'diet_profile_id': user.diet_profile.id \
......
......@@ -5,7 +5,7 @@ from rest_framework.response import Response
from django.db.models import Q
from django.http import HttpResponse
from authentication.models import CustomUser
from authentication.serializers import CustomUserDetailsSerializer
from authentication.serializers import CustomUserDetailsSerializer,UserAuthSerializer
from dietela_quiz.models import DietProfile
from diet_questionnaire.models import DietQuestionnaire
from .utilities import dp_helper,dq_helper
......@@ -43,6 +43,9 @@ class GetProfilesViewSet(generics.ListAPIView):
response = []
for user in queryset:
onboarding_status = UserAuthSerializer(user).data
if onboarding_status['is_finished_onboarding'] is True\
and onboarding_status['role']=="client":
response.append({
'user': CustomUserDetailsSerializer(user).data,
'diet_profile_id': user.diet_profile.id \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment