clockrecord增加筛选/身份证号校验取消
This commit is contained in:
parent
0137da7479
commit
d4e9406666
|
@ -10,7 +10,7 @@ class ClockRecordFilterSet(filters.FilterSet):
|
|||
|
||||
class Meta:
|
||||
model = ClockRecord
|
||||
fields = ['employee', 'start_create', 'end_create', 'year', 'month', 'type']
|
||||
fields = ['employee', 'start_create', 'end_create', 'year', 'month', 'type', 'employee__type', 'employee__belong_dept']
|
||||
|
||||
def filter_year(self, queryset, name, value):
|
||||
return queryset.filter(create_time__year=value)
|
||||
|
|
|
@ -216,7 +216,7 @@ class ClockRecordViewSet(ListModelMixin, CustomGenericViewSet):
|
|||
permission_classes = [AllowAny]
|
||||
queryset = ClockRecord.objects.all()
|
||||
select_related_fields = ['employee']
|
||||
search_fields = ['employee__name', 'employee__number']
|
||||
search_fields = ['employee__name', 'employee__number', 'employee__phone']
|
||||
serializer_class = ClockRecordListSerializer
|
||||
filterset_class = ClockRecordFilterSet
|
||||
ordering = ['-pk']
|
||||
|
|
|
@ -8,7 +8,7 @@ from apps.utils.fields import MyFilePathField
|
|||
from apps.utils.serializers import CustomModelSerializer
|
||||
from apps.system.serializers import DictSerializer, DictSimpleSerializer, FileSerializer, UserSimpleSerializer
|
||||
from rest_framework import serializers
|
||||
from rest_framework.exceptions import ParseError
|
||||
from rest_framework.exceptions import ParseError, ValidationError
|
||||
from django.db import transaction
|
||||
from apps.third.dahua import dhClient
|
||||
from apps.third.tapis import dhapis
|
||||
|
@ -135,6 +135,8 @@ class RemployeeCreateSerializer(CustomModelSerializer):
|
|||
fields = ['name', 'phone', 'photo', 'id_number', 'rparty']
|
||||
|
||||
def create(self, validated_data):
|
||||
if Remployee.objects.filter(id_number=validated_data['id_number'], rparty=validated_data['rparty']).exists():
|
||||
raise ValidationError('该成员已存在')
|
||||
with transaction.atomic():
|
||||
dhClient.request(**dhapis['person_img_upload'], file_path_rela=validated_data['photo'])
|
||||
return super().create(validated_data)
|
||||
|
|
|
@ -95,6 +95,8 @@ class RemployeeViewSet(CustomModelViewSet):
|
|||
create_serializer_class = RemployeeCreateSerializer
|
||||
update_serializer_class = RemployeeUpdateSerializer
|
||||
serializer_class = RemployeeSerializer
|
||||
search_fields = ['name', 'phone', 'id_number']
|
||||
filterset_fields = ['rparty']
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
|
|
|
@ -106,10 +106,10 @@ def p_in_poly(p, poly):
|
|||
|
||||
|
||||
def check_id_number_e(val):
|
||||
is_ok, msg = check_id_number(val)
|
||||
if is_ok:
|
||||
return val
|
||||
raise ValidationError(detail=msg)
|
||||
re_s = r'/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;'
|
||||
if not re.match(re_s, val):
|
||||
raise ValidationError('身份证号校验错误')
|
||||
return val
|
||||
|
||||
|
||||
def check_id_number(idcard):
|
||||
|
|
Loading…
Reference in New Issue