Last active
October 3, 2023 15:12
-
-
Save defong/a525bd0f717be647f2dd2b7b2c6d6958 to your computer and use it in GitHub Desktop.
[DfE] 2263-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: [ | |
"3FP" | |
]) | |
provider_to_copy_from = RecruitmentCycle.current.providers.find_by(provider_code: "1FP") | |
courses = provider_to_copy_from.courses.where(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