feat: handle_user也作为约束条件
This commit is contained in:
parent
a69fa79de8
commit
d0b40cfd3d
|
|
@ -92,7 +92,10 @@ class MlogSerializer(CustomModelSerializer):
|
|||
mtask = validated_data['mtask']
|
||||
batch = validated_data['batch']
|
||||
handle_date = validated_data['handle_date']
|
||||
if Mlog.objects.filter(mtask=mtask, batch=batch, handle_date=handle_date).exists():
|
||||
handle_user = validated_data['handle_user']
|
||||
if not WMaterial.objects.filter(batch=batch).exists():
|
||||
raise ValidationError('批次号不存在')
|
||||
if Mlog.objects.filter(mtask=mtask, batch=batch, handle_date=handle_date, handle_user=handle_user).exists():
|
||||
raise ValidationError('存在相同的日志的记录')
|
||||
return super().create(validated_data)
|
||||
|
||||
|
|
@ -100,6 +103,7 @@ class MlogSerializer(CustomModelSerializer):
|
|||
validated_data.pop('mtask', None)
|
||||
validated_data.pop('batch', None)
|
||||
validated_data.pop('handle_date', None)
|
||||
validated_data.pop('handle_user', None)
|
||||
return super().update(instance, validated_data)
|
||||
|
||||
def validate(self, attrs):
|
||||
|
|
|
|||
Loading…
Reference in New Issue