Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candidate pool show candidate #10404

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<h1 class="govuk-heading-l"><%= t('.title') %></h2>

<% application_form.application_choices.each_with_index do |choice, index| %>
<h2 class="govuk-heading-m"><%= t('.subtitle', counter: index + 1) %></h3>
<%= govuk_summary_list do |summary_list| %>

<% summary_list.with_row do |row| %>
<% row.with_key { t('.subject') } %>
<% row.with_value { choice.course.subjects.pluck(:name).join(',') } %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key { t('.location') } %>
<% row.with_value do %>
<p class='govuk-body'>
<%= course_address(choice) %>
</p>
<p class='govuk-body'>
<%= choice.course_option.site_postcode %>
</p>
<% end %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key { t('.status') } %>
<% row.with_value { render(ProviderInterface::ApplicationStatusTagComponent.new(application_choice: choice)) } %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key { t('.rejection_reason') } %>
<% row.with_value { rejection_reason_value(choice) } %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key { t('.qualification') } %>
<% row.with_value { choice.course.qualifications_to_s } %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key { t('.funding_type') } %>
<% row.with_value { choice.course.funding_type.capitalize } %>
<% end %>
<% end %>

<h2 class="govuk-heading-m"><%= t('.personal_statement') %></h3>
<%= govuk_details(summary_text: 'Guidance given to candidates', classes: 'govuk-!-margin-bottom-4') do %>
<%= render 'candidate_interface/personal_statement/guidance' %>
<% end %>

<p class='govuk-body'><%= choice.personal_statement %></p>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class ProviderInterface::FindCandidates::ApplicationChoicesComponent < ViewComponent::Base
attr_reader :application_form

def initialize(application_form:)
@application_form = application_form
end

def course_address(choice)
site = choice.course_option.site
"#{site.address_line2} #{site.address_line3}"
end

def rejection_reason_value(choice)
return unless rejection_reasons_text(choice)

rejection_reasons_text(choice)
end

private

def rejection_reasons_text(choice)
return unless choice.rejection_reason.present? || choice.structured_rejection_reasons.present?

@rejection_reasons_text ||= render(RejectionsComponent.new(application_choice: choice))
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h2 class="govuk-heading-m"><%= t('.title') %></h2>

<%= govuk_summary_list do |summary_list| %>
<% summary_list.with_row do |row| %>
<% row.with_key { t('.visa_sponsorhip') } %>
<% row.with_value { visa_sponsorhip_value } %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ProviderInterface::FindCandidates::RightToWorkComponent < ViewComponent::Base
attr_reader :application_form

def initialize(application_form:)
@application_form = application_form
end

def visa_sponsorhip_value
application_form.right_to_work_or_study_yes? ? 'Not required' : 'Required'
end
end
11 changes: 11 additions & 0 deletions app/controllers/provider_interface/find_candidates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module ProviderInterface
class FindCandidatesController < ProviderInterfaceController
include Pagy::Backend
before_action :redirect_to_applications_unless_provider_opted_in
before_action :set_candidate, only: :show

def index
@pagy, @candidates = pagy(
Expand All @@ -10,8 +11,18 @@ def index
)
end

def show
@application_form = @candidate.application_forms.current_cycle.last
end

private

def set_candidate
@candidate ||= Pool::Candidates.for_provider(
providers: current_provider_user.providers,
).find_by(id: params.expect(:id))
end

def redirect_to_applications_unless_provider_opted_in
invites = CandidatePoolProviderOptIn.find_by(provider_id: current_provider_user.provider_ids)

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/navigation_items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def for_provider_primary_nav(current_provider_user, current_controller, performi
if CandidatePoolProviderOptIn.find_by(provider_id: current_provider_user.provider_ids).present?
items << {
text: 'Find candidates',
href: provider_interface_find_candidates_index_path,
href: provider_interface_find_candidates_path,
active: active?(current_controller, %w[find_candidates]),
}
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def description_and_accredited_provider
accredited_provider ? "#{description_to_s} - #{accredited_provider&.name}" : description_to_s
end

def name_code_and_course_provider
"#{name} (#{code}) – #{provider.name}"
end

def currently_has_both_study_modes_available?
available_study_modes_with_vacancies.count == 2
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/course_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CourseOption < ApplicationRecord
audited associated_with: :provider
delegate :provider, to: :course
delegate :accredited_provider, to: :course
delegate :name, :full_address, to: :site, prefix: true
delegate :name, :full_address, :postcode, to: :site, prefix: true

validates :vacancy_status, presence: true
validate :validate_providers
Expand Down
4 changes: 3 additions & 1 deletion app/views/provider_interface/find_candidates/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
<%= table.with_body do |body| %>
<% @candidates.each do |candidate| %>
<%= body.with_row do |row| %>
<%= row.with_cell(text: candidate.redacted_full_name_current_cycle) %>
<%= row.with_cell do %>
<%= govuk_link_to candidate.redacted_full_name_current_cycle, provider_interface_find_candidate_path(candidate) %>
<% end %>
<% end %>
<% end %>
<% end %>
Expand Down
12 changes: 12 additions & 0 deletions app/views/provider_interface/find_candidates/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% content_for :browser_title, t('.title') %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render ServiceInformationBanner.new(namespace: :provider) %>

<h1 class="govuk-heading-l"><%= @application_form.redacted_full_name %></h1>

<%= render ProviderInterface::FindCandidates::RightToWorkComponent.new(application_form: @application_form) %>
<%= render ProviderInterface::FindCandidates::ApplicationChoicesComponent.new(application_form: @application_form) %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
en:
provider_interface:
find_candidates:
right_to_work_component:
title: Right to work or study in the UK
visa_sponsorhip: Visa sponsorhip
application_choices_component:
title: Applications made
subtitle: Application %{counter}
subject: Subject
location: Location
status: Status
rejection_reason: Rejection reason
qualification: Qualification
funding_type: Funding type
personal_statement: Personal statement
2 changes: 2 additions & 0 deletions config/locales/provider_interface/find_candidates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ en:
candidate_information_agreement: These candidates have agreed to share their application details.
review_candidates: You can review their applications and decide whether to invite them to apply.
name: Name
show:
title: Candidate details
2 changes: 1 addition & 1 deletion config/routes/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

get '/applications' => 'application_choices#index'

get 'find-candidates/index' => 'find_candidates#index'
resources :find_candidates, only: %i[index show], path: 'find-candidates'

resources :reports, only: :index

Expand Down
1 change: 1 addition & 0 deletions spec/models/course_option_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
describe 'delegators' do
it { is_expected.to delegate_method(:name).to(:site).with_prefix }
it { is_expected.to delegate_method(:full_address).to(:site).with_prefix }
it { is_expected.to delegate_method(:postcode).to(:site).with_prefix }
end

describe '.selectable' do
Expand Down
11 changes: 11 additions & 0 deletions spec/models/course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,15 @@
expect(course.deferred_start_date).to eq(course.start_date + 1.year)
end
end

describe '#name_code_and_course_provider' do
it 'returns the name code and provider of the course' do
provider = create(:provider, name: 'provider')
course = create(:course, name: 'course', code: '123', provider:)

expect(course.name_code_and_course_provider).to eq(
'course (123) – provider',
)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
require 'rails_helper'

RSpec.describe 'Providers views candidate pool list' do
include CourseOptionHelpers
include DfESignInHelpers

let(:current_provider) { create(:provider) }

scenario 'View a candidate' do
given_i_am_a_provider_user_with_dfe_sign_in
and_provider_user_exists
and_there_are_candidates_for_candidate_pool
and_provider_is_opted_in_to_candidate_pool
and_i_sign_in_to_the_provider_interface

when_i_visit_the_find_candidates_page
and_i_click_on_a_candidate

then_i_am_redirected_to_view_that_candidate
and_i_can_view_their_details
end

def given_i_am_a_provider_user_with_dfe_sign_in
provider_exists_in_dfe_sign_in
end

def and_provider_user_exists
provider_user_exists_in_apply_database(provider_code: current_provider.code)
end

def and_there_are_candidates_for_candidate_pool
@rejected_candidate = create(:candidate, pool_status: 'opt_in')
@rejected_candidate_form = create(
:application_form,
:completed,
candidate: @rejected_candidate,
submitted_at: 1.day.ago,
)
create(:application_choice, :rejected, application_form: @rejected_candidate_form)

declined_candidate = create(:candidate, pool_status: 'opt_in')
@declined_candidate_form = create(
:application_form,
:completed,
candidate: declined_candidate,
submitted_at: Time.zone.today,
)
create(:application_choice, :declined, application_form: @declined_candidate_form)

previous_cycle_form = create(
:application_form,
:completed,
first_name: 'test',
last_name: 'test',
recruitment_cycle_year: RecruitmentCycleTimetable.previous_year,
submitted_at: 1.year.ago,
candidate: declined_candidate,
)
create(:application_choice, :declined, application_form: previous_cycle_form)
end

def and_provider_is_opted_in_to_candidate_pool
create(:candidate_pool_provider_opt_in, provider: current_provider)
end

def when_i_visit_the_find_candidates_page
visit provider_interface_find_candidates_path
end

def and_i_click_on_a_candidate
click_on @rejected_candidate.redacted_full_name_current_cycle
end

def then_i_am_redirected_to_view_that_candidate
expect(page).to have_current_path(provider_interface_find_candidate_path(@rejected_candidate), ignore_query: true)
end

def and_i_can_view_their_details
expect(page).to have_content(@rejected_candidate.redacted_full_name_current_cycle)
expect(page).to have_content('Right to work or study in the UK')
expect(page).to have_content('Applications made')
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def and_provider_is_opted_in_to_candidate_pool
end

def when_i_visit_the_find_candidates_page
visit provider_interface_find_candidates_index_path
visit provider_interface_find_candidates_path
end

def then_i_expect_to_see_eligible_candidates_order_by_application_form_submitted_at
Expand Down
Loading