manager: fix check type form & pricing fields mutex (#64778)
This commit is contained in:
parent
aee7d8c9f8
commit
ff2f877557
|
@ -82,7 +82,7 @@ class NewCheckTypeForm(forms.ModelForm):
|
|||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
if self.cleaned_data.get('pricing') and self.cleaned_data.get('pricing_rate'):
|
||||
if self.cleaned_data.get('pricing') is not None and self.cleaned_data.get('pricing_rate') is not None:
|
||||
raise ValidationError(_('Please choose between pricing and pricing rate.'))
|
||||
|
||||
|
||||
|
|
|
@ -145,6 +145,10 @@ def test_add_check_type_pricing(settings, app, admin_user):
|
|||
resp.form['pricing_rate'] = 150
|
||||
resp = resp.form.submit()
|
||||
assert resp.context['form'].errors['__all__'] == ['Please choose between pricing and pricing rate.']
|
||||
resp.form['pricing'] = 0
|
||||
resp.form['pricing_rate'] = 0
|
||||
resp = resp.form.submit()
|
||||
assert resp.context['form'].errors['__all__'] == ['Please choose between pricing and pricing rate.']
|
||||
resp.form['pricing'] = 42
|
||||
resp.form['pricing_rate'] = None
|
||||
resp = resp.form.submit()
|
||||
|
|
Loading…
Reference in New Issue