示例#1
0
 def test_get_confirm_view(self):
     """
     Test that method can return conformation view
     """
     request = RequestFactory().get('/')
     user = model_factory(User, username='******', save=True)
     cart = model_factory(Cart, contact=user.contact, is_active=True,
                                                                 save=True)
     request.user = user
     model_factory(Order, cart=cart, save=True)
     with patch('django.conf.settings.PAYMENT_MODULES',
                             {'dummy': 'salest.payments.modules.dummy'}):
         confirm_view = get_confirm_view('dummy')
         self.assertEqual(dummy_confirm_view, confirm_view)
示例#2
0
    def done(self, form_list, **kwargs):
        """
        Method called when all forms valid
        """
        if isinstance(self.request.user, AnonymousUser):
            self.contact = Contact.objects.create()
        else:
            self.contact = Contact.objects.get_or_create(
                                                     user=self.request.user)[0]
        self.cart = self.request.cart
        self.cart.contact = self.contact
        self.cart.save()

        self.order = self.cart.checkout()

        for form in form_list:
            if hasattr(form, 'save'):
                form.save(wizard=self)
        return get_confirm_view(
            self.get_payment_method_from_data(form_list))(
                            request=self.request).get(request=self.request)