forked from beba/foerderbarometer
improved literature form validation
This commit is contained in:
parent
73cd0ff906
commit
d8b8f28442
|
|
@ -292,18 +292,15 @@ class LiteratureForm(TermsForm):
|
||||||
if self.errors:
|
if self.errors:
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
return self.clean_selfbuy_fields(cleaned_data)
|
|
||||||
|
|
||||||
def clean_selfbuy_fields(self, cleaned_data):
|
|
||||||
if cleaned_data['selfbuy'] == 'TRUE':
|
if cleaned_data['selfbuy'] == 'TRUE':
|
||||||
cleaned_data['selfbuy_data'] = ''
|
cleaned_data['selfbuy_data'] = ''
|
||||||
cleaned_data['selfbuy_give_data'] = False
|
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'):
|
return cleaned_data
|
||||||
self.add_error('selfbuy_give_data', trans('This field is required.'))
|
|
||||||
|
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
|
return cleaned_data
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue