Unverified Commit 09d42281 authored by feng626's avatar feng626 Committed by GitHub
Browse files

Merge pull request #7102 from jumpserver/pr@dev@ticket_tips

perf: 工单错误提示优化
Showing with 8 additions and 9 deletions
+8 -9
...@@ -80,12 +80,11 @@ class ApplySerializer(serializers.Serializer): ...@@ -80,12 +80,11 @@ class ApplySerializer(serializers.Serializer):
applications = Application.objects.filter(id__in=apply_applications, type=type).values_list('id', flat=True) applications = Application.objects.filter(id__in=apply_applications, type=type).values_list('id', flat=True)
return list(applications) return list(applications)
def validate_apply_date_expired(self, value): def validate(self, attrs):
date_start = self.root.initial_data['meta'].get('apply_date_start') apply_date_start = attrs['apply_date_start']
date_start = datetime.strptime(date_start, '%Y-%m-%dT%H:%M:%S.%fZ') apply_date_expired = attrs['apply_date_expired']
date_expired = self.root.initial_data['meta'].get('apply_date_expired')
date_expired = datetime.strptime(date_expired, '%Y-%m-%dT%H:%M:%S.%fZ') if apply_date_expired <= apply_date_start:
if date_expired <= date_start:
error = _('The expiration date should be greater than the start date') error = _('The expiration date should be greater than the start date')
raise serializers.ValidationError(error) raise serializers.ValidationError({'apply_date_expired': error})
return value return attrs
...@@ -160,7 +160,7 @@ class TicketFlowApproveSerializer(serializers.ModelSerializer): ...@@ -160,7 +160,7 @@ class TicketFlowApproveSerializer(serializers.ModelSerializer):
def validate(self, attrs): def validate(self, attrs):
if attrs['strategy'] == TicketApprovalStrategy.custom_user and not attrs.get('assignees'): if attrs['strategy'] == TicketApprovalStrategy.custom_user and not attrs.get('assignees'):
error = _('Please select the Assignees') error = _('Please select the Assignees')
raise serializers.ValidationError(error) raise serializers.ValidationError({'assignees': error})
return super().validate(attrs) return super().validate(attrs)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment