缓存区域信息

This commit is contained in:
曹前明 2022-10-18 19:16:54 +08:00
parent 2ad6d2a3be
commit cfc6b072c6
3 changed files with 27 additions and 10 deletions

View File

@ -20,6 +20,16 @@ class AreaViewSet(CustomModelViewSet):
ordering = ['number']
search_fields = ['number', 'name']
def create(self, request, *args, **kwargs):
ret = super().create(request, *args, **kwargs)
cache_areas_info.delay()
return ret
def update(self, request, *args, **kwargs):
ret = super().update(request, *args, **kwargs)
cache_areas_info.delay()
return ret
@transaction.atomic
@action(methods=['post'], detail=True, perms_map={'post': 'area.bind_rail'},
serializer_class=serializers.Serializer)

View File

@ -57,16 +57,16 @@ 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)
ep, _ = 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=ep).data)
@action(methods=['post'], detail=False, permission_classes=[IsAuthenticated],
serializer_class=EmployeeImproveSerializer)

View File

@ -123,6 +123,13 @@ class VisitorViewSet(CustomModelViewSet):
ep2.is_deleted = False
ep2.save()
sync_to_visitor(ep2)
else:
ep = Employee()
ep.user = user
ep.name = user.name
ep.phone = user.phone
ep.type = user.type
ep.save()
return Response(get_tokens_for_user(user))