访客账户注册时关联已有人员优化

This commit is contained in:
曹前明 2022-10-18 11:38:20 +08:00
parent a6b71c9450
commit af61d75177
2 changed files with 11 additions and 1 deletions

View File

@ -57,6 +57,15 @@ class EmployeeViewSet(CustomModelViewSet):
个人信息
"""
user = request.user
# Employee.objects.get_or_create(user=user,
# defaults={
# "user": user,
# "name": user.name,
# "phone": user.phone,
# "belong_dept": user.belong_dept,
# "post": user.post,
# "type": user.type
# })
return Response(EmployeeSerializer(instance=user.employee).data)
@action(methods=['post'], detail=False, permission_classes=[IsAuthenticated],

View File

@ -17,7 +17,7 @@ from django.contrib.auth.hashers import make_password
from django.db import transaction
from rest_framework.serializers import Serializer
from apps.vm.services import visit_driver_end
from apps.vm.services import sync_to_visitor, visit_driver_end
# Create your views here.
@ -122,6 +122,7 @@ class VisitorViewSet(CustomModelViewSet):
ep2.user = user
ep2.is_deleted = False
ep2.save()
sync_to_visitor(ep2)
return Response(get_tokens_for_user(user))