From 04aac7fe7911619383a2fed35361b9514fbe85cc Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 25 Apr 2024 09:04:48 +0100 Subject: [PATCH] Add update_teaching_qualification_certificate_date task This adds a new Rake task that makes it possible to change the certificate date of a qualification using the service added in the previous commit. --- lib/tasks/application_forms.rake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/tasks/application_forms.rake b/lib/tasks/application_forms.rake index 567e681b44..ee5ef1bdeb 100644 --- a/lib/tasks/application_forms.rake +++ b/lib/tasks/application_forms.rake @@ -92,4 +92,26 @@ namespace :application_forms do user:, ) end + + desc "Change the certificate date of a qualification for an application form." + task :update_teaching_qualification_certificate_date, + %i[reference staff_email certificate_date] => + :environment do |_task, args| + application_form = ApplicationForm.find_by!(reference: args[:reference]) + qualification = application_form.teaching_qualification + user = Staff.find_by!(email: args[:staff_email]) + certificate_date = Date.parse(args[:certificate_date]) + + UpdateQualificationCertificateDate.call( + qualification:, + user:, + certificate_date:, + ) + + note = + "Amended date to accurately reflect the qualification (deemed by the assessor). " \ + "This was approved by Humzah and Natalie on 16/04/2024." + + CreateNote.call(application_form:, author: user, text: note) + end end