diff --git a/apps/opm/serializers.py b/apps/opm/serializers.py index ab3f27c8..fe6dff65 100644 --- a/apps/opm/serializers.py +++ b/apps/opm/serializers.py @@ -107,6 +107,8 @@ class OplWorkerCreateSerializer(CustomModelSerializer): with transaction.atomic(): oplw = super().create(validated_data) for x in certificates: + if x.state == Certificate.CERT_EXPIRED: + raise ParseError(f'证书{x.number}已过期!') oplc = OplCert.objects.filter(opl_worker=oplw, certificate=x).first() if oplc: pass @@ -133,6 +135,8 @@ class OplWorkerUpdateSerializer(CustomModelSerializer): with transaction.atomic(): oplw = super().update(instance, validated_data) for x in certificates: + if x.state == Certificate.CERT_EXPIRED: + raise ParseError(f'证书{x.number}已过期!') oplc = OplCert.objects.filter(opl_worker=oplw, certificate=x).first() if oplc: pass diff --git a/apps/rpm/services.py b/apps/rpm/services.py index eb5c9037..60e139dc 100644 --- a/apps/rpm/services.py +++ b/apps/rpm/services.py @@ -196,6 +196,7 @@ def rpj_certificate_in(rpjm: Rpjmember): ct.expiration_date = i.expiration_date ct.review_date = i.review_date ct.file = i.file + ct.state = ct.get_state() ct.save() @@ -219,6 +220,7 @@ def rpj_audit_end(ticket): ct.expiration_date = i.expiration_date ct.review_date = i.review_date ct.file = i.file + ct.state = ct.get_state() ct.save() # 更新相关方资料库后续可从资料库里选择 for i in Rpjfile.objects.filter(rpj=rpj):