Commit 77ee243e by Diana Huang

Some cleanup fixes to get verified certs working.

parent d6e777bc
......@@ -61,6 +61,12 @@ class Order(models.Model):
else:
return items[0].currency
def clear(self):
"""
Clear out all the items in the cart
"""
self.orderitem_set.all().delete()
def purchase(self, first='', last='', street1='', street2='', city='', state='', postalcode='',
country='', ccnum='', cardtype='', processor_reply_dump=''):
"""
......@@ -208,15 +214,6 @@ class PaidCourseRegistration(OrderItem):
"run:{0}".format(run)])
# Each entry is a dictionary of ModelName: 'lower_case_model_name'
# See https://docs.djangoproject.com/en/1.4/topics/db/models/#multi-table-inheritance for
# PLEASE KEEP THIS LIST UP_TO_DATE WITH THE SUBCLASSES OF OrderItem
ORDER_ITEM_SUBTYPES = {
PaidCourseRegistration: 'paidcourseregistration',
VerifiedCertificate: 'verifiedcertificate',
}
class VerifiedCertificate(OrderItem):
"""
This is an inventory item for purchasing verified certificates
......@@ -229,8 +226,6 @@ class VerifiedCertificate(OrderItem):
"""
Add a VerifiedCertificate item to an order
"""
# TODO: add the basic enrollment
# TODO: error checking
course_enrollment = CourseEnrollment.create_enrollment(order.user, course_id, mode="verified")
item, _created = cls.objects.get_or_create(
order=order,
......@@ -248,5 +243,16 @@ class VerifiedCertificate(OrderItem):
return item
def purchased_callback(self):
# TODO: add code around putting student in the verified track
pass
"""
When purchase goes through, activate the course enrollment
"""
self.course_enrollment.activate()
# Each entry is a dictionary of ModelName: 'lower_case_model_name'
# See https://docs.djangoproject.com/en/1.4/topics/db/models/#multi-table-inheritance for
# PLEASE KEEP THIS LIST UP_TO_DATE WITH THE SUBCLASSES OF OrderItem
ORDER_ITEM_SUBTYPES = {
PaidCourseRegistration: 'paidcourseregistration',
VerifiedCertificate: 'verifiedcertificate',
}
......@@ -57,7 +57,7 @@ def show_cart(request):
@login_required
def clear_cart(request):
cart = Order.get_cart_for_user(request.user)
cart.orderitem_set.all().delete()
cart.clear()
return HttpResponse('Cleared')
@login_required
......@@ -89,7 +89,7 @@ def postpay_callback(request):
return render_to_response('shoppingcart.processor_error.html', {'order':result['order'],
'error_html': result['error_html']})
@login_required
def show_receipt(request, ordernum):
"""
Displays a receipt for a particular order.
......@@ -108,8 +108,3 @@ def show_receipt(request, ordernum):
return render_to_response('shoppingcart/receipt.html', {'order': order,
'order_items': order_items,
'any_refunds': any_refunds})
#def show_orders(request):
"""
Displays all orders of a user
"""
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