Add reference to new field in schedule model
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user