Skip to content

Commit

Permalink
Changes to school placements page
Browse files Browse the repository at this point in the history
  • Loading branch information
elceebee committed May 30, 2024
1 parent fa7d556 commit b43ec39
Show file tree
Hide file tree
Showing 25 changed files with 583 additions and 317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def about_this_course_link = about_this_course_publish_provider_recruitment_cycl
def degree_link = degrees_start_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true)
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 = about_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true, anchor: 'how-school-placements-work')
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')

Expand Down
77 changes: 0 additions & 77 deletions app/controllers/publish/courses/course_information_controller.rb

This file was deleted.

93 changes: 93 additions & 0 deletions app/controllers/publish/courses/school_placements_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# frozen_string_literal: true

module Publish
module Courses
class SchoolPlacementsController < PublishController
include CopyCourseContent
include GotoPreview

before_action :authorise_with_pundit

def edit
@course_school_placements_form = CourseSchoolPlacementsForm.new(course_enrichment)
@copied_fields = copy_content_check(::Courses::Copy::SCHOOL_PLACEMENTS_FIELDS)

@copied_fields_values = copied_fields_values if @copied_fields.present?

@course_school_placements_form.valid? if show_errors_on_publish?
end

def update
@course_school_placements_form = CourseSchoolPlacementsForm.new(
course_enrichment,
params: school_placements_params
)

if @course_school_placements_form.valid?
@course_school_placements_form.save!
course_updated_message(I18n.t('publish.providers.school_placements.edit.how_school_placements_work')) unless goto_preview?

redirect_to redirect_path
else
render :edit
end
end

private

def course_to_authorise
@course_to_authorise ||= provider.courses.find_by!(course_code: params[:code])
end

def course
@course ||= CourseDecorator.new(course_to_authorise)
end

def authorise_with_pundit
authorize course_to_authorise
end

def school_placements_params
params.require(param_form_key)
.except(:goto_preview)
.permit(CourseSchoolPlacementsForm::FIELDS)
end

def course_enrichment
@course_enrichment ||= course.enrichments.find_or_initialize_draft
end

def param_form_key = :publish_course_school_placements_form

def course_information
@course_information ||= Configs::CourseInformation.new(@course)
end

def redirect_path
if goto_preview?
preview_publish_provider_recruitment_cycle_course_path(
provider.provider_code,
recruitment_cycle.year,
course.course_code
)
else
publish_provider_recruitment_cycle_course_path(
provider.provider_code,
recruitment_cycle.year,
course.course_code
)

end
end

def show_scitt_guidance?
course_information.show_placement_guidance?(:program_type)
end

def show_universities_guidance?
course_information.show_placement_guidance?(:provider_type)
end
helper_method :show_scitt_guidance?, :show_universities_guidance?
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Publish
class CourseInformationForm < BaseProviderForm
class CourseSchoolPlacementsForm < BaseProviderForm
alias course_enrichment model

FIELDS = %i[how_school_placements_work].freeze
Expand Down
2 changes: 1 addition & 1 deletion app/services/courses/copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Copy
['Interview process', 'interview_process']
].freeze

ABOUT_FIELDS = [
SCHOOL_PLACEMENTS_FIELDS = [
['How school placements work', 'how_school_placements_work']
].freeze

Expand Down
2 changes: 1 addition & 1 deletion app/views/publish/courses/_description_content.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
course.placements_heading,
value_provided?(course.how_school_placements_work),
%w[how_school_placements_work],
action_path: course.is_withdrawn? ? nil : "#{about_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code)}#how-school-placements-work",
action_path: course.is_withdrawn? ? nil : school_placements_publish_provider_recruitment_cycle_course_path(@provider.provider_code, course.recruitment_cycle_year, course.course_code),
action_visually_hidden_text: "details about how school placements work"
) %>
<% end %>
Expand Down
92 changes: 0 additions & 92 deletions app/views/publish/courses/course_information/edit.html.erb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p class="govuk-body"><%= t("publish.providers.interview_process.edit.include_information_about") %></p>

<%= t("publish.providers.interview_process.edit.include_information_about_html") %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<%= govuk_notification_banner(
title_text: t("notification_banner.warning"),
classes: "govuk-notification-banner--warning",
html_attributes: {
data: { qa: "copy-course-warning" },
role: "alert"
}
) do |notification_banner| %>
<% notification_banner.with_heading(text: t("publish.providers.school_placements.edit.changes_not_saved")) %>
<p class="govuk-body">
<%= t(
"publish.providers.school_placements.edit.copied_fields_from",
name_and_code: "#{@source_course.name} (#{@source_course.course_code})"
) %>
</p>
<ul class="govuk-list">
<% @copied_fields.each do |name, field| %>
<li>
<%= govuk_link_to(
name,
"#publish-course-school-placements-form-#{field.gsub('_', '-')}-field",
class: "govuk-notification-banner__link"
) %>
</li>
<% end %>
</ul>
<p class="govuk-body">
<%= t("publish.providers.school_placements.edit.please_check_changes") %>
</p>
<% end %>
27 changes: 27 additions & 0 deletions app/views/publish/courses/school_placements/_guidance.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<%= t("publish.providers.school_placements.edit.guidance_text_html") %>

<% if show_universities_guidance? %>
<details class="govuk-details">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
<%= t("publish.providers.school_placements.edit.summary_text") %>
</span>
</summary>
<div class="govuk-!-margin-top-4" />
<%= render Find::Utility::AdviceComponent::View.new(title: t("publish.providers.school_placements.edit.where_you_will_train")) do %>
<%= t("publish.providers.school_placements.edit.university_guidance_html") %>
<% end %>
</details>
<% elsif show_scitt_guidance? %>
<details class="govuk-details">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
<%= t("publish.providers.school_placements.edit.summary_text") %>
</span>
</summary>
<div class="govuk-!-margin-top-4" />
<%= render Find::Utility::AdviceComponent::View.new(title: t("publish.providers.school_placements.edit.where_you_will_train")) do %>
<%= t("publish.providers.school_placements.edit.scitt_guidance_html") %>
<% end %>
</details>
<% end %>
Loading

0 comments on commit b43ec39

Please sign in to comment.