Commit 6198b900 by Chris Dodge

only display the count for coupon redemptions that actually went through to purchase completion

parent 1fa1d357
...@@ -1794,6 +1794,40 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa ...@@ -1794,6 +1794,40 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
self.assertIn(item.status, response.content.split('\r\n')[1],) self.assertIn(item.status, response.content.split('\r\n')[1],)
self.assertIn(coupon_redemption[0].coupon.code, 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('<td>0</td>', 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('<td>1</td>', resp.content)
def test_get_sale_records_features_csv(self): def test_get_sale_records_features_csv(self):
""" """
Test that the response from get_sale_records is in csv format. Test that the response from get_sale_records is in csv format.
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<th class="c_code">${_("Code")}</th> <th class="c_code">${_("Code")}</th>
<th class="c_dsc">${_("Description")}</th> <th class="c_dsc">${_("Description")}</th>
<th class="c_discount">${_("Discount (%)")}</th> <th class="c_discount">${_("Discount (%)")}</th>
<th class="c_count">${_("Count")}</th> <th class="c_count">${_("Redeem Count")}</th>
<th class="c_action">${_("Actions")}</th> <th class="c_action">${_("Actions")}</th>
</tr> </tr>
</thead> </thead>
...@@ -110,10 +110,7 @@ ...@@ -110,10 +110,7 @@
<td>${_('{code}').format(code=coupon.code)}</td> <td>${_('{code}').format(code=coupon.code)}</td>
<td>${_('{description}').format(description=coupon.description)}</td> <td>${_('{description}').format(description=coupon.description)}</td>
<td>${_('{discount}').format(discount=coupon.percentage_discount)}</td> <td>${_('{discount}').format(discount=coupon.percentage_discount)}</td>
<td> <td>${ coupon.couponredemption_set.filter(order__status='purchased').count() }</td>
${ coupon.couponredemption_set.all().count() }
</td>
<!--<td>${coupon.is_active}</td>-->
<td><a data-item-id="${coupon.id}" class='remove_coupon' href='#'>[x]</a><a href="#edit-modal" data-item-id="${coupon.id}" class="edit-right">${_('Edit')}</a></td> <td><a data-item-id="${coupon.id}" class='remove_coupon' href='#'>[x]</a><a href="#edit-modal" data-item-id="${coupon.id}" class="edit-right">${_('Edit')}</a></td>
</tr> </tr>
%endfor %endfor
......
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