Merge pull request #19968 from edx/PROD-58
handle incorrectly set schedules
This commit is contained in:
@@ -741,7 +741,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
user=self.user,
|
||||
course_id=course.id
|
||||
)
|
||||
schedule = ScheduleFactory(start=self.THREE_YEARS_AGO, enrollment=enrollment)
|
||||
schedule = ScheduleFactory(start=self.THREE_YEARS_AGO + timedelta(days=1), enrollment=enrollment)
|
||||
|
||||
response = self.client.get(reverse('dashboard'))
|
||||
dashboard_html = self._remove_whitespace_from_html_string(response.content)
|
||||
|
||||
@@ -261,7 +261,7 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest
|
||||
user=self.user,
|
||||
course_id=course.id
|
||||
)
|
||||
ScheduleFactory(start=self.THREE_YEARS_AGO, enrollment=enrollment)
|
||||
ScheduleFactory(start=self.THREE_YEARS_AGO + datetime.timedelta(days=1), enrollment=enrollment)
|
||||
else:
|
||||
course = CourseFactory.create(start=self.LAST_WEEK, mobile_available=True)
|
||||
self.enroll(course.id)
|
||||
|
||||
@@ -77,6 +77,14 @@ def get_user_course_expiration_date(user, course):
|
||||
# for most people. Using the schedule date will provide flexibility to deal with
|
||||
# more complex business rules in the future.
|
||||
content_availability_date = enrollment.schedule.start
|
||||
# We have anecdotally observed a case where the schedule.start was
|
||||
# equal to the course start, but should have been equal to the enrollment start
|
||||
# https://openedx.atlassian.net/browse/PROD-58
|
||||
# This section is meant to address that case
|
||||
if enrollment.created and course.start:
|
||||
if (content_availability_date.date() == course.start.date() and
|
||||
course.start < enrollment.created < timezone.now()):
|
||||
content_availability_date = enrollment.created
|
||||
except CourseEnrollment.schedule.RelatedObjectDoesNotExist:
|
||||
content_availability_date = max(enrollment.created, course.start)
|
||||
|
||||
|
||||
@@ -523,11 +523,11 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
|
||||
audit_user = UserFactory(password=self.TEST_PASSWORD)
|
||||
self.client.login(username=audit_user.username, password=self.TEST_PASSWORD)
|
||||
audit_enrollment = CourseEnrollment.enroll(audit_user, course.id, mode=CourseMode.AUDIT)
|
||||
ScheduleFactory(start=THREE_YEARS_AGO, enrollment=audit_enrollment)
|
||||
ScheduleFactory(start=THREE_YEARS_AGO + timedelta(days=1), enrollment=audit_enrollment)
|
||||
|
||||
response = self.client.get(url)
|
||||
|
||||
expiration_date = strftime_localized(course.start + timedelta(weeks=4), u'%b. %-d, %Y')
|
||||
expiration_date = strftime_localized(course.start + timedelta(weeks=4) + timedelta(days=1), u'%b. %-d, %Y')
|
||||
expected_params = QueryDict(mutable=True)
|
||||
course_name = CourseOverview.get_from_id(course.id).display_name_with_default
|
||||
expected_params['access_response_error'] = u'Access to {run} expired on {expiration_date}'.format(
|
||||
|
||||
Reference in New Issue
Block a user