Commit 67af3d5c by Diana Huang

Don't try to purchase the same order twice

parent 0e2d833a
......@@ -105,6 +105,8 @@ class Order(models.Model):
`processor_reply_dump` - all the parameters returned by the processor
"""
if self.status == 'purchased':
return
self.status = 'purchased'
self.purchase_time = datetime.now(pytz.utc)
self.bill_to_first = first
......
......@@ -103,6 +103,14 @@ class OrderTest(ModuleStoreTestCase):
# verify that e-mail wasn't sent
self.assertEquals(len(mail.outbox), 0)
def test_purchase_twice(self):
cart = Order.get_cart_for_user(self.user)
CertificateItem.add_to_order(cart, self.course_id, self.cost, 'honor')
# purchase the cart more than once
cart.purchase()
cart.purchase()
self.assertEquals(len(mail.outbox), 1)
def purchase_with_data(self, cart):
""" purchase a cart with billing information """
CertificateItem.add_to_order(cart, self.course_id, self.cost, 'honor')
......@@ -137,7 +145,6 @@ class OrderTest(ModuleStoreTestCase):
@patch.dict(settings.MITX_FEATURES, {'STORE_BILLING_INFO': False})
def test_billing_info_storage_off(self):
cart = Order.get_cart_for_user(self.user)
cart = Order.get_cart_for_user(self.user)
self.purchase_with_data(cart)
self.assertNotEqual(cart.bill_to_first, '')
self.assertNotEqual(cart.bill_to_last, '')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment