Unverified Commit 0cb6bad7 by Anthony Mangano Committed by GitHub

Merge pull request #16971 from edx/fix-for-LEARNER-3482

Ensure enrollment_end is parsed to datetime prior to making comparisons
parents 0efc3764 47287de4
...@@ -363,7 +363,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -363,7 +363,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
mock_course_runs.return_value = [ mock_course_runs.return_value = [
{ {
'key': 'course-v1:FAKE+FA1-MA1.X+3T2017', 'key': 'course-v1:FAKE+FA1-MA1.X+3T2017',
'enrollment_end': self.TOMORROW, 'enrollment_end': str(self.TOMORROW),
'pacing_type': 'instructor_paced', 'pacing_type': 'instructor_paced',
'type': 'verified' 'type': 'verified'
} }
...@@ -391,7 +391,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -391,7 +391,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
mock_course_runs.return_value = [ mock_course_runs.return_value = [
{ {
'key': 'course-v1:FAKE+FA1-MA1.X+3T2017', 'key': 'course-v1:FAKE+FA1-MA1.X+3T2017',
'enrollment_end': self.TOMORROW, 'enrollment_end': str(self.TOMORROW),
'pacing_type': 'instructor_paced', 'pacing_type': 'instructor_paced',
'type': 'verified' 'type': 'verified'
} }
...@@ -418,8 +418,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -418,8 +418,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
course_enrollment = CourseEnrollmentFactory(user=self.user, course_id=unicode(mocked_course_overview.id)) course_enrollment = CourseEnrollmentFactory(user=self.user, course_id=unicode(mocked_course_overview.id))
mock_course_runs.return_value = [ mock_course_runs.return_value = [
{ {
'key': mocked_course_overview.id, 'key': str(mocked_course_overview.id),
'enrollment_end': mocked_course_overview.enrollment_end, 'enrollment_end': str(mocked_course_overview.enrollment_end),
'pacing_type': 'self_paced', 'pacing_type': 'self_paced',
'type': 'verified' 'type': 'verified'
} }
...@@ -436,8 +436,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -436,8 +436,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
mock_course_key.return_value = mocked_course_overview.id mock_course_key.return_value = mocked_course_overview.id
mock_course_runs.return_value = [ mock_course_runs.return_value = [
{ {
'key': mocked_course_overview.id, 'key': str(mocked_course_overview.id),
'enrollment_end': mocked_course_overview.enrollment_end, 'enrollment_end': str(mocked_course_overview.enrollment_end),
'pacing_type': 'self_paced', 'pacing_type': 'self_paced',
'type': 'verified' 'type': 'verified'
} }
...@@ -453,8 +453,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -453,8 +453,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
mock_course_key.return_value = mocked_course_overview.id mock_course_key.return_value = mocked_course_overview.id
mock_course_runs.return_value = [ mock_course_runs.return_value = [
{ {
'key': mocked_course_overview.id, 'key': str(mocked_course_overview.id),
'enrollment_end': mocked_course_overview.enrollment_end, 'enrollment_end': None,
'pacing_type': 'self_paced', 'pacing_type': 'self_paced',
'type': 'verified' 'type': 'verified'
} }
...@@ -483,8 +483,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -483,8 +483,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
course_enrollment = CourseEnrollmentFactory(user=self.user, course_id=unicode(mocked_course_overview.id)) course_enrollment = CourseEnrollmentFactory(user=self.user, course_id=unicode(mocked_course_overview.id))
mock_course_runs.return_value = [ mock_course_runs.return_value = [
{ {
'key': mocked_course_overview.id, 'key': str(mocked_course_overview.id),
'enrollment_end': mocked_course_overview.enrollment_end, 'enrollment_end': str(mocked_course_overview.enrollment_end),
'pacing_type': 'self_paced', 'pacing_type': 'self_paced',
'type': 'verified' 'type': 'verified'
} }
...@@ -519,8 +519,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -519,8 +519,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin):
course_enrollment = CourseEnrollmentFactory(user=self.user, course_id=unicode(mocked_course_overview.id), created=self.THREE_YEARS_AGO) course_enrollment = CourseEnrollmentFactory(user=self.user, course_id=unicode(mocked_course_overview.id), created=self.THREE_YEARS_AGO)
mock_course_runs.return_value = [ mock_course_runs.return_value = [
{ {
'key': mocked_course_overview.id, 'key': str(mocked_course_overview.id),
'enrollment_end': mocked_course_overview.enrollment_end, 'enrollment_end': str(mocked_course_overview.enrollment_end),
'pacing_type': 'self_paced', 'pacing_type': 'self_paced',
'type': 'verified' 'type': 'verified'
} }
......
...@@ -3,6 +3,7 @@ Student Views ...@@ -3,6 +3,7 @@ Student Views
""" """
import datetime import datetime
import dateutil
import json import json
import logging import logging
import uuid import uuid
...@@ -708,7 +709,7 @@ def dashboard(request): ...@@ -708,7 +709,7 @@ def dashboard(request):
for course_run in course_runs_for_course: for course_run in course_runs_for_course:
enrollment_end = course_run.get('enrollment_end') enrollment_end = course_run.get('enrollment_end')
if not enrollment_end or enrollment_end > datetime.datetime.now(UTC): if not enrollment_end or (dateutil.parser.parse(enrollment_end) > datetime.datetime.now(UTC)):
enrollable_course_runs.append(course_run) enrollable_course_runs.append(course_run)
course_entitlement_available_sessions[str(course_entitlement.uuid)] = enrollable_course_runs course_entitlement_available_sessions[str(course_entitlement.uuid)] = enrollable_course_runs
......
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