From d8b8f28442b978980ce88c3021660fd7ba35a31c Mon Sep 17 00:00:00 2001 From: Oliver Zander Date: Mon, 10 Nov 2025 18:06:21 +0100 Subject: [PATCH] improved literature form validation --- input/forms.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/input/forms.py b/input/forms.py index 4059d72..6d55a3a 100755 --- a/input/forms.py +++ b/input/forms.py @@ -292,18 +292,15 @@ class LiteratureForm(TermsForm): if self.errors: return cleaned_data - return self.clean_selfbuy_fields(cleaned_data) - - def clean_selfbuy_fields(self, cleaned_data): if cleaned_data['selfbuy'] == 'TRUE': cleaned_data['selfbuy_data'] = '' cleaned_data['selfbuy_give_data'] = False - else: - if not cleaned_data.get('selfbuy_data'): - self.add_error('selfbuy_data', trans('This field is required.')) - if not cleaned_data.get('selfbuy_give_data'): - self.add_error('selfbuy_give_data', trans('This field is required.')) + return cleaned_data + + for field in 'selfbuy_data', 'selfbuy_give_data': + if not cleaned_data.get('selfbuy_data'): + self.add_error(field, trans('This field is required.')) return cleaned_data