visit create
This commit is contained in:
parent
fe52b60bad
commit
1483494f8e
|
@ -40,6 +40,18 @@ class EmployeeViewSet(CustomModelViewSet):
|
||||||
search_fields = ['name', 'number', 'user__username']
|
search_fields = ['name', 'number', 'user__username']
|
||||||
ordering = ['-pk']
|
ordering = ['-pk']
|
||||||
|
|
||||||
|
@action(methods=['get'], detail=False, perms_map={'get': '*'},
|
||||||
|
serializer_class=serializers.Serializer)
|
||||||
|
def info(self, request, pk=None):
|
||||||
|
"""个人信息
|
||||||
|
|
||||||
|
个人信息
|
||||||
|
"""
|
||||||
|
user = request.user
|
||||||
|
if user.employee:
|
||||||
|
return Response(EmployeeSerializer(instance=user.employee).data)
|
||||||
|
raise ParseError('请先完善个人信息')
|
||||||
|
|
||||||
@action(methods=['post'], detail=True, perms_map={'post': 'employee:notworkremark'},
|
@action(methods=['post'], detail=True, perms_map={'post': 'employee:notworkremark'},
|
||||||
serializer_class=EmployeeNotWorkRemarkSerializer)
|
serializer_class=EmployeeNotWorkRemarkSerializer)
|
||||||
def not_work_remark(self, request, pk=None):
|
def not_work_remark(self, request, pk=None):
|
||||||
|
|
|
@ -9,7 +9,7 @@ from rest_framework import serializers
|
||||||
class VisitCreateUpdateSerializer(CustomModelSerializer):
|
class VisitCreateUpdateSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Visit
|
model = Visit
|
||||||
fields = ['purpose', 'name', 'description', 'visit_time', 'leave_time', 'receptionist', 'company']
|
fields = ['purpose', 'name', 'description', 'visit_time', 'leave_time', 'receptionist', 'company', 'level', 'count_people']
|
||||||
|
|
||||||
|
|
||||||
class VisitSerializer(CustomModelSerializer):
|
class VisitSerializer(CustomModelSerializer):
|
||||||
|
|
|
@ -53,6 +53,13 @@ class VisitorViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Custo
|
||||||
create_serializer_class = VisitorCreateSerializer
|
create_serializer_class = VisitorCreateSerializer
|
||||||
serializer_class = VisitorSerializer
|
serializer_class = VisitorSerializer
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
user = self.request.user
|
||||||
|
queryset = super().get_queryset()
|
||||||
|
if user.type == 'visitor':
|
||||||
|
queryset = queryset.filter(create_by=user)
|
||||||
|
return queryset
|
||||||
|
|
||||||
@action(methods=['post'], detail=False,
|
@action(methods=['post'], detail=False,
|
||||||
authentication_classes=[], permission_classes=[],
|
authentication_classes=[], permission_classes=[],
|
||||||
serializer_class=VisitorRegisterSerializer)
|
serializer_class=VisitorRegisterSerializer)
|
||||||
|
|
Loading…
Reference in New Issue