diff --git a/lms/djangoapps/courseware/tests/test_access.py b/lms/djangoapps/courseware/tests/test_access.py
index 97e64eea91..b2c1a14bdf 100644
--- a/lms/djangoapps/courseware/tests/test_access.py
+++ b/lms/djangoapps/courseware/tests/test_access.py
@@ -1,14 +1,20 @@
from mock import Mock
from django.test import TestCase
+from django.test.utils import override_settings
from xmodule.modulestore import Location
import courseware.access as access
+from courseware.tests.tests import TEST_DATA_MIXED_MODULESTORE
from .factories import CourseEnrollmentAllowedFactory
import datetime
from django.utils.timezone import UTC
+from student.tests.factories import UserFactory
+from xmodule.modulestore.tests.factories import CourseFactory
+
+@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
class AccessTestCase(TestCase):
def test__has_global_staff_access(self):
u = Mock(is_staff=False)
@@ -108,18 +114,19 @@ class AccessTestCase(TestCase):
# Non-staff cannot enroll outside the open enrollment period if not specifically allowed
def test__has_access_refund(self):
- user = Mock()
+ user = UserFactory.create()
+ course = CourseFactory.create(org='org', number='test', run='course', display_name='Test Course')
today = datetime.datetime.now(UTC())
grace_period = datetime.timedelta(days=14)
one_day_extra = datetime.timedelta(days=1)
# User is allowed to receive refund if it is within two weeks of course start date
- course = Mock(enrollment_start=(today - one_day_extra), id='edX/tests/Whenever')
+ course.enrollment_start = (today - one_day_extra)
self.assertTrue(access._has_access_course_desc(user, course, 'refund'))
- course = Mock(enrollment_start=(today - grace_period), id='edX/test/Whenever')
+ course.enrollment_start = (today - grace_period)
self.assertTrue(access._has_access_course_desc(user, course, 'refund'))
# After two weeks, user may no longer receive a refund
- course = Mock(enrollment_start=(today - grace_period - one_day_extra), id='edX/test/Whenever')
+ course.enrollment_start = (today - grace_period - one_day_extra)
self.assertFalse(access._has_access_course_desc(user, course, 'refund'))
diff --git a/lms/djangoapps/shoppingcart/models.py b/lms/djangoapps/shoppingcart/models.py
index 834034624e..f75b31e1ce 100644
--- a/lms/djangoapps/shoppingcart/models.py
+++ b/lms/djangoapps/shoppingcart/models.py
@@ -413,7 +413,6 @@ class CertificateItem(OrderItem):
try:
course_id = kwargs['course_id']
user = kwargs['user']
- user_email = kwargs['user_email']
# If there's duplicate entries, just grab the first one and refund it (though in most cases we should only get one)
target_certs = CertificateItem.objects.filter(course_id=course_id, user_id=user, status='purchased', mode='verified')
@@ -425,7 +424,7 @@ class CertificateItem(OrderItem):
# send billing an email so they can handle refunding
subject = _("[Refund] User-Requested Refund")
- message = "User " + str(user) + "(" + str(user_email) + ") has requested a refund on Order #" + str(order_number) + "."
+ message = "User " + str(user) + "(" + str(user.email) + ") has requested a refund on Order #" + str(order_number) + "."
to_email = [settings.PAYMENT_SUPPORT_EMAIL]
from_email = "support@edx.org"
send_mail(subject, message, from_email, to_email, fail_silently=False)
@@ -433,7 +432,7 @@ class CertificateItem(OrderItem):
return target_cert
except IndexError:
- log.exception("No certificate found")
+ log.exception("Matching CertificateItem not found while trying to refund. User %s, Course %s", user, course_id)
raise IndexError
@classmethod
diff --git a/lms/templates/dashboard/_dashboard_course_listing.html b/lms/templates/dashboard/_dashboard_course_listing.html
index 13346c9842..0896797a0f 100644
--- a/lms/templates/dashboard/_dashboard_course_listing.html
+++ b/lms/templates/dashboard/_dashboard_course_listing.html
@@ -144,9 +144,9 @@
% if enrollment.mode != "verified":
${_('Unregister')}
% elif show_refund_option:
- ${_('Unregister')}
+ ${_('Unregister')}
% else:
- ${_('Unregister')}
+ ${_('Unregister')}
% endif
% if show_email_settings: