Skip to content

Commit be57d82

Browse files
committed
Check if settings.ACCOUNTS_MAX_ACCOUNT_VALUE is set before using it
1 parent 184cece commit be57d82

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/oscar_accounts/dashboard/forms.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ def __init__(self, *args, **kwargs):
164164

165165
def clean_amount(self):
166166
amt = self.cleaned_data['amount']
167-
max_amount = settings.ACCOUNTS_MAX_ACCOUNT_VALUE - self.account.balance
168-
if amt > max_amount:
169-
raise forms.ValidationError(_(
170-
"The maximum permitted top-up amount is %s") % (
171-
currency(max_amount)))
167+
if hasattr(settings, 'ACCOUNTS_MAX_ACCOUNT_VALUE'):
168+
max_amount = (
169+
settings.ACCOUNTS_MAX_ACCOUNT_VALUE - self.account.balance)
170+
if amt > max_amount:
171+
raise forms.ValidationError(_(
172+
"The maximum permitted top-up amount is %s") % (
173+
currency(max_amount)))
172174
return amt
173175

174176
def clean(self):

0 commit comments

Comments
 (0)