From 6198b90051ad6d17703b8c337f84b6cc92224181 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Fri, 19 Dec 2014 13:38:55 -0500 Subject: [PATCH] only display the count for coupon redemptions that actually went through to purchase completion --- lms/djangoapps/instructor/tests/test_api.py | 34 +++++++++++++++++++ .../instructor_dashboard_2/e-commerce.html | 7 ++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index 683490515e..72e9961f79 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -1794,6 +1794,40 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa self.assertIn(item.status, response.content.split('\r\n')[1],) self.assertIn(coupon_redemption[0].coupon.code, response.content.split('\r\n')[1],) + def test_coupon_redeem_count_in_ecommerce_section(self): + """ + Test that checks the redeem count in the instructor_dashboard coupon section + """ + # add the coupon code for the course + coupon = Coupon( + code='test_code', description='test_description', course_id=self.course.id, + percentage_discount='10', created_by=self.instructor, is_active=True + ) + coupon.save() + PaidCourseRegistration.add_to_order(self.cart, self.course.id) + # apply the coupon code to the item in the cart + resp = self.client.post(reverse('shoppingcart.views.use_code'), {'code': coupon.code}) + self.assertEqual(resp.status_code, 200) + + # URL for instructor dashboard + instructor_dashboard = reverse('instructor_dashboard', kwargs={'course_id': self.course.id.to_deprecated_string()}) + # visit the instructor dashboard page and + # check that the coupon redeem count should be 0 + resp = self.client.get(instructor_dashboard) + self.assertEqual(resp.status_code, 200) + self.assertIn('Redeem Count', resp.content) + self.assertIn('0', resp.content) + + # now make the payment of your cart items + self.cart.purchase() + # visit the instructor dashboard page and + # check that the coupon redeem count should be 1 + resp = self.client.get(instructor_dashboard) + self.assertEqual(resp.status_code, 200) + + self.assertIn('Redeem Count', resp.content) + self.assertIn('1', resp.content) + def test_get_sale_records_features_csv(self): """ Test that the response from get_sale_records is in csv format. diff --git a/lms/templates/instructor/instructor_dashboard_2/e-commerce.html b/lms/templates/instructor/instructor_dashboard_2/e-commerce.html index f520d58537..d656a5bbf3 100644 --- a/lms/templates/instructor/instructor_dashboard_2/e-commerce.html +++ b/lms/templates/instructor/instructor_dashboard_2/e-commerce.html @@ -96,7 +96,7 @@ ${_("Code")} ${_("Description")} ${_("Discount (%)")} - ${_("Count")} + ${_("Redeem Count")} ${_("Actions")} @@ -110,10 +110,7 @@ ${_('{code}').format(code=coupon.code)} ${_('{description}').format(description=coupon.description)} ${_('{discount}').format(discount=coupon.percentage_discount)} - - ${ coupon.couponredemption_set.all().count() } - - + ${ coupon.couponredemption_set.filter(order__status='purchased').count() } [x]${_('Edit')} %endfor