From e5d6dc126a1f12a2da48afa7bad5b2d1a706c4f6 Mon Sep 17 00:00:00 2001 From: Iain McNulty Date: Tue, 19 Nov 2024 10:51:07 +0000 Subject: [PATCH] Use Courses::PublishService in Publish::CoursesController#publish --- app/controllers/publish/courses_controller.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/app/controllers/publish/courses_controller.rb b/app/controllers/publish/courses_controller.rb index 7c3d06aa5b..6dff10b42c 100644 --- a/app/controllers/publish/courses_controller.rb +++ b/app/controllers/publish/courses_controller.rb @@ -72,8 +72,7 @@ def publish fetch_course authorize @course - if @course.publishable? - publish_course + if ::Courses::PublishService.new(course: @course, user: @current_user).call flash[:success] = 'Your course has been published.' redirect_to publish_provider_recruitment_cycle_course_path( @@ -130,15 +129,6 @@ def self_accredited_courses @self_accredited_courses ||= courses_by_accrediting_provider.delete(provider.provider_name) end - def publish_course - Course.transaction do - @course.publish_sites - @course.publish_enrichment(@current_user) - @course.application_status_open! - NotificationService::CoursePublished.call(course: @course) - end - end - def format_publish_error_messages @course.errors.messages.transform_values do |error_messages| error_messages.map { |message| message.gsub(/^\^/, '') }