Skip to content

Commit

Permalink
Add provider & accrediting_provider views course
Browse files Browse the repository at this point in the history
The course show page for find and publish(preview page) has too much
content. This commit tries to reduce this content by putting the
provider of the course and the accrediting provider of the course into
their own views.

For this to happen we also needed to change the logic of the
redirects/back links when adding a provider through the course show
page. You can do this when you have a draft course but without a
provider.
  • Loading branch information
CatalinVoineag committed Jul 8, 2024
1 parent 92943e4 commit f9f4959
Show file tree
Hide file tree
Showing 37 changed files with 638 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def fee_uk_eu_link = fees_publish_provider_recruitment_cycle_course_path(provide
def gcse_link = gcses_pending_or_equivalency_tests_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true)
def how_school_placements_work_link = school_placements_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true)
def train_with_disability_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true, anchor: 'train-with-disability')
def train_with_us_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true, anchor: 'train-with-us')
def train_with_us_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_provider: true, anchor: 'train-with-us')

def about_accrediting_provider_link
if accrediting_provider_present?(course)
Expand Down
14 changes: 6 additions & 8 deletions app/components/find/courses/about_schools_component/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ class View < ViewComponent::Base
include PublishHelper
include PreviewHelper

attr_reader :course
attr_reader :course, :preview

delegate :published_how_school_placements_work,
:program_type,
:study_sites,
:site_statuses, to: :course

def initialize(course)
def initialize(course, preview: false)
super
@course = course
@preview = preview
end

def render?
Expand All @@ -39,17 +40,14 @@ def show_scitt_guidance?
end

def placements_url
if course.has_unpublished_changes? || (course.is_published? && course.is_running?)
URI.join(
Settings.search_ui.base_url,
find_placements_path(course.provider_code, course.course_code)
).to_s
else
if preview
placements_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
)
else
find_placements_path(course.provider_code, course.course_code)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div id="contact_section" class="govuk-!-margin-bottom-8">
<h2 class="govuk-heading-l" id="section-contact">Contact this training provider</h2>
<h1 class="govuk-heading-xl" id="section-contact">
<%= t(".heading", provider_name: course.provider_name) %>
</h1>

<div class="course-basicinfo">
<dl class="app-description-list">
Expand Down
4 changes: 0 additions & 4 deletions app/components/find/courses/contents_component/view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
<% if how_school_placements_work.present? || program_type == "higher_education_programme" || program_type == "scitt_programme" || preview? %>
<li><%= govuk_link_to "Training locations", "#training-locations" %></li>
<% end %>
<% if provider.train_with_us.present? || about_accrediting_provider.present? || preview? %>
<li><%= govuk_link_to "About the training provider", "#section-about-provider" %></li>
<% end %>
<% if salaried? %>
<li><%= govuk_link_to "Salary", "#section-salary" %></li>
<% end %>
Expand All @@ -21,7 +18,6 @@
<% if provider.train_with_disability.present? || preview? %>
<li><%= govuk_link_to "Training with disabilities and other needs", "#section-train-with-disabilities" %></li>
<% end %>
<li><%= govuk_link_to "Contact this training provider", "#section-contact" %></li>
<li><%= govuk_link_to "Support and advice", "#section-advice" %></li>
<% if course.application_status_open? %> <li><%= govuk_link_to "Apply", "#section-apply" %></li> <% end %>
</ul>
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
<dd data-qa="course__qualifications">
<% case find_outcome %>
<% when "QTS" %>
<%= govuk_details(summary_text: "QTS") do %>
<p class="govuk-body">
Qualified teacher status (QTS) allows you to teach in state schools in England and may also allow you to teach in other parts of the UK.
</p>
<p class="govuk-body">
It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<% end %>
<% case find_outcome %>
<% when "QTS" %>
<%= govuk_details(summary_text: "QTS") do %>
<p class="govuk-body">
Qualified teacher status (QTS) allows you to teach in state schools in England and may also allow you to teach in other parts of the UK.
</p>
<p class="govuk-body">
It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<% end %>
<% when "QTS with PGCE" %>
<%= govuk_details(summary_text: "QTS with PGCE") do %>
<p class="govuk-body">
You need qualified teacher status (QTS) to teach in state schools in England. QTS may also allow you to teach in other parts of the UK.
</p>
<p class="govuk-body">
This course also offers a postgraduate certificate in education (PGCE). PGCE courses can include credits that count towards a master’s degree.
</p>
<% end %>
<% when "PGDE with QTS" %>
<%= govuk_details(summary_text: "PGDE with QTS") do %>
<p class="govuk-body">
A postgraduate diploma in education (PGDE) with qualified teacher status (QTS) will allow you to teach in state schools in England and may allow you to teach in other parts of the UK.
</p>
<p class="govuk-body">
It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<p class="govuk-body">
Many PGDE courses include credits towards a Master’s degree.
</p>
<% end %>
<% when "PGCE" %>
<%= govuk_details(summary_text: "PGCE") do %>
<p class="govuk-body">
A postgraduate certificate in education (PGCE) is an academic qualification in education.
</p>
<p class="govuk-body">
It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<p class="govuk-body">
This course does not lead to qualified teacher status (QTS).
</p>
<% end %>
<% when "PGDE" %>
<%= govuk_details(summary_text: "PGDE") do %>
<p class="govuk-body">
A postgraduate diploma in education (PGDE) is equivalent to a postgraduate certificate in education (PGCE).
</p>
<p class="govuk-body">
It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<p class="govuk-body">
This course does not lead to qualified teacher status (QTS).
</p>
<% end %>
<%= govuk_details(summary_text: "QTS with PGCE") do %>
<p class="govuk-body">
You need qualified teacher status (QTS) to teach in state schools in England. QTS may also allow you to teach in other parts of the UK.
</p>
<p class="govuk-body">
This course also offers a postgraduate certificate in education (PGCE). PGCE courses can include credits that count towards a master’s degree.
</p>
<% end %>
<% when "PGDE with QTS" %>
<%= govuk_details(summary_text: "PGDE with QTS") do %>
<p class="govuk-body">
A postgraduate diploma in education (PGDE) with qualified teacher status (QTS) will allow you to teach in state schools in England and may allow you to teach in other parts of the UK.
</p>
<p class="govuk-body">
It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<p class="govuk-body">
Many PGDE courses include credits towards a Master’s degree.
</p>
<% end %>
<% when "PGCE" %>
<%= govuk_details(summary_text: "PGCE") do %>
<p class="govuk-body">
A postgraduate certificate in education (PGCE) is an academic qualification in education.
</p>
<p class="govuk-body">
It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<p class="govuk-body">
This course does not lead to qualified teacher status (QTS).
</p>
<% end %>
<% when "PGDE" %>
<%= govuk_details(summary_text: "PGDE") do %>
<p class="govuk-body">
A postgraduate diploma in education (PGDE) is equivalent to a postgraduate certificate in education (PGCE).
</p>
<p class="govuk-body">
It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in.
</p>
<p class="govuk-body">
This course does not lead to qualified teacher status (QTS).
</p>
<% end %>
</dd>
<% end %>
86 changes: 54 additions & 32 deletions app/components/find/courses/summary_component/view.html.erb
Original file line number Diff line number Diff line change
@@ -1,49 +1,71 @@
<dl class="app-description-list govuk-!-margin-bottom-8">
<% if accrediting_provider.present? && (accrediting_provider.provider_code != provider.provider_code) %>
<dt class="app-description-list__label">Accredited provider</dt>
<dd data-qa="course__accredited_provider"><%= accrediting_provider.provider_name %></dd>
<% end %>
<dt class="app-description-list__label">Fee or salary</dt>
<dd data-qa="course__funding_option"><%= course.funding %>
<%= govuk_summary_list(actions: false, classes: ['govuk-summary-list--no-border']) do |summary_list| %>i
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".fee_or_salary")) %>
<% row.with_value do %>
<%= course.funding %>
<br>
<p class="govuk-hint"><%= course.funding_option %>
</dd>
</dt>

<dt class="app-description-list__label">Visa sponsorship</dt>
<dd data-qa="course__visa_sponsorship"><%= visa_sponsorship_row %></dd>
<p class="govuk-hint"><%= course.funding_option %></p>
<% end %>
<% end %>

<% unless no_fee? %>
<dt class="app-description-list__label">Course fee</dt>
<dd data-qa="course__fee"><%= course_fee_value %></dd>
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".course_fee"))%>
<% row.with_value(text: course_fee_value) %>
<% end %>
<% end %>

<% if length.present? %>
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".course_length")) %>
<% row.with_value(text: course_length_with_study_mode_row) %>
<% end %>
<% end %>

<dt class="app-description-list__label">Qualification</dt>
<%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %>
<% if age_range_in_years.present? %>
<dt class="app-description-list__label">Age range</dt>
<dd data-qa="course__age_range"><%= age_range_in_years_row %></dd>
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".age_range")) %>
<% row.with_value(text: age_range_in_years_row) %>
<% end %>
<% end %>

<% if length.present? %>
<dt class="app-description-list__label">Course length</dt>
<dd data-qa="course__length"><%= course_length_with_study_mode_row %></dd>
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".qualification")) %>
<% row.with_value do %>
<%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %>
<% end %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".provider")) %>
<% row.with_value do %>
<%= govuk_link_to course.provider_name, x_provider_url %>
<% end %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".accredited_by")) %>
<% row.with_value do %>
<%= govuk_link_to course.accrediting_provider.provider_name, x_accrediting_provider_url %>
<% end %>
<% end %>

<% if show_apply_from_row? %>
<dt class="app-description-list__label">Date you can apply from</dt>
<dd data-qa="course__applications_open"><%= l(applications_open_from&.to_date) %></dd>
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".date_can_apply")) %>
<% row.with_value(text: l(applications_open_from&.to_date)) %>
<% end %>
<% end %>

<% if start_date.present? %>
<dt class="app-description-list__label">Date course starts</dt>
<dd data-qa="course__start_date"><%= l(start_date&.to_date, format: :short) %></dd>
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".date_course_start")) %>
<% row.with_value(text: l(start_date&.to_date, format: :short)) %>
<% end %>
<% end %>

<% if provider.decorate.website.present? %>
<dt class="app-description-list__label">Website</dt>
<dd data-qa="course__provider_website">
<%= govuk_link_to provider.decorate.website, provider.decorate.website %>
</dd>
<% summary_list.with_row do |row| %>
<% row.with_key(text: t(".visa_sponsorship")) %>
<% row.with_value(text: visa_sponsorship_row) %>
<% end %>
</dl>
<% end %>
25 changes: 25 additions & 0 deletions app/components/find/courses/summary_component/view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module SummaryComponent
class View < ViewComponent::Base
include ApplicationHelper
include ::ViewHelper
include PreviewHelper

attr_reader :course

Expand Down Expand Up @@ -74,6 +75,30 @@ def no_fee?
def show_apply_from_row?
course.applications_open_from&.future?
end

def x_provider_url
if preview?(params)
provider_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
)
else
find_provider_path(course.provider_code, course.course_code)
end
end

def x_accrediting_provider_url
if preview?(params)
accredited_by_publish_provider_recruitment_cycle_course_path(
course.provider_code,
course.recruitment_cycle_year,
course.course_code
)
else
find_accrediting_provider_path(course.provider_code, course.course_code)
end
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/concerns/goto_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ def param_form_key
end

def goto_preview? = params.dig(param_form_key, :goto_preview) == 'true'
def goto_provider? = params.dig(param_form_key, :goto_provider) == 'true'
end
17 changes: 17 additions & 0 deletions app/controllers/find/courses/accrediting_providers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Find
module Courses
class AccreditingProvidersController < Find::ApplicationController
def show
@course = provider.courses.includes(
:enrichments,
subjects: [:financial_incentive],
site_statuses: [:site]
).find_by!(course_code: params[:course_code]&.upcase).decorate

render_not_found if @course.accrediting_provider.blank? || !@course.is_published?
end
end
end
end
19 changes: 19 additions & 0 deletions app/controllers/find/courses/providers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Find
module Courses
class ProvidersController < Find::ApplicationController
before_action -> { render_not_found if provider.nil? }

def show
@course = provider.courses.includes(
:enrichments,
subjects: [:financial_incentive],
site_statuses: [:site]
).find_by!(course_code: params[:course_code]&.upcase).decorate

render_not_found unless @course.is_published?
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
module Publish
module Courses
class AccreditedProviderController < PublishController
include CourseBasicDetailConcern
before_action :build_course, only: %i[edit update]
before_action :build_course_params, only: :continue

include CourseBasicDetailConcern
def show
@course = build_course&.decorate
render_not_found if @course.accrediting_provider.blank?
end

def edit
build_provider
Expand Down
Loading

0 comments on commit f9f4959

Please sign in to comment.