示例#1
0
def signup(request):
    if request.method == "POST":
        form = CreateResellerAccountForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse("auth_login"))
    else:
        form = CreateResellerAccountForm()
    return direct_to_template(request, template="sales/signup.html", extra_context={"form": form})
示例#2
0
文件: views.py 项目: tonomuniz/tiger
def signup(request):
    if request.method == 'POST':
        form = CreateResellerAccountForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('auth_login'))
    else:
        form = CreateResellerAccountForm()
    return direct_to_template(request,
                              template='sales/signup.html',
                              extra_context={'form': form})
示例#3
0
 def test_valid_form_creates_manager_account(self):
     with patch.object(CreateResellerAccountForm, 'create_payment_profile') as mock_method:
         mock_method.return_value = ['foo', 'bar']
         form = CreateResellerAccountForm(self.data)
         form.full_clean()
         self.assertTrue(form.create_payment_profile.called)
         account = form.save()
         account.credit_card |should_not| be(None)
         card = account.credit_card
         self.assertEquals(card.customer_id, 'foo')
         self.assertEquals(card.subscription_id, 'bar')
         self.assertEquals(card.card_number, '5678')
         self.assertTrue(account.manager)
         self.assertEquals(len(mail.outbox), 1)
         self.assertTrue(self.client.login(email=account.user.email, password='******'))
示例#4
0
 def test_valid_form_creates_manager_account(self):
     with patch.object(CreateResellerAccountForm,
                       'create_payment_profile') as mock_method:
         mock_method.return_value = ['foo', 'bar']
         form = CreateResellerAccountForm(self.data)
         form.full_clean()
         self.assertTrue(form.create_payment_profile.called)
         account = form.save()
         account.credit_card | should_not | be(None)
         card = account.credit_card
         self.assertEquals(card.customer_id, 'foo')
         self.assertEquals(card.subscription_id, 'bar')
         self.assertEquals(card.card_number, '5678')
         self.assertTrue(account.manager)
         self.assertEquals(len(mail.outbox), 1)
         self.assertTrue(
             self.client.login(email=account.user.email,
                               password='******'))