Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move TrainingProviders to Providers module #4776

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Publish
module Providers
module TrainingProviders
class CourseExportsController < PublishController
def index
authorize(provider, :can_list_training_providers?)

respond_to do |format|
format.csv do
send_data(data_export.data, filename: data_export.filename, disposition: :attachment)
end
end
end

private

def courses
@courses ||= provider.current_accredited_courses
end

def data_export
@data_export ||= Exports::AccreditedCourseList.new(courses:)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

module Publish
module Providers
module TrainingProviders
class CoursesController < PublishController
def index
authorize(provider, :index?)

@courses = fetch_courses
end

private

def training_provider
@training_provider ||= provider.training_providers.find_by(provider_code: params[:training_provider_code])
end

def fetch_courses
training_provider
.courses
.includes(:enrichments, :site_statuses, provider: [:recruitment_cycle])
.where(accredited_provider_code: provider.provider_code)
.order(:name)
.map(&:decorate)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Publish
module Providers
class TrainingProvidersController < PublishController
def index
authorize(provider, :can_list_training_providers?)

@training_providers = provider.training_providers.include_accredited_courses_counts(provider.provider_code).order(:provider_name)
@course_counts = @training_providers.to_h { |p| [p.provider_code, p.accredited_courses_count] }
end
end
end
end

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions app/controllers/publish/training_providers_controller.rb

This file was deleted.

10 changes: 5 additions & 5 deletions config/routes/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@
get '/about', on: :member, to: 'providers#about'
put '/about', on: :member, to: 'providers#update'
get '/details', on: :member, to: 'providers#details'
get '/training-providers-courses', on: :member, to: 'training_providers/course_exports#index', as: 'download_training_providers_courses'

resources :training_providers, path: '/training-providers', only: [:index], param: :code do
resources :courses, only: [:index], controller: 'training_providers/courses'
end

resource :courses, only: %i[create] do
resource :outcome, on: :member, only: %i[new], controller: 'courses/outcome' do
Expand Down Expand Up @@ -256,6 +251,11 @@
end

scope module: :providers do
get '/training-providers-courses', on: :member, to: 'training_providers/course_exports#index', as: 'download_training_providers_courses'
resources :training_providers, path: '/training-providers', only: [:index], param: :code do
resources :courses, module: :training_providers, only: [:index]
end

resources :accredited_providers, param: :accredited_provider_code, only: %i[index new edit create update destroy], path: 'accredited-providers' do
member do
get :delete
Expand Down
Loading