|
|
|
@ -3,7 +3,8 @@ from rest_framework import status
|
|
|
|
|
from rest_framework.decorators import api_view
|
|
|
|
|
from rest_framework.response import Response
|
|
|
|
|
from osinacore.models import *
|
|
|
|
|
from .serializers import CustomerProfileSerializer, UserSerializer
|
|
|
|
|
from .serializers import *
|
|
|
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
|
|
|
|
|
|
@api_view(['POST'])
|
|
|
|
|
def register_customer(request):
|
|
|
|
@ -12,7 +13,8 @@ def register_customer(request):
|
|
|
|
|
if user_serializer.is_valid():
|
|
|
|
|
user = user_serializer.save()
|
|
|
|
|
customer_data = request.data['customer']
|
|
|
|
|
customer_data['user'] = user
|
|
|
|
|
user_instance = get_object_or_404(User, id=user.id)
|
|
|
|
|
customer_data['user'] = user_instance
|
|
|
|
|
customer_serializer = CustomerProfileSerializer(data=customer_data)
|
|
|
|
|
if customer_serializer.is_valid():
|
|
|
|
|
customer_serializer.save()
|
|
|
|
|