Skip to content

Commit

Permalink
Add application_forms:decline_work_history_duration
Browse files Browse the repository at this point in the history
This adds a Rake task which allows us to decline the applications which
should not have been able to be submitted automatically.
  • Loading branch information
thomasleese committed Nov 23, 2023
1 parent aa591df commit 5a1965f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/tasks/application_forms.rake
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,44 @@ namespace :application_forms do
puts application_form.reference
end
end

desc "Decline applications with less than 9 months of work experience."
task :decline_work_history_duration,
%i[staff_email] => :environment do |_task, _args|
zimbabwe = Country.find_by!(code: "ZW").regions.first

ApplicationForm
.not_started_stage
.where.not(region: zimbabwe)
.where(needs_work_history: true)
.each do |application_form|
if WorkHistoryDuration.for_application_form(
application_form,
).enough_for_submission?
next
end

assessment = application_form.assessment

assessment_section = assessment.sections.find_by!(key: "work_history")
assessment_section.selected_failure_reasons.create!(
key: FailureReasons::WORK_HISTORY_DURATION,
assessor_feedback:
"You have added at least one teaching role that started before you " \
"were recognised as a teacher.\n\nWe do not accept teaching work " \
"experience that was gained before you were recognised as a " \
"teacher.\n\nThis means you have less than 9 months teaching work " \
"history and are not eligible for QTS.\n\nYou can reapply for QTS " \
"once you have gained more teaching work experience. If you have " \
"this experience already, you can reapply and provide evidence of " \
"this as part of your new application.",
)

application_form.reload

DeclineQTS.call(application_form:, user:)

puts application_form.reference
end
end
end

0 comments on commit 5a1965f

Please sign in to comment.