Skip to content

Commit ad1af6e

Browse files
committed
fix: exclude course runs from retired programs
Once a course run is reviewed check to see if it is part of a retired program. If it is, then move this newly reviewed course run to excluded course run of the retired program. VAN-748
1 parent 9ad8bbb commit ad1af6e

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

course_discovery/apps/course_metadata/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,6 @@ def save(self, suppress_publication=False, send_emails=True, **kwargs): # pylin
18481848
suppress_publication (bool): if True, we won't push the run data to the marketing site
18491849
send_emails (bool): whether to send email notifications for status changes from this save
18501850
"""
1851-
is_new_course_run = not self.id
18521851
push_to_marketing = (not suppress_publication and
18531852
self.course.partner.has_marketing_site and
18541853
waffle.switch_is_active('publish_course_runs_to_marketing_site') and
@@ -1864,7 +1863,7 @@ def save(self, suppress_publication=False, send_emails=True, **kwargs): # pylin
18641863
if push_to_marketing:
18651864
self.push_to_marketing_site(previous_obj)
18661865

1867-
if is_new_course_run:
1866+
if self.status == CourseRunStatus.Reviewed and not self.draft:
18681867
retired_programs = self.programs.filter(status=ProgramStatus.Retired)
18691868
for program in retired_programs:
18701869
program.excluded_course_runs.add(self)

course_discovery/apps/course_metadata/tests/test_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,15 @@ def test_exclude_deleted_program_types(self):
582582
assert self.course_run.program_types == [active_program.type.name]
583583

584584
def test_new_course_run_excluded_in_retired_programs(self):
585-
""" Verify the newly created course run must be excluded in associated retired programs"""
585+
""" Verify the newly reviewed course run must be excluded in associated retired programs"""
586586
course = factories.CourseFactory()
587587
course_run = factories.CourseRunFactory(course=course)
588588
program = factories.ProgramFactory(
589589
courses=[course], status=ProgramStatus.Retired,
590590
)
591591
course_run.weeks_to_complete = 2
592592
course_run.save()
593-
new_course_run = factories.CourseRunFactory(course=course)
593+
new_course_run = factories.CourseRunFactory(course=course, status=CourseRunStatus.Reviewed, draft=False)
594594
new_course_run.save()
595595
assert program.excluded_course_runs.count() == 1
596596
assert len(list(program.course_runs)) == 1

0 commit comments

Comments
 (0)