From 347fce874492a8cb967521fa7b5679f0128af0cd Mon Sep 17 00:00:00 2001 From: CatalinVoineag <11318084+CatalinVoineag@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:41:35 +0100 Subject: [PATCH] Training with disabilities view on courses The course show page on find and the preview page on publish contains too much information that might be off-putting for the user. This commit tries to fix this by putting this section into its own view accessible from the course page --- .../missing_information_component.rb | 2 +- .../training_with_disabilities_controller.rb | 18 ++++++++++ .../training_with_disabilities_controller.rb | 19 +++++++++++ app/helpers/find/goto_preview_helper.rb | 4 +-- app/helpers/preview_helper.rb | 3 +- .../courses/_train_with_disabilities.html.erb | 16 ++++----- app/views/find/courses/show.html.erb | 14 +++++++- .../training_with_disabilities/show.html.erb | 29 ++++++++++++++++ app/views/publish/courses/preview.html.erb | 15 +++++++- .../training_with_disabilities/show.html.erb | 34 +++++++++++++++++++ app/views/publish/providers/about.html.erb | 1 + config/locales/en.yml | 9 +++++ config/locales/find.yml | 7 ++++ config/routes/find.rb | 1 + config/routes/publish.rb | 2 ++ .../missing_information_component_spec.rb | 2 +- .../find/search/viewing_a_course_spec.rb | 25 ++++++++++++-- .../publish/viewing_a_course_preview_spec.rb | 27 ++++++++++++--- 18 files changed, 206 insertions(+), 22 deletions(-) create mode 100644 app/controllers/find/courses/training_with_disabilities_controller.rb create mode 100644 app/controllers/publish/courses/training_with_disabilities_controller.rb create mode 100644 app/views/find/courses/training_with_disabilities/show.html.erb create mode 100644 app/views/publish/courses/training_with_disabilities/show.html.erb diff --git a/app/components/course_preview/missing_information_component.rb b/app/components/course_preview/missing_information_component.rb index 5dcd692b6c..777073ff1f 100644 --- a/app/components/course_preview/missing_information_component.rb +++ b/app/components/course_preview/missing_information_component.rb @@ -36,7 +36,7 @@ def degree_link = degrees_start_publish_provider_recruitment_cycle_course_path(p def fee_uk_eu_link = fees_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true) 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_disability_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_training_with_disabilities: true, anchor: 'train-with-disability') 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 diff --git a/app/controllers/find/courses/training_with_disabilities_controller.rb b/app/controllers/find/courses/training_with_disabilities_controller.rb new file mode 100644 index 0000000000..5d8911c1d8 --- /dev/null +++ b/app/controllers/find/courses/training_with_disabilities_controller.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Find + module Courses + class TrainingWithDisabilitiesController < Find::ApplicationController + before_action -> { render_not_found if provider.nil? } + before_action -> { render_not_found if provider.train_with_disability.blank? } + + def show + @course = provider.courses.includes( + :enrichments, + subjects: [:financial_incentive], + site_statuses: [:site] + ).find_by!(course_code: params[:course_code]&.upcase).decorate + end + end + end +end diff --git a/app/controllers/publish/courses/training_with_disabilities_controller.rb b/app/controllers/publish/courses/training_with_disabilities_controller.rb new file mode 100644 index 0000000000..d754f78f6f --- /dev/null +++ b/app/controllers/publish/courses/training_with_disabilities_controller.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Publish + module Courses + class TrainingWithDisabilitiesController < PublishController + include CourseBasicDetailConcern + before_action :build_course, only: %i[show] + + def show; end + + private + + def build_course + super + authorize @course + end + end + end +end diff --git a/app/helpers/find/goto_preview_helper.rb b/app/helpers/find/goto_preview_helper.rb index fe136a07b0..3053349170 100644 --- a/app/helpers/find/goto_preview_helper.rb +++ b/app/helpers/find/goto_preview_helper.rb @@ -14,8 +14,8 @@ def goto_provider_value(param_form_key:, params:) params[:goto_provider] || params.dig(param_form_key, :goto_provider) end - def goto_provider?(param_form_key:, params:) - goto_provider_value(param_form_key:, params:) == 'true' + def goto_training_with_disabilities_value(param_form_key:, params:) + params[:goto_training_with_disabilities] || params.dig(param_form_key, :goto_training_with_disabilities) end def back_link_path(param_form_key:, params:, provider_code:, recruitment_cycle_year:, course_code:) diff --git a/app/helpers/preview_helper.rb b/app/helpers/preview_helper.rb index e38c033fc1..1cc9f5baac 100644 --- a/app/helpers/preview_helper.rb +++ b/app/helpers/preview_helper.rb @@ -4,6 +4,7 @@ module PreviewHelper def preview?(params) params[:action] == 'preview' || params[:action].nil? || - (params[:controller] == 'publish/courses/providers' && params[:action] == 'show') + (params[:controller] == 'publish/courses/providers' && params[:action] == 'show') || + (params[:controller] == 'publish/courses/training_with_disabilities' && params[:action] == 'show') end end diff --git a/app/views/find/courses/_train_with_disabilities.html.erb b/app/views/find/courses/_train_with_disabilities.html.erb index b120ab60f4..1687e64ee3 100644 --- a/app/views/find/courses/_train_with_disabilities.html.erb +++ b/app/views/find/courses/_train_with_disabilities.html.erb @@ -1,10 +1,8 @@ -
-

Training with disabilities and other needs

-
- <% if course.provider.train_with_disability.present? %> - <%= markdown(course.provider.train_with_disability) %> - <% else %> - <%= render CoursePreview::MissingInformationComponent.new(course:, information_type: :train_with_disability, is_preview: preview?(params)) %> - <% end %> -
+

Training with disabilities and other needs

+
+ <% if course.provider.train_with_disability.present? %> + <%= markdown(course.provider.train_with_disability) %> + <% else %> + <%= render CoursePreview::MissingInformationComponent.new(course:, information_type: :train_with_disability, is_preview: preview?(params)) %> + <% end %>
diff --git a/app/views/find/courses/show.html.erb b/app/views/find/courses/show.html.erb index 76ea45d8a6..8cc136a8a3 100644 --- a/app/views/find/courses/show.html.erb +++ b/app/views/find/courses/show.html.erb @@ -54,7 +54,19 @@ <%= render Find::Courses::InternationalStudentsComponent::View.new(course: @course) %> <% if @provider.train_with_disability.present? %> - <%= render partial: "find/courses/train_with_disabilities", locals: { course: @course } %> +

+ <%= t(".training_with_disabilities") %> +

+ +

+ <%= govuk_link_to( + t(".training_with_disabilities_link", provider_name: @course.provider_name), + find_training_with_disabilities_path( + @course.provider_code, + @course.course_code + ) + ) %> +

<% end %> <%= render partial: "find/courses/advice", locals: { course: @course } %> diff --git a/app/views/find/courses/training_with_disabilities/show.html.erb b/app/views/find/courses/training_with_disabilities/show.html.erb new file mode 100644 index 0000000000..60def88c2d --- /dev/null +++ b/app/views/find/courses/training_with_disabilities/show.html.erb @@ -0,0 +1,29 @@ +<%= content_for :page_title do %> + <%= t(".heading") %> +<% end %> +<% content_for :before_content do %> + <%= govuk_back_link( + href: search_ui_course_page_url( + provider_code: @course.provider_code, + course_code: @course.course_code + ), + text: t( + ".back", + course_name: @course.name, + course_code: @course.course_code + ) + ) %> +<% end %> + +
+
+ <%= render partial: "find/courses/train_with_disabilities", locals: { course: @course } %> + +

+ <%= govuk_link_to( + t(".contact", provider_name: @course.provider_name), + find_provider_path(@course.provider_code, @course.course_code) + ) %> +

+
+
diff --git a/app/views/publish/courses/preview.html.erb b/app/views/publish/courses/preview.html.erb index 089f5477c1..7c6ff4356b 100644 --- a/app/views/publish/courses/preview.html.erb +++ b/app/views/publish/courses/preview.html.erb @@ -43,7 +43,20 @@ <%= render Find::Courses::InternationalStudentsComponent::View.new(course:) %> - <%= render partial: "find/courses/train_with_disabilities", locals: { course: } %> +

+ <%= t(".training_with_disabilities") %> +

+ +

+ <%= govuk_link_to( + t(".training_with_disabilities_link", provider_name: course.provider_name), + training_with_disabilities_publish_provider_recruitment_cycle_course_path( + course.provider_code, + course.recruitment_cycle_year, + course.course_code + ) + ) %> +

<%= render partial: "find/courses/advice", locals: { course: } %> diff --git a/app/views/publish/courses/training_with_disabilities/show.html.erb b/app/views/publish/courses/training_with_disabilities/show.html.erb new file mode 100644 index 0000000000..a2b7107a1c --- /dev/null +++ b/app/views/publish/courses/training_with_disabilities/show.html.erb @@ -0,0 +1,34 @@ +<%= content_for :page_title do %> + <%= t(".heading") %> +<% end %> +<% content_for :before_content do %> + <%= govuk_back_link( + href: preview_publish_provider_recruitment_cycle_course_path( + @course.provider_code, + @course.recruitment_cycle_year, + @course.course_code + ), + text: t( + ".back", + course_name: @course.name, + course_code: @course.course_code + ) + ) %> +<% end %> + +
+
+ <%= render partial: "find/courses/train_with_disabilities", locals: { course: } %> + +

+ <%= govuk_link_to( + t(".contact", provider_name: @course.provider_name), + provider_publish_provider_recruitment_cycle_course_path( + @course.provider_code, + @course.recruitment_cycle_year, + @course.course_code + ) + ) %> +

+
+
diff --git a/app/views/publish/providers/about.html.erb b/app/views/publish/providers/about.html.erb index e71285c913..a50533551e 100644 --- a/app/views/publish/providers/about.html.erb +++ b/app/views/publish/providers/about.html.erb @@ -75,6 +75,7 @@ rows: 15) %> <%= f.hidden_field(:goto_preview, value: goto_preview_value(param_form_key: f.object_name.to_sym, params:)) %> <%= f.hidden_field(:goto_provider, value: goto_provider_value(param_form_key: f.object_name.to_sym, params:)) %> + <%= f.hidden_field(:goto_training_with_disabilities, value: goto_training_with_disabilities_value(param_form_key: f.object_name.to_sym, params:)) %> <%= f.hidden_field(:course_code, value: params[:course_code] || params.dig(f.object_name.to_sym, :course_code)) %> <%= f.govuk_submit "Save and publish" %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 686f9aa61c..08668a7324 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -398,6 +398,15 @@ en: add: "Add user" update: "Update user" publish: + courses: + training_with_disabilities: + show: + heading: Training with disabilities and other needs + back: Back to %{course_name} (%{course_code}) + contact: Contact %{provider_name} + preview: + training_with_disabilities: Training with disabilities and other needs + training_with_disabilities_link: Find out about training with disabilities and other needs at %{provider_name} providers: courses: accredited_provider: diff --git a/config/locales/find.yml b/config/locales/find.yml index 12a30f551f..4e9a8b4caf 100644 --- a/config/locales/find.yml +++ b/config/locales/find.yml @@ -104,6 +104,11 @@ en: telephone: Telephone school_website: School Website address: Address + training_with_disabilities: + show: + heading: Training with disabilities and other needs + back: Back to %{course_name} (%{course_code}) + contact: Contact %{provider_name} about_schools_component: view: view_list_of_school_placements: View list of school placements @@ -118,6 +123,8 @@ en: not_consider_a_level_equivalency: We will not consider candidates who need to take A level equivalency tests. show: back_to_search: Back to search results + training_with_disabilities: Training with disabilities and other needs + training_with_disabilities_link: Find out about training with disabilities and other needs at %{provider_name} scholarships: physics: body: Institute of Physics diff --git a/config/routes/find.rb b/config/routes/find.rb index 7d81395f8f..10e77558b4 100644 --- a/config/routes/find.rb +++ b/config/routes/find.rb @@ -22,6 +22,7 @@ scope module: :courses, path: '/courses' do get '/:provider_code/:course_code/provider', to: 'providers#show', as: :provider get '/:provider_code/:course_code/accredited-by', to: 'accrediting_providers#show', as: :accrediting_provider + get '/:provider_code/:course_code/training-with-disabilities', to: 'training_with_disabilities#show', as: :training_with_disabilities end get '/feature-flags', to: 'feature_flags#index' diff --git a/config/routes/publish.rb b/config/routes/publish.rb index 9bfa99e245..2904e5f4c9 100644 --- a/config/routes/publish.rb +++ b/config/routes/publish.rb @@ -254,6 +254,8 @@ get '/study-sites', on: :member, to: 'courses/study_sites#edit' put '/study-sites', on: :member, to: 'courses/study_sites#update' + get '/training-with-disabilities', on: :member, to: 'courses/training_with_disabilities#show' + get '/applications-open', on: :member, to: 'courses/applications_open#edit' put '/applications-open', on: :member, to: 'courses/applications_open#update' diff --git a/spec/components/course_preview/missing_information_component_spec.rb b/spec/components/course_preview/missing_information_component_spec.rb index 4ada7a3a53..d3913ee87d 100644 --- a/spec/components/course_preview/missing_information_component_spec.rb +++ b/spec/components/course_preview/missing_information_component_spec.rb @@ -27,7 +27,7 @@ module CoursePreview how_school_placements_work: school_placements_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true), train_with_disability: - "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true)}#train-with-disability", + "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_training_with_disabilities: true)}#train-with-disability", train_with_us: "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_provider: true)}#train-with-us", about_accrediting_provider: diff --git a/spec/features/find/search/viewing_a_course_spec.rb b/spec/features/find/search/viewing_a_course_spec.rb index da4b0692f2..565c7b9edf 100644 --- a/spec/features/find/search/viewing_a_course_spec.rb +++ b/spec/features/find/search/viewing_a_course_spec.rb @@ -4,6 +4,7 @@ feature 'Viewing a findable course' do include PublishHelper + include Rails.application.routes.url_helpers before do Timecop.travel(Find::CycleTimetable.mid_cycle) @@ -89,6 +90,15 @@ then_i_should_be_on_the_course_page end + scenario 'user views the training with disabilities page' do + given_there_is_a_findable_course + when_i_visit_the_course_page + when_i_click("Find out about training with disabilities and other needs at #{@course.provider_name}") + then_i_should_be_on_the_training_with_disabilities_page + when_i_click("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_on_the_course_page + end + private def given_there_is_a_findable_course @@ -259,8 +269,8 @@ def then_i_should_see_the_course_information 'Certificate must be print in blue ink' ) - expect(find_course_show_page.train_with_disability).to have_content( - provider.train_with_disability + expect(find_course_show_page).to have_content( + 'Training with disabilities and other needs' ) expect(find_course_show_page.school_placements).to have_no_content('Suspended site with vacancies') @@ -379,4 +389,15 @@ def then_i_should_be_on_the_course_page ).to_s ) end + + def then_i_should_be_on_the_training_with_disabilities_page + expect(find_course_show_page.train_with_disability).to have_content( + provider.train_with_disability + ) + + expect(page).to have_link( + "Contact #{course.provider_name}", + href: find_provider_path(@course.provider_code, @course.course_code) + ) + end end diff --git a/spec/features/publish/viewing_a_course_preview_spec.rb b/spec/features/publish/viewing_a_course_preview_spec.rb index 5f38d94c34..6cc8464c2a 100644 --- a/spec/features/publish/viewing_a_course_preview_spec.rb +++ b/spec/features/publish/viewing_a_course_preview_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' feature 'Course show', { can_edit_current_and_next_cycles: false } do + include Rails.application.routes.url_helpers context 'bursaries and scholarships is announced' do before do FeatureFlag.activate(:bursaries_and_scholarships_announced) @@ -37,14 +38,17 @@ scenario 'blank training with disabilities and other needs' do given_i_am_authenticated(user: user_with_no_course_enrichments) when_i_visit_the_publish_course_preview_page + and_i_click_link_or_button("Find out about training with disabilities and other needs at #{@course.provider_name}") and_i_click_link_or_button('Enter details about training with disabilities and other needs') then_i_should_be_on_about_your_organisation_page and_i_click_link_or_button('Back') - then_i_should_be_back_on_the_preview_page + then_i_should_be_on_the_training_with_disabilities_page and_i_click_link_or_button('Enter details about training with disabilities and other needs') and_i_submit_a_valid_about_your_organisation - then_i_should_be_back_on_the_preview_page + then_i_should_be_on_the_training_with_disabilities_page then_i_should_see_the_updated_content('test training with disabilities') + and_i_click_link_or_button("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_back_on_the_preview_page end scenario 'blank school placements section' do @@ -239,8 +243,8 @@ def then_i_see_the_course_preview_details 'Financial support from the training provider' ) - expect(publish_course_preview_page.train_with_disability).to have_content( - provider.train_with_disability + expect(publish_course_preview_page).to have_content( + 'Training with disabilities and other needs' ) expect(publish_course_preview_page).to have_content '2:1 or above, or equivalent' @@ -504,4 +508,19 @@ def then_i_should_be_on_the_accrediting_provider_page decorated_course.about_accrediting_provider ) end + + def then_i_should_be_on_the_training_with_disabilities_page + expect(publish_course_preview_page.train_with_disability).to have_content( + provider.train_with_disability + ) + + expect(page).to have_link( + "Contact #{course.provider_name}", + href: provider_publish_provider_recruitment_cycle_course_path( + @course.provider_code, + @course.recruitment_cycle_year, + @course.course_code + ) + ) + end end