-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add Provider partnerships to training partners #4842
Changes from all commits
fce3002
dc14498
a6f8e3e
c959a45
925e03c
b8d8eca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<% if required_organisation_details_present? %> | ||
<%= govuk_button_link_to( | ||
"Add course", | ||
new_publish_provider_recruitment_cycle_course_path( | ||
provider_code: provider.provider_code, | ||
recruitment_cycle_year: provider.recruitment_cycle_year | ||
), | ||
class: "govuk-!-margin-bottom-6" | ||
) %> | ||
|
||
<% else %> | ||
|
||
<div class="govuk-inset-text"> | ||
<p class="govuk-body">Before adding a course, you need to:</p> | ||
<ul class="govuk-list govuk-list--bullet"> | ||
<% incomplete_sections.each do |section| %> | ||
<li> | ||
<%= govuk_link_to(section.name, section.path) %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddCourseButtonEnrichments < ViewComponent::Base | ||
include RecruitmentCycleHelper | ||
attr_reader :provider | ||
|
||
Section = Struct.new(:name, :path, keyword_init: true) | ||
|
||
def initialize(provider:) | ||
@provider = provider | ||
super | ||
end | ||
|
||
private | ||
|
||
def incomplete_sections | ||
incomplete_sections_hash.keys.select { |section| send(section) }.map do |section| | ||
Section.new(name: "add #{incomplete_section_article(section)} #{incomplete_section_label_suffix(section)}", path: incomplete_sections_hash[section]) | ||
end | ||
end | ||
|
||
def incomplete_sections_hash | ||
{ | ||
site_not_present?: publish_provider_recruitment_cycle_schools_path(provider.provider_code, provider.recruitment_cycle_year), | ||
accredited_provider_not_present?: publish_provider_recruitment_cycle_accredited_providers_path(provider.provider_code, provider.recruitment_cycle_year) | ||
} | ||
end | ||
|
||
def incomplete_section_label_suffix(section) | ||
labels = { | ||
accredited_provider_not_present?: 'accredited provider', | ||
site_not_present?: 'school' | ||
} | ||
|
||
labels[section] | ||
end | ||
|
||
def required_organisation_details_present? | ||
accredited_provider_present? && site_present? | ||
end | ||
|
||
def accredited_provider_present? | ||
return true if accredited_provider? | ||
|
||
provider.accredited_providers.any? | ||
end | ||
|
||
def site_present? | ||
provider.sites.any? | ||
end | ||
|
||
def accredited_provider_not_present? | ||
return false if provider.accredited? | ||
|
||
!accredited_provider_present? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this simplified by the same idea? https://github.com/DFE-Digital/publish-teacher-training/pull/4842/files#r1926738703 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is getting deleted after the switch to provider partnerships |
||
end | ||
|
||
def site_not_present? | ||
!site_present? | ||
end | ||
|
||
def accredited_provider? | ||
provider.accredited? | ||
end | ||
|
||
def incomplete_section_article(section) | ||
incomplete_section_label_suffix(section) == 'accredited provider' ? 'an' : 'a' | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Publish | ||
module Providers | ||
module TrainingPartners | ||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Publish | ||
module Providers | ||
module TrainingPartners | ||
class CoursesController < ApplicationController | ||
def index | ||
authorize(provider, :index?) | ||
|
||
@courses = fetch_courses | ||
end | ||
|
||
private | ||
|
||
def training_partner | ||
@training_partner ||= provider.training_partners.find_by(provider_code: params[:training_partner_code]) | ||
end | ||
|
||
def fetch_courses | ||
training_partner | ||
.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 TrainingPartnersController < ApplicationController | ||
def index | ||
authorize(provider, :can_list_training_providers?) | ||
|
||
@training_partners = provider.training_partners.include_accredited_courses_counts(provider.provider_code).order(:provider_name) | ||
@course_counts = @training_partners.to_h { |p| [p.provider_code, p.accredited_courses_count] } | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% content_for :page_title, @provider.provider_name %> | ||
<%= content_for :before_content, render_breadcrumbs(:training_provider_courses) %> | ||
|
||
<h1 class="govuk-heading-l"> | ||
<span class="govuk-caption-l"><%= t(".title") %></span> | ||
<%= @training_partner.provider_name %> | ||
</h1> | ||
|
||
<section data-qa="courses__table-section"> | ||
<%= render partial: "publish/courses/course_table", locals: { courses: @courses } %> | ||
</section> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<% content_for :page_title, "Training partners" %> | ||
<%= content_for :before_content, render_breadcrumbs(:training_providers) %> | ||
|
||
<h1 class="govuk-heading-l"> | ||
<%= t(".title") %> | ||
</h1> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
|
||
<ul class="govuk-list" data-qa="provider__training_partners_list"> | ||
<% @training_partners.each do |training_partner| %> | ||
<li data-qa="training_partner"> | ||
<h3 class="govuk-heading-s"> | ||
<% if Settings.features.provider_partnerships %> | ||
<%= govuk_link_to( | ||
training_partner.provider_name, | ||
publish_provider_recruitment_cycle_training_partner_courses_path( | ||
@provider.provider_code, | ||
@provider.recruitment_cycle_year, | ||
training_partner.provider_code | ||
), | ||
class: "govuk-!-font-weight-bold", | ||
data: { qa: "training_partner_name" } | ||
) %> | ||
<% else %> | ||
<%= govuk_link_to( | ||
training_partner.provider_name, | ||
publish_provider_recruitment_cycle_training_provider_courses_path( | ||
@provider.provider_code, | ||
@provider.recruitment_cycle_year, | ||
training_partner.provider_code | ||
), | ||
class: "govuk-!-font-weight-bold", | ||
data: { qa: "training_partner_name" } | ||
) %> | ||
<% end %> | ||
<span class="govuk-hint govuk-!-display-inline" data-qa="course_count"> | ||
<%= pluralize(@course_counts[training_partner.provider_code], "course") %> | ||
</span> | ||
</h3> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
|
||
<% unless @training_partners.empty? %> | ||
<aside class="govuk-grid-column-one-third"> | ||
<div class="app-status-box" data-qa="download-section"> | ||
<h2 class="govuk-heading-m"><%= t(".download") %></h2> | ||
<p class="govuk-body"><%= t(".export") %></p> | ||
<p class="govuk-body"> | ||
<%= govuk_link_to( | ||
t(".download_file"), | ||
download_training_providers_courses_publish_provider_recruitment_cycle_path( | ||
@provider.provider_code, | ||
@provider.recruitment_cycle_year, | ||
format: :csv | ||
) | ||
) %> | ||
</p> | ||
</div> | ||
</aside> | ||
<% end %> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.