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

Jack pilot review #4746

Closed
wants to merge 19 commits into from
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![Tests](https://github.com/DFE-Digital/early-careers-framework/workflows/Test/badge.svg)

Jack
# Early careers framework

## Development Setup
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/schools/cohorts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index
@cohorts = Cohort
.where
.not(start_year: 2020)
.where(start_year: ..Cohort.active_registration_cohort.start_year)
.where(start_year: ..::Schools::LatestManageableCohort.call(school: @school).start_year)
.order(start_year: :desc)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def create
end

def choice_saved
@cohort = cohort
@school = school
@cohort = cohort
render "shared/choice_saved_no_early_career_teachers"
end

Expand Down Expand Up @@ -61,6 +61,6 @@ def how_to_continue_form_params
end

def cohort
Cohort.active_registration_cohort
Schools::LatestManageableCohort.call(school:)
end
end
17 changes: 7 additions & 10 deletions app/controllers/schools/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Schools::BaseController < ApplicationController
def check_cohort_year
return if params[:cohort_id].blank?

if params[:cohort_id].to_i > Cohort.active_registration_cohort&.start_year
if params[:cohort_id].to_i > Schools::LatestManageableCohort.call(school: active_school).start_year
redirect_to schools_dashboard_path
end
end
Expand All @@ -28,13 +28,14 @@ def redirect_to_setup_cohort
return unless current_user.induction_coordinator?
return unless active_school

latest_manageable_cohort = Cohort.active_registration_cohort
return if active_school.chosen_programme?(latest_manageable_cohort)
latest_cohort = Schools::LatestManageableCohort.call(school: active_school)

if latest_manageable_cohort == Cohort.active_registration_cohort
redirect_to schools_cohort_setup_start_path(cohort_id: latest_manageable_cohort)
return if active_school.chosen_programme?(latest_cohort)

if latest_cohort == Cohort.active_registration_cohort
redirect_to schools_cohort_setup_start_path(cohort_id: latest_cohort)
else
cohort_id = (active_cohort || latest_manageable_cohort)&.start_year
cohort_id = (active_cohort || latest_cohort)&.start_year
redirect_to schools_choose_programme_path(school_id: active_school.slug, cohort_id:)
end
end
Expand Down Expand Up @@ -63,8 +64,4 @@ def set_school_cohort(cohort: active_cohort)
@school_cohort = policy_scope(SchoolCohort).find_by(cohort: @cohort, school: @school)
redirect_to schools_choose_programme_path(cohort_id: @cohort) unless @school_cohort
end

def start_year
Cohort.active_registration_cohort.start_year
end
end
16 changes: 10 additions & 6 deletions app/controllers/schools/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,32 @@ def show

private

def active_registration_cohort_visible?
@school_cohorts.map(&:cohort_id).include?(Cohort.active_registration_cohort.id)
def latest_manageable_cohort_visible?
@school_cohorts.where(cohort: latest_manageable_cohort).any?
end

def check_school_cohorts
if @school_cohorts.empty?
redirect_to schools_choose_programme_path(cohort_id: Cohort.active_registration_cohort.start_year)
redirect_to schools_choose_programme_path(cohort_id: latest_manageable_cohort.start_year)
end
end

def latest_manageable_cohort
@latest_manageable_cohort ||= Schools::LatestManageableCohort.call(school: @school)
end

def set_school_cohorts
@school = active_school
@school_cohorts = SchoolCohort.dashboard_for_school(school: @school,
latest_year: Cohort.active_registration_cohort.start_year)
latest_year: latest_manageable_cohort.start_year)
end

def set_up_new_cohort?
active_registration_cohort_visible? && [email protected]_programme?(Cohort.active_registration_cohort)
latest_manageable_cohort_visible? && [email protected]_programme?(latest_manageable_cohort)
end

def previous_school_cohort
@school.school_cohorts.find_by(cohort: Cohort.active_registration_cohort.previous)
@school.school_cohorts.find_by(cohort: latest_manageable_cohort.previous)
end

def previous_lead_provider(school_cohort)
Expand Down
12 changes: 10 additions & 2 deletions app/forms/schools/add_participants/base_wizard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def need_training_setup?

# path to the most appropriate start point to set up training for the transfer
def need_training_path
if cohort_to_place_participant == Cohort.active_registration_cohort
if cohort_to_place_participant == latest_manageable_cohort
schools_cohort_setup_start_path(school_id: school.slug, cohort_id: cohort_to_place_participant)
else
schools_choose_programme_path(school_id: school.slug, cohort_id: cohort_to_place_participant)
Expand All @@ -137,7 +137,15 @@ def school_previous_cohort
end

def current_cohort
@current_cohort ||= Cohort.active_registration_cohort
@current_cohort ||= latest_manageable_cohort
end

def latest_manageable_cohort
@latest_manageable_cohort ||= Schools::LatestManageableCohort.call(school:)
end

def school_within_next_registration_period?
latest_manageable_cohort != Cohort.current
end

def previous_cohort
Expand Down
4 changes: 1 addition & 3 deletions app/forms/schools/add_participants/who_to_add_wizard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def save!
def registration_open_for_participant_cohort?
desired_cohort = cohort_to_place_participant

return true if desired_cohort.start_year <= Cohort.current.start_year

Cohort.within_next_registration_period? && desired_cohort == Cohort.next
desired_cohort.start_year <= latest_manageable_cohort.start_year
end

def next_step_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def start_term_options
private

def start_term_in_registration_scope?
return true if Cohort.within_next_registration_period?
return true if wizard.school_within_next_registration_period?
return true if cannot_automatically_determine_cohort? && start_term == "summer"

false
Expand Down
4 changes: 3 additions & 1 deletion app/forms/schools/cohorts/setup_wizard/success.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def what_changes_programme
end

def should_send_the_pilot_survey?
cohort.start_year == 2023 && expect_any_ects? && current_user.induction_coordinator?
# FIXME: question raised if we should keep this/reuse/modify for 2024
# cohort.start_year == 2023 && expect_any_ects? && current_user.induction_coordinator?
false
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def induction_coordinator_dashboard_path(user)
return schools_dashboard_index_path if user.schools.count > 1

school = user.induction_coordinator_profile.schools.first
return schools_choose_programme_path(school_id: school.slug, cohort_id: Cohort.active_registration_cohort) if school.school_cohorts.empty?
return schools_choose_programme_path(school_id: school.slug, cohort_id: Schools::LatestManageableCohort.call(school:)) if school.school_cohorts.empty?

school_dashboard_with_tab_path(school)
end
Expand Down Expand Up @@ -105,6 +105,6 @@ def post_2020_ecf_participant?(user)

def school_dashboard_with_tab_path(school)
schools_dashboard_path(school_id: school.slug,
anchor: TabLabelDecorator.new(Cohort.active_registration_cohort.description).parameterize)
anchor: TabLabelDecorator.new(Schools::LatestManageableCohort.call(school:).description).parameterize)
end
end
2 changes: 1 addition & 1 deletion app/mailers/school_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def nomination_email
nomination_url = params[:nomination_url]
expiry_date = params[:expiry_date]

academic_year = Cohort.active_registration_cohort.description
academic_year = Schools::LatestManageableCohort.call(school:).description

template_mail(
NOMINATION_EMAIL_WITH_ACADEMIC_YEAR_TEMPLATE,
Expand Down
2 changes: 1 addition & 1 deletion app/services/dashboard/participants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(school:, user:, type: :all)
@no_longer_training_ects = []
@currently_mentoring_mentors = []
@not_mentoring_mentors = []
@latest_year = Cohort.active_registration_cohort.start_year
@latest_year = Schools::LatestManageableCohort.call(school:).start_year
@orphan_ects = []
@school = school
@user = user
Expand Down
6 changes: 6 additions & 0 deletions app/services/dqt_record_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ def magic_results

# all matches 23 cohort start date - use 23/1/1900
23 => CheckResult.new(magic_dqt_record(induction_start_date: Date.new(2023, 9, 1)), true, true, true, true, 4),

# all matches 24 cohort start date - use 24/1/1900
24 => CheckResult.new(magic_dqt_record(induction_start_date: Date.new(2024, 9, 1)), true, true, true, true, 4),

# all matches 25 cohort start date - use 25/1/1900
25 => CheckResult.new(magic_dqt_record(induction_start_date: Date.new(2025, 9, 1)), true, true, true, true, 4),
}
end

Expand Down
2 changes: 2 additions & 0 deletions app/services/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def feature

# Short-lived feature flags
TEMPORARY_FEATURE_FLAGS = %i[
registration_pilot
registration_pilot_school
eligibility_notifications
prevent_2023_ect_registrations
school_participant_status_language
Expand Down
9 changes: 9 additions & 0 deletions app/services/participants/sync_dqt_induction_start_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def initialize(dqt_induction_start_date, participant_profile)
end

def call
return false if school_cannot_manage_target_cohort?
return false unless update_induction_start_date
return true if mentor? || pre_2021_dqt_induction_start_date?
return cohort_missing unless target_cohort
Expand Down Expand Up @@ -62,6 +63,10 @@ def cohort_missing
save_error("Cohort containing date #{dqt_induction_start_date.to_fs(:govuk)} not setup in the service!")
end

def school_cannot_manage_target_cohort?
target_cohort && target_cohort.start_year > Schools::LatestManageableCohort.call(school:).start_year
end

def update_induction_start_date
participant_profile.update!(induction_start_date: dqt_induction_start_date) if dqt_induction_start_date
end
Expand All @@ -70,5 +75,9 @@ def update_participant
clear_participant_sync_errors
save_errors(*amend_cohort.errors.full_messages) unless amend_cohort.save
end

def school
@school ||= Induction::FindBy.call(participant_profile:).school
end
end
end
33 changes: 33 additions & 0 deletions app/services/schools/latest_manageable_cohort.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module Schools
class LatestManageableCohort < ::BaseService
def call
if active_registration_pilot?
if school_in_pilot?
Cohort.active_registration_cohort
else
Cohort.current
end
else
Cohort.active_registration_cohort
end
end

private

attr_reader :school

def initialize(school:)
@school = school
end

def active_registration_pilot?
FeatureFlag.active?(:registration_pilot)
end

def school_in_pilot?
FeatureFlag.active?(:registration_pilot_school, for: school)
end
end
end
Loading
Loading