Commit 1a31f251 by Ahsan Ulhaq Committed by GitHub

Merge pull request #14875 from…

Merge pull request #14875 from edx/ahsan/ECOM-7688-users-seeing-500-error-Financial-assistance-application

Financial aid for courses with no course overview
parents d9f17435 65069584
......@@ -789,6 +789,30 @@ class ViewsTestCase(ModuleStoreTestCase):
self.assertNotIn(str(course.id), response.content)
@patch.object(CourseOverview, 'load_from_module_store', return_value=None)
def test_financial_assistance_form_missing_course_overview(self, _mock_course_overview):
"""
Verify that learners can not get financial aid for the courses with no
course overview.
"""
# Create course
course = CourseFactory.create().id
# Create Course Modes
CourseModeFactory.create(mode_slug=CourseMode.AUDIT, course_id=course)
CourseModeFactory.create(mode_slug=CourseMode.VERIFIED, course_id=course)
# Enroll user in the course
enrollment = CourseEnrollmentFactory(course_id=course, user=self.user, mode=CourseMode.AUDIT)
self.assertEqual(enrollment.course_overview, None)
url = reverse('financial_assistance_form')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertNotIn(str(course), response.content)
def test_financial_assistance_form(self):
"""Verify that learner can get the financial aid for the course in which
he/she is enrolled in audit mode whereas the course provide verified mode.
......
......@@ -1599,6 +1599,7 @@ def get_financial_aid_courses(user):
for enrollment in CourseEnrollment.enrollments_for_user(user).order_by('-created'):
if enrollment.mode != CourseMode.VERIFIED and \
enrollment.course_overview and \
enrollment.course_overview.eligible_for_financial_aid and \
CourseMode.objects.filter(
Q(_expiration_datetime__isnull=True) | Q(_expiration_datetime__gt=datetime.now(UTC())),
......
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