Last active
October 3, 2023 14:57
-
-
Save defong/bb7bee0477d427f9765d199210ac0af6 to your computer and use it in GitHub Desktop.
[DfE] 2262-copy-over-courses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copies the courses for theses providers | |
providers_to_copy_to = RecruitmentCycle.current.providers.where(provider_code: [ | |
"3F4" | |
]) | |
provider_to_copy_from = RecruitmentCycle.current.providers.find_by(provider_code: "3F2") | |
courses = provider_to_copy_from.courses.where.not(accredited_provider_code: "C58") | |
copier = Courses::CopyToProviderService.new(sites_copy_to_course: Sites::CopyToCourseService, enrichments_copy_to_course: Enrichments::CopyToCourseService.new, force: true) | |
providers_to_copy_to.each do |new_provider| | |
courses.each do |course| | |
course.study_sites = [] | |
new_course = copier.execute(course:, new_provider: ) | |
new_course.enrichments.first.draft! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment