diff --git a/app/controllers/npq_separation/admin/applications/notes_controller.rb b/app/controllers/npq_separation/admin/applications/notes_controller.rb new file mode 100644 index 0000000000..1108d0c3f2 --- /dev/null +++ b/app/controllers/npq_separation/admin/applications/notes_controller.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module NpqSeparation + module Admin + module Applications + class NotesController < NpqSeparation::AdminController + before_action :set_application + + def edit; end + + def update + if @application.update(notes_params) + flash[:success] = "Notes updated." + redirect_to npq_separation_admin_application_review_path(@application) + else + render :edit + end + end + + private + + def notes_params + params.require(:application).permit(:notes) + end + + def set_application + @application = Application.find(params[:id]) + end + end + end + end +end diff --git a/app/controllers/npq_separation/admin/applications/reviews_controller.rb b/app/controllers/npq_separation/admin/applications/reviews_controller.rb index f10789625a..3710a6f985 100644 --- a/app/controllers/npq_separation/admin/applications/reviews_controller.rb +++ b/app/controllers/npq_separation/admin/applications/reviews_controller.rb @@ -15,6 +15,10 @@ def index @pagy, @applications = pagy(applications, limit: 9) end + def show + @application = Application.find(params[:id]) + end + private def employment_types diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 76560be68b..c8c29e56c6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -66,4 +66,14 @@ def show_otp_code_in_ui(current_env, admin) tag.p("OTP code: #{admin.otp_hash}") end + + def lead_provider_approval_status_badge(lead_provider_approval_status) + colour = { + pending: "blue", + accepted: "green", + rejected: "red", + }.fetch(lead_provider_approval_status.to_sym, "grey") + + govuk_tag(text: lead_provider_approval_status.humanize, colour:) + end end diff --git a/app/views/npq_separation/admin/applications/notes/edit.html.erb b/app/views/npq_separation/admin/applications/notes/edit.html.erb new file mode 100644 index 0000000000..c6c06cf2e3 --- /dev/null +++ b/app/views/npq_separation/admin/applications/notes/edit.html.erb @@ -0,0 +1,17 @@ +
+ Applicant ID: + <%= @application.user.ecf_id %> +
+ ++ Email: + <%= @application.user.email %> +
+ ++ Date of birth: + <%= @application.user.date_of_birth.to_fs(:govuk_short) %> + | + National Insurance: + <%= @application.user.national_insurance_number.presence || 'Not provided' %> +
+ ++ TRN: + <%= @application.user.trn %> + <%= boolean_red_green_tag(@application.user.trn_verified?, @application.user.trn_verified? ? "Validated" : "Not validated") %> +
+ ++ Get an Identity ID: + <%= @application.user.uid.presence || 'Not set' %> +
+ +<%= + govuk_summary_list(card: { title: "Course details" }) do |sl| + sl.with_row do |row| + row.with_key(text: "NPQ course") + row.with_value(text: "#{@application.course.name} (#{@application.course.short_code})") + end + sl.with_row do |row| + row.with_key(text: "Provider") + row.with_value(text: @application.lead_provider.name) + end + sl.with_row do |row| + row.with_key(text: "Provider approval status") + row.with_value(text: lead_provider_approval_status_badge(@application.lead_provider_approval_status)) + end + end +%> + +<%= + govuk_summary_list(card: { title: "Funding details" }) do |sl| + sl.with_row do |row| + row.with_key(text: "Eligible for funding") + row.with_value(text: boolean_red_green_tag(@application.eligible_for_funding)) + row.with_action(text: "Change", href: new_npq_separation_admin_applications_change_funding_eligibility_path(@application)) + end + sl.with_row do |row| + row.with_key(text: "Funded place") + row.with_value(text: boolean_red_green_nil_tag(@application.funded_place)) + end + sl.with_row do |row| + row.with_key(text: "Notes") + row.with_value(text: @application.notes) + row.with_action(text: "Change", href: edit_npq_separation_admin_applications_notes_path(@application)) + end + end +%> + +<%= + govuk_summary_list(card: { title: "Work details" }) do |sl| + sl.with_row do |row| + row.with_key(text: "Works in England") + row.with_value(text: boolean_red_green_tag(@application.teacher_catchment == "england")) + end + sl.with_row do |row| + row.with_key(text: "Work setting") + row.with_value(text: @application.work_setting.try(:humanize)) + end + sl.with_row do |row| + row.with_key(text: "Employment type") + row.with_value(text: @application.employment_type.try(:humanize)) + end + sl.with_row do |row| + row.with_key(text: "Employer name") + row.with_value(text: @application.employer_name_to_display) + end + sl.with_row do |row| + row.with_key(text: "Role") + row.with_value(text: @application.employment_role) + end + end +%> + +<%= + govuk_summary_list(card: { title: "Schedule" }) do |sl| + sl.with_row do |row| + row.with_key(text: "Cohort") + row.with_value(text: @application.cohort.start_year) + end + sl.with_row do |row| + row.with_key(text: "Schedule identifier") + row.with_value(text: @application.schedule.try(:identifier)) + end + end +%> + +<%= + govuk_summary_list(card: { title: "Registration details" }) do |sl| + sl.with_row do |row| + row.with_key(text: "Participant ID") + row.with_value(text: @application.user.ecf_id) + end + sl.with_row do |row| + row.with_key(text: "Application ID") + row.with_value(text: @application.ecf_id) + end + sl.with_row do |row| + row.with_key(text: "Registration submission date") + row.with_value(text: @application.created_at.to_fs(:govuk_short)) + end + sl.with_row do |row| + row.with_key(text: "Last updated date") + row.with_value(text: @application.updated_at.to_fs(:govuk_short)) + end + end +%> + +<%= govuk_details(summary_text: "View registration as it appears on the Lead Provider API V3") do %> +<%= JSON.pretty_generate API::ApplicationSerializer.render_as_hash(@application, view: :v3, root: "data") %>
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index daed272178..6f21680816 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -227,13 +227,14 @@
resources :applications, only: %i[index show] do
collection do
- resources :reviews, controller: "applications/reviews", as: "application_reviews", only: %i[index]
+ resources :reviews, controller: "applications/reviews", as: "application_reviews", only: %i[index show]
end
member do
namespace :applications, path: nil do
resource :revert_to_pending, controller: "revert_to_pending", only: %i[new create]
resource :change_training_status, only: %i[new create]
resource :change_funding_eligibility, only: %i[new create]
+ resource :notes, only: %i[edit update]
end
end
end
diff --git a/spec/features/npq_separation/admin/applications_in_review_spec.rb b/spec/features/npq_separation/admin/applications_in_review_spec.rb
index 2f71b7c358..d6b3c039f4 100644
--- a/spec/features/npq_separation/admin/applications_in_review_spec.rb
+++ b/spec/features/npq_separation/admin/applications_in_review_spec.rb
@@ -3,11 +3,11 @@
RSpec.feature "Applications in review", type: :feature do
include Helpers::AdminLogin
- let(:cohort_21) { create(:cohort, start_year: 2021) }
- let(:cohort_22) { create(:cohort, start_year: 2022) }
+ let(:cohort_21) { create :cohort, start_year: 2021 }
+ let(:cohort_22) { create :cohort, start_year: 2022 }
let!(:normal_application) { create(:application) }
- let!(:application_for_hospital_school) { create(:application, employment_type: "hospital_school", employer_name: Faker::Company.name, cohort: cohort_21, referred_by_return_to_teaching_adviser: "yes") }
+ let!(:application_for_hospital_school) { create(:application, :accepted, employment_type: "hospital_school", employer_name: Faker::Company.name, cohort: cohort_21, referred_by_return_to_teaching_adviser: "yes") }
let!(:application_for_la_supply_teacher) { create(:application, employment_type: "local_authority_supply_teacher", cohort: cohort_22, referred_by_return_to_teaching_adviser: "no") }
let!(:application_for_la_virtual_school) { create(:application, employment_type: "local_authority_virtual_school") }
let!(:application_for_lead_mentor) { create(:application, employment_type: "local_authority_virtual_school") }
@@ -16,6 +16,8 @@
let!(:application_for_rtta_yes) { create(:application, referred_by_return_to_teaching_adviser: "yes") }
let!(:application_for_rtta_no) { create(:application, referred_by_return_to_teaching_adviser: "no") }
+ let(:serialized_application) { { application: 1 } }
+
before do
sign_in_as create(:admin)
visit npq_separation_admin_applications_path
@@ -128,4 +130,78 @@
expect(page).not_to have_text(application_for_hospital_school.user.full_name)
expect(page).not_to have_text(application_for_la_supply_teacher.user.full_name)
end
+
+ scenario "viewing an application" do
+ allow(API::ApplicationSerializer).to receive(:render_as_hash).and_return(serialized_application)
+ application = application_for_hospital_school.reload
+ application.user.update! uid: SecureRandom.uuid
+
+ click_on application.user.full_name
+
+ expect(page).to have_css("h1", text: application.user.full_name)
+
+ expect(page).to have_text("Applicant ID: #{application.user.ecf_id}")
+ expect(page).to have_text("Email: #{application.user.email}")
+ expect(page).to have_text("Date of birth: #{application.user.date_of_birth.to_fs(:govuk_short)}")
+ expect(page).to have_text("National Insurance: Not provided")
+ expect(page).to have_text("TRN: #{application.user.trn} Not validated")
+ expect(page).to have_text("Get an Identity ID: #{application.user.uid}")
+
+ summary_lists = all(".govuk-summary-list")
+
+ expect(page).to have_css("h2", text: "Course details")
+ within(summary_lists[0]) do |summary_list|
+ expect(summary_list).to have_summary_item("NPQ course", "#{application.course.name} (#{application.course.short_code})")
+ expect(summary_list).to have_summary_item("Provider", application.lead_provider.name)
+ expect(summary_list).to have_summary_item("Provider approval status", application.lead_provider_approval_status.humanize)
+ end
+
+ expect(page).to have_css("h2", text: "Funding details")
+ within(summary_lists[1]) do |summary_list|
+ expect(summary_list).to have_summary_item("Eligible for funding", "No")
+ expect(summary_list).to have_summary_item("Funded place", "No")
+ expect(summary_list).to have_summary_item("Notes", application.notes)
+ end
+
+ expect(page).to have_css("h2", text: "Work details")
+ within(summary_lists[2]) do |summary_list|
+ expect(summary_list).to have_summary_item("Works in England", "Yes")
+ expect(summary_list).to have_summary_item("Work setting", application.work_setting)
+ expect(summary_list).to have_summary_item("Employment type", application.employment_type.humanize)
+ expect(summary_list).to have_summary_item("Employer name", application.employer_name)
+ expect(summary_list).to have_summary_item("Role", application.employment_role)
+ end
+
+ expect(page).to have_css("h2", text: "Schedule")
+ within(summary_lists[3]) do |summary_list|
+ expect(summary_list).to have_summary_item("Cohort", application.cohort.start_year)
+ expect(summary_list).to have_summary_item("Schedule identifier", application.schedule.identifier)
+ end
+
+ expect(page).to have_css("h2", text: "Registration details")
+ within(summary_lists[4]) do |summary_list|
+ expect(summary_list).to have_summary_item("Participant ID", application.user.ecf_id)
+ expect(summary_list).to have_summary_item("Application ID", application.ecf_id)
+ expect(summary_list).to have_summary_item("Registration submission date", application.created_at.to_fs(:govuk_short))
+ expect(summary_list).to have_summary_item("Last updated date", application.updated_at.to_fs(:govuk_short))
+ end
+
+ find("summary", text: "View registration as it appears on the Lead Provider API V3").click
+ expect(page).to have_text JSON.pretty_generate(serialized_application)
+ end
+
+ scenario "updating notes" do
+ click_on application_for_hospital_school.user.full_name
+
+ within(".govuk-summary-list__row", text: "Notes") do
+ click_on "Change"
+ end
+
+ fill_in "Notes about changes to this registration", with: "Some notes"
+ click_on "Update notes"
+
+ within(".govuk-summary-list__row", text: "Notes") do
+ expect(page).to have_text("Some notes")
+ end
+ end
end