Commit 2c984719 by Anthony Mangano Committed by Michael LoTurco

ensure enrollment_end is parsed to datetime prior to making comparisons

parent 5a8579d3
...@@ -361,7 +361,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -361,7 +361,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'
} }
...@@ -389,7 +389,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -389,7 +389,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'
} }
...@@ -416,8 +416,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -416,8 +416,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'
} }
...@@ -434,8 +434,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -434,8 +434,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'
} }
...@@ -451,8 +451,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -451,8 +451,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'
} }
...@@ -481,8 +481,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -481,8 +481,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'
} }
...@@ -517,8 +517,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin): ...@@ -517,8 +517,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