diff --git a/lms/djangoapps/mobile_api/users/tests.py b/lms/djangoapps/mobile_api/users/tests.py index ee6eeba965..5cf6a0dc9b 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 bb6e5b13e1..1c0b02e1e6 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 9d2eac6612..e975713fb9 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 1d4b3399e5..9011382635 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 96c320ef6f..99886b82a3 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 e078921911..d410380dc5 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 bb984a25a6..c50a73d53c 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)