Fakultas Ilmu Komputer UI

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