Skip to content

Commit

Permalink
Use Courses::PublishService in Publish::CoursesController#publish
Browse files Browse the repository at this point in the history
  • Loading branch information
inulty-dfe committed Nov 19, 2024
1 parent 19b72f8 commit e5d6dc1
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions app/controllers/publish/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(/^\^/, '') }
Expand Down

0 comments on commit e5d6dc1

Please sign in to comment.