Merge pull request #25562 from edx/ddumesnil/no-updates-after-end-aa-422
AA-422: Ensure learners are not receiving updates after course end
This commit is contained in:
@@ -473,6 +473,10 @@ class CourseNextSectionUpdate(PrefixedDebugLoggerMixin, RecipientResolver):
|
||||
template_context = get_base_template_context(self.site)
|
||||
for schedule in schedules:
|
||||
course = schedule.enrollment.course
|
||||
# We don't want to show any updates if the course has ended so we short circuit here.
|
||||
if course.end and course.end.date() <= target_date:
|
||||
return
|
||||
|
||||
user = schedule.enrollment.user
|
||||
start_date = max(filter(None, (schedule.start_date, course.start)))
|
||||
LOG.info('Received a schedule for user {} in course {} for date {}'.format(
|
||||
|
||||
@@ -252,3 +252,11 @@ class TestCourseNextSectionUpdateResolver(SchedulesResolverTestMixin, ModuleStor
|
||||
log_message = ('Next Section Course Update: Last section was reached. '
|
||||
'There are no more highlights for {}'.format(self.course.id))
|
||||
log_capture.check_present((LOG.name, 'WARNING', log_message))
|
||||
|
||||
@override_waffle_flag(COURSE_UPDATE_WAFFLE_FLAG, True)
|
||||
def test_no_updates_if_course_ended(self):
|
||||
self.course.end = self.yesterday
|
||||
self.course = self.update_course(self.course, self.user.id)
|
||||
resolver = self.create_resolver()
|
||||
schedules = list(resolver.get_schedules())
|
||||
self.assertListEqual(schedules, [])
|
||||
|
||||
Reference in New Issue
Block a user