From cbb259eb1f4705e8b9145c592ca5c6a101232039 Mon Sep 17 00:00:00 2001 From: David Ormsbee <dave@edx.org> Date: Fri, 23 Aug 2013 11:07:06 -0400 Subject: [PATCH] Allow amounts specified to actually work for purchasing certificates --- common/djangoapps/course_modes/views.py | 8 ++++++++ common/templates/course_modes/choose.html | 19 +++++++------------ lms/djangoapps/verify_student/views.py | 7 ++++++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/common/djangoapps/course_modes/views.py b/common/djangoapps/course_modes/views.py index a2ccc8583ab..13bbb2d4f8c 100644 --- a/common/djangoapps/course_modes/views.py +++ b/common/djangoapps/course_modes/views.py @@ -47,6 +47,14 @@ class ChooseModeView(View): return redirect('dashboard') if requested_mode == "verified": + amount = request.POST.get("contribution") or \ + request.POST.get("contribution-other-amt") or \ + requested_mode.min_price + + donation_for_course = request.session.get("donation_for_course", {}) + donation_for_course[course_id] = float(amount) + request.session["donation_for_course"] = donation_for_course + return redirect( "{}?{}".format( reverse('verify_student_verify'), diff --git a/common/templates/course_modes/choose.html b/common/templates/course_modes/choose.html index 6c9bf1a0a84..111bdf8dfca 100644 --- a/common/templates/course_modes/choose.html +++ b/common/templates/course_modes/choose.html @@ -39,24 +39,19 @@ <p>Sign up as a verified student and work toward a Certificate of Achievement.</p> <dl> <dt> - Select your contribution for this course (in USD): + Select your contribution for this course (in ${modes["verified"].currency.upper()|h}): </dt> <dd> <ul> + % for price in modes["verified"].suggested_prices.split(","): <li> - <input type="radio" name="contribution-25" id="contribution"> <label for="contribution-25">$25</label> + <input type="radio" name="contribution" value="${price|h}"><label for="contribution-${price|h}">$${price}</label> </li> + % endfor <li> - <input type="radio" name="contribution-50" id="contribution"> <label for="contribution-50">$50</label> - </li> - <li> - <input type="radio" name="contribution-100" id="contribution"> <label for="contribution-100">$100</label> - </li> - <li> - <input type="radio" name="contribution-other" id="contribution"> <label for="contribution-other">Other</label> - </li> - <li> - <label for="contribution-other-amt">Other Amount</label> <input type="text" name="contribution-other" id="contribution-other-amt"> + <input type="radio" name="contribution" value=""/> + <label for="contribution-other-amt">Other Amount</label> + $<input type="text" name="contribution-other-amt" id="contribution-other-amt" /> </li> </ul> </dd> diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 79ad5589b7f..18461bc180d 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -58,11 +58,16 @@ def create_order(request): attempt.save() course_id = request.POST['course_id'] + donation_for_course = request.session.get("donation_for_course", {}) + + # FIXME: When this isn't available we do...? + amount = donation_for_course.get(course_id) # I know, we should check this is valid. All kinds of stuff missing here # enrollment = CourseEnrollment.create_enrollment(request.user, course_id) cart = Order.get_cart_for_user(request.user) - CertificateItem.add_to_order(cart, course_id, 30, 'verified') + cart.clear() + CertificateItem.add_to_order(cart, course_id, amount, 'verified') params = get_signed_purchase_params(cart) -- GitLab