def test_invalid_credit_card_displays_errors(self): with patch.object(SiteSignupForm, 'create_payment_profile') as mock_method: mock_method.side_effect = PaymentGatewayError() form = SiteSignupForm(self.data, account=self.account, plan=self.plan) self.assertFalse(form.is_valid()) self.assertTrue(form.create_payment_profile.called) self.assertTrue('Unable to process your credit card.' in form.non_field_errors())
def signup(request, reseller_secret, plan_secret): account = get_object_or_404(Account, secret=reseller_secret) plan = get_object_or_404(account.plan_set, secret=plan_secret) if request.method == 'POST': form = SiteSignupForm(request.POST, account=account, plan=plan, error_class=SpanErrorList) if form.is_valid(): form.save() return HttpResponseRedirect(unicode(form.site) + reverse('dashboard', urlconf='tiger.urls')) else: form = SiteSignupForm(account=account, plan=plan) return direct_to_template(request, template='tiger/signup.html', extra_context={ 'form': form, 'plan': plan })
def signup(request, reseller_secret, plan_secret): account = get_object_or_404(Account, secret=reseller_secret) plan = get_object_or_404(account.plan_set, secret=plan_secret) if request.method == 'POST': form = SiteSignupForm(request.POST, account=account, plan=plan, error_class=SpanErrorList) if form.is_valid(): form.save() return HttpResponseRedirect( unicode(form.site) + reverse('dashboard', urlconf='tiger.urls')) else: form = SiteSignupForm(account=account, plan=plan) return direct_to_template(request, template='tiger/signup.html', extra_context={ 'form': form, 'plan': plan })