From 5a6b64eebd86b1b82540be0f7ef8f127d5096393 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Wed, 15 Sep 2021 16:25:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E5=8D=95=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=B0=8F=E4=BA=8E=E5=BC=80=E5=A7=8B=E6=97=A5?= =?UTF-8?q?=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ticket/meta/ticket_type/apply_application.py | 8 ++++++-- .../serializers/ticket/meta/ticket_type/apply_asset.py | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/tickets/serializers/ticket/meta/ticket_type/apply_application.py b/apps/tickets/serializers/ticket/meta/ticket_type/apply_application.py index e8217bf2b..dd3be12a7 100644 --- a/apps/tickets/serializers/ticket/meta/ticket_type/apply_application.py +++ b/apps/tickets/serializers/ticket/meta/ticket_type/apply_application.py @@ -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 diff --git a/apps/tickets/serializers/ticket/meta/ticket_type/apply_asset.py b/apps/tickets/serializers/ticket/meta/ticket_type/apply_asset.py index 489ded1a8..294ecd1ab 100644 --- a/apps/tickets/serializers/ticket/meta/ticket_type/apply_asset.py +++ b/apps/tickets/serializers/ticket/meta/ticket_type/apply_asset.py @@ -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