-
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
Showing
25 changed files
with
583 additions
and
317 deletions.
There are no files selected for viewing
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
77 changes: 0 additions & 77 deletions
77
app/controllers/publish/courses/course_information_controller.rb
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
app/controllers/publish/courses/school_placements_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,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 |
2 changes: 1 addition & 1 deletion
2
app/forms/publish/course_information_form.rb → .../publish/course_school_placements_form.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
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
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
92 changes: 0 additions & 92 deletions
92
app/views/publish/courses/course_information/edit.html.erb
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
app/views/publish/courses/interview_process/_guidance.html.erb
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,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") %> |
30 changes: 30 additions & 0 deletions
30
app/views/publish/courses/school_placements/_copy_school_placements_content_warning.html.erb
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 @@ | ||
<%= 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
27
app/views/publish/courses/school_placements/_guidance.html.erb
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,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 %> |
Oops, something went wrong.