diff --git a/lms/djangoapps/mobile_api/users/tests.py b/lms/djangoapps/mobile_api/users/tests.py index ee6eeba9655c4e46d95e0d5a6fceaa7dfd5f55a6..5cf6a0dc9bf3efaca76018458d71faa4a75e030f 100644 --- a/lms/djangoapps/mobile_api/users/tests.py +++ b/lms/djangoapps/mobile_api/users/tests.py @@ -265,7 +265,12 @@ class TestUserEnrollmentApi(UrlResetMixin, MobileAPITestCase, MobileAuthUserTest user=self.user, course_id=course.id ) - ScheduleFactory(start=self.THREE_YEARS_AGO + datetime.timedelta(days=1), enrollment=enrollment) + ScheduleFactory( + # TODO replace 'start' field with 'start_date' after data migration, + # in removing writes from old field step in column renaming release + 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) diff --git a/openedx/core/djangoapps/schedules/admin.py b/openedx/core/djangoapps/schedules/admin.py index bb6e5b13e1deeac50b2130d4711e431b163a4f50..1c0b02e1e6b5fc5827c00d7c1055c5ec614f5f38 100644 --- a/openedx/core/djangoapps/schedules/admin.py +++ b/openedx/core/djangoapps/schedules/admin.py @@ -122,7 +122,9 @@ class CourseIdFilter(admin.SimpleListFilter): @admin.register(models.Schedule) class ScheduleAdmin(admin.ModelAdmin): + # Replace 'start' with 'start_date' once data migration is complete, in removing writes from old field step. list_display = ('username', 'course_id', 'active', 'start', 'upgrade_deadline', 'experience_display') + # Replace 'start' with 'start_date' once data migration is complete, in removing writes from old field step. list_display_links = ('start', 'upgrade_deadline', 'experience_display') list_filter = ( CourseIdFilter, diff --git a/openedx/core/djangoapps/schedules/management/commands/setup_models_to_send_test_emails.py b/openedx/core/djangoapps/schedules/management/commands/setup_models_to_send_test_emails.py index 9d2eac6612ab065e2f3e35fd520ed7c7c73e3f32..e975713fb90c7ac0cd4f2f5e0f9e35b5872acd78 100644 --- a/openedx/core/djangoapps/schedules/management/commands/setup_models_to_send_test_emails.py +++ b/openedx/core/djangoapps/schedules/management/commands/setup_models_to_send_test_emails.py @@ -27,21 +27,30 @@ class ThreeDayNudgeSchedule(ScheduleFactory): """ A ScheduleFactory that creates a Schedule set up for a 3-day nudge email. """ + # TODO: Remove 'start' once data migration is complete, after removing reference to old field step, + # and use new field in column renames. start = factory.Faker('date_time_between', start_date='-3d', end_date='-3d', tzinfo=pytz.UTC) + # start_date = factory.Faker('date_time_between', start_date='-3d', end_date='-3d', tzinfo=pytz.UTC) class TenDayNudgeSchedule(ScheduleFactory): """ A ScheduleFactory that creates a Schedule set up for a 10-day nudge email. """ + # TODO: Remove 'start' once data migration is complete, after removing reference to old field step, + # and use new field in column renames. start = factory.Faker('date_time_between', start_date='-10d', end_date='-10d', tzinfo=pytz.UTC) + # start_date = factory.Faker('date_time_between', start_date='-10d', end_date='-10d', tzinfo=pytz.UTC) class UpgradeReminderSchedule(ScheduleFactory): """ A ScheduleFactory that creates a Schedule set up for a 2-days-remaining upgrade reminder. """ + # TODO: Remove 'start' once data migration is complete, after removing reference to old field step, + # and use new field in column renames. start = factory.Faker('past_datetime', tzinfo=pytz.UTC) + # start_date = factory.Faker('past_datetime', tzinfo=pytz.UTC) upgrade_deadline = factory.Faker('date_time_between', start_date='+2d', end_date='+2d', tzinfo=pytz.UTC) @@ -49,7 +58,10 @@ class ContentHighlightSchedule(ScheduleFactory): """ A ScheduleFactory that creates a Schedule set up for a course highlights email. """ + # TODO: Remove 'start' once data migration is complete, after removing reference to old field step, + # and use new field in column renames. start = factory.Faker('date_time_between', start_date='-7d', end_date='-7d', tzinfo=pytz.UTC) + # start_date = factory.Faker('date_time_between', start_date='-7d', end_date='-7d', tzinfo=pytz.UTC) experience = factory.RelatedFactory(ScheduleExperienceFactory, 'schedule', experience_type=ScheduleExperience.EXPERIENCES.course_updates) diff --git a/openedx/core/djangoapps/schedules/resolvers.py b/openedx/core/djangoapps/schedules/resolvers.py index 1d4b3399e551e4ae4d7248805caa3c718f33298b..90113826352442e602135d838dcf0284554ca333 100644 --- a/openedx/core/djangoapps/schedules/resolvers.py +++ b/openedx/core/djangoapps/schedules/resolvers.py @@ -336,6 +336,8 @@ class CourseUpdateResolver(BinnedSchedulesBaseResolver): course has updates. """ log_prefix = 'Course Update' + # TODO assign 'schedule_date_field' value to new column ('start_date') + # once data migration step is completed in column renames. schedule_date_field = 'start' num_bins = COURSE_UPDATE_NUM_BINS experience_filter = Q(experience__experience_type=ScheduleExperience.EXPERIENCES.course_updates) diff --git a/openedx/core/djangoapps/schedules/signals.py b/openedx/core/djangoapps/schedules/signals.py index 96c320ef6f9bb76164c0af87a7de24ba525f6e4d..99886b82a38f895743f190b7bba4ffeee362dade 100644 --- a/openedx/core/djangoapps/schedules/signals.py +++ b/openedx/core/djangoapps/schedules/signals.py @@ -196,7 +196,9 @@ def _create_schedule(enrollment, enrollment_created): schedule = Schedule.objects.create( enrollment=enrollment, + # TODO remove 'start' field in removing writes from old field step in column renaming release start=content_availability_date, + start_date=content_availability_date, upgrade_deadline=upgrade_deadline ) diff --git a/openedx/core/djangoapps/schedules/tasks.py b/openedx/core/djangoapps/schedules/tasks.py index e078921911fb6a0c17fbd2b018562456d21bb342..d410380dc55562ca60433c06d72c9a2331e4305e 100644 --- a/openedx/core/djangoapps/schedules/tasks.py +++ b/openedx/core/djangoapps/schedules/tasks.py @@ -48,7 +48,9 @@ def update_course_schedules(self, **kwargs): try: Schedule.objects.filter(enrollment__course_id=course_key).update( + # TODO remove 'start' field in removing writes from old field step in column renaming release start=new_start_date, + start_date=new_start_date, upgrade_deadline=new_upgrade_deadline ) except Exception as exc: diff --git a/openedx/core/djangoapps/schedules/tests/factories.py b/openedx/core/djangoapps/schedules/tests/factories.py index bb984a25a66a6c2ea23a062903cfd0c830dc74d7..c50a73d53c826364f0c8bb24dfcb7ef29884b003 100644 --- a/openedx/core/djangoapps/schedules/tests/factories.py +++ b/openedx/core/djangoapps/schedules/tests/factories.py @@ -22,6 +22,8 @@ class ScheduleFactory(factory.DjangoModelFactory): class Meta(object): model = models.Schedule + # TODO replace 'start' field with 'start_date' after data migration, + # in removing writes from old field step in column renaming release start = factory.Faker('future_datetime', tzinfo=pytz.UTC) upgrade_deadline = factory.Faker('future_datetime', tzinfo=pytz.UTC) enrollment = factory.SubFactory(CourseEnrollmentFactory)