From 7b20c784d5bd6f20d306e3b3d92f7777d539991a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 22 Dec 2023 15:41:16 -0500 Subject: [PATCH] paperwork: Handle missing certification definition/version in admin form --- paperwork/forms.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paperwork/forms.py b/paperwork/forms.py index 5869b18..21bacac 100644 --- a/paperwork/forms.py +++ b/paperwork/forms.py @@ -24,6 +24,11 @@ class CertificationForm(forms.ModelForm): certification_version = cleaned_data.get("certification_version") certification_definition = cleaned_data.get("certification_definition") + if certification_version is None: + raise ValidationError("Certification Version missing") + if certification_definition is None: + raise ValidationError("Certification Definition missing") + if certification_version.definition != certification_definition: raise ValidationError( "Certification Version did not match Certification Definition!"