improved literature form validation

This commit is contained in:
Oliver Zander 2025-11-10 18:06:21 +01:00 committed by Tobias Herre
parent 73cd0ff906
commit d8b8f28442
1 changed files with 5 additions and 8 deletions

View File

@ -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