-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move TrainingProviders to Providers module
- Loading branch information
1 parent
794c328
commit 2bceab5
Showing
9 changed files
with
78 additions
and
72 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
app/controllers/publish/providers/training_providers/course_exports_controller.rb
This file contains 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
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 |
30 changes: 30 additions & 0 deletions
30
app/controllers/publish/providers/training_providers/courses_controller.rb
This file contains 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
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 |
14 changes: 14 additions & 0 deletions
14
app/controllers/publish/providers/training_providers_controller.rb
This file contains 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
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 |
27 changes: 0 additions & 27 deletions
27
app/controllers/publish/training_providers/course_exports_controller.rb
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
app/controllers/publish/training_providers/courses_controller.rb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains 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