fix: mlog create 不带mtask时报错
This commit is contained in:
parent
c376cfb24a
commit
27e4022d9a
|
@ -122,14 +122,15 @@ class MlogSerializer(CustomModelSerializer):
|
|||
return super().update(instance, validated_data)
|
||||
|
||||
def validate(self, attrs):
|
||||
mtask = attrs['mtask']
|
||||
handle_date = attrs['handle_date']
|
||||
if handle_date >= mtask.start_date and handle_date <= mtask.end_date:
|
||||
pass
|
||||
else:
|
||||
raise ValidationError('操作日期错误')
|
||||
if mtask.state != Mtask.MTASK_ASSGINED:
|
||||
raise ValidationError(f'{mtask.mgroup.name}_不可提交日志!')
|
||||
mtask = attrs.get('mtask', None)
|
||||
if mtask:
|
||||
handle_date = attrs['handle_date']
|
||||
if handle_date >= mtask.start_date and handle_date <= mtask.end_date:
|
||||
pass
|
||||
else:
|
||||
raise ValidationError('操作日期错误')
|
||||
if mtask.state != Mtask.MTASK_ASSGINED:
|
||||
raise ValidationError(f'{mtask.mgroup.name}_不可提交日志!')
|
||||
return attrs
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue