-
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.
- Loading branch information
1 parent
7f34da6
commit bade972
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
app/controllers/publish/providers/training_partnerships/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 TrainingPartnerships | ||
class CourseExportsController < ApplicationController | ||
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_partnerships/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 TrainingPartnerships | ||
class CoursesController < ApplicationController | ||
def index | ||
authorize(provider, :index?) | ||
|
||
@courses = fetch_courses | ||
end | ||
|
||
private | ||
|
||
def training_provider | ||
@training_provider ||= provider.training_partners.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_partnerships_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 TrainingPartnershipsController < ApplicationController | ||
def index | ||
authorize(provider, :can_list_training_providers?) | ||
|
||
@training_providers = provider.training_partners.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 |