Fakultas Ilmu Komputer UI

Commit ab880664 authored by Glenda Emanuella Sutanto's avatar Glenda Emanuella Sutanto
Browse files

Link user and nutritionist in payment

parent 8668c02f
Pipeline #84025 passed with stages
in 13 minutes and 34 seconds
import datetime
from rest_framework import viewsets, status from rest_framework import viewsets, status
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView
...@@ -13,7 +12,7 @@ from payment.serializers import CartSerializer ...@@ -13,7 +12,7 @@ from payment.serializers import CartSerializer
from .models import CustomUser from .models import CustomUser
from .serializers import CustomUserDetailsSerializer, CustomLoginSerializer, UserAuthSerializer from .serializers import CustomUserDetailsSerializer, CustomLoginSerializer, UserAuthSerializer
from .google_utils import validate_google_token from .google_utils import validate_google_token
from .utilities import get_first_deadline
class CustomLoginView(LoginView): class CustomLoginView(LoginView):
serializer_class = CustomLoginSerializer serializer_class = CustomLoginSerializer
...@@ -44,8 +43,6 @@ class LinkDataViewSet(viewsets.ViewSet): ...@@ -44,8 +43,6 @@ class LinkDataViewSet(viewsets.ViewSet):
return Response({'message': 'Cart is not found.'}, status=status.HTTP_400_BAD_REQUEST) return Response({'message': 'Cart is not found.'}, status=status.HTTP_400_BAD_REQUEST)
user.diet_profile = diet_profile user.diet_profile = diet_profile
user.nutritionist = cart.nutritionist
user.deadline = get_first_deadline(datetime.date.today())
user.save() user.save()
......
...@@ -11,6 +11,7 @@ from dietela_program.serializers import DietelaProgramSerializer ...@@ -11,6 +11,7 @@ from dietela_program.serializers import DietelaProgramSerializer
from dietela_program.models import DietelaProgram from dietela_program.models import DietelaProgram
from diet_questionnaire.models import DietQuestionnaire from diet_questionnaire.models import DietQuestionnaire
from profile_dietku.models import DietRecommendation from profile_dietku.models import DietRecommendation
from authentication.utilities import get_first_deadline
from .serializers import CartSerializer from .serializers import CartSerializer
from .models import Cart from .models import Cart
...@@ -129,6 +130,11 @@ class MidtransRedirectionViewSet(viewsets.ViewSet): ...@@ -129,6 +130,11 @@ class MidtransRedirectionViewSet(viewsets.ViewSet):
PROGRAM_DURATION[cart.program.unique_code]) PROGRAM_DURATION[cart.program.unique_code])
cart.save() cart.save()
user = cart.user
user.nutritionist = cart.nutritionist
user.deadline = get_first_deadline(date.today())
user.save()
DietQuestionnaire.objects.create(user=cart.user) DietQuestionnaire.objects.create(user=cart.user)
DietRecommendation.objects.create( DietRecommendation.objects.create(
client=cart.user, client=cart.user,
......
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