Merge pull request #6862 from jumpserver/pr@dev@ticket_time_validation

fix: 工单失效日期小于开始日期
pull/6865/head
feng626 2021-09-15 16:44:23 +08:00 committed by GitHub
commit aa6dcdc65d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -69,5 +69,9 @@ class ApplySerializer(serializers.Serializer):
'Permission named `{}` already exists'.format(permission_name)
))
def validate_apply_date_expired(self, apply_date_expired):
apply_date_start = self.root.initial_data['meta'].get('apply_date_start')
if str(apply_date_expired) <= apply_date_start:
error = _('The expiration date should be greater than the start date')
raise serializers.ValidationError(error)
return apply_date_expired

View File

@ -60,3 +60,10 @@ class ApplySerializer(serializers.Serializer):
raise serializers.ValidationError(_(
'Permission named `{}` already exists'.format(permission_name)
))
def validate_apply_date_expired(self, apply_date_expired):
apply_date_start = self.root.initial_data['meta'].get('apply_date_start')
if str(apply_date_expired) <= apply_date_start:
error = _('The expiration date should be greater than the start date')
raise serializers.ValidationError(error)
return apply_date_expired