Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpattinson committed Nov 14, 2024
1 parent f46e879 commit 597af08
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 58 deletions.
5 changes: 1 addition & 4 deletions app/components/induction_summary_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def rows
text:
link_to(
"Download Induction certificate",
qualifications_certificate_path(
certificate_type,
certificate_url: details.certificate_url
),
qualifications_certificate_path(certificate_type, format: :pdf),
class: "govuk-link"
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/qualification_summary_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def rows
text:
link_to(
"Download #{type.to_s.upcase} certificate",
qualifications_certificate_path(certificate_type, format: :pdf),
qualifications_certificate_path(type, format: :pdf),
class: "govuk-link"
)
}
Expand Down
16 changes: 13 additions & 3 deletions app/controllers/qualifications/certificates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ def show
unless render_certificate?
redirect_to qualifications_dashboard_path,
alert: "Certificate not found"
return
end
Rails.logger.debug @qualification.certificate_type.downcase
html = render_to_string(template: "qualifications/certificates/_#{@qualification.certificate_type.downcase}",
formats: [:html],
locals: { teacher: @teacher, qualification: @qualification },
layout: "layouts/certificate")
grover = Grover.new(html, format: 'A4', display_url: request.base_url)
pdf = grover.to_pdf
send_data pdf, filename: "#{@teacher.name}_#{@qualification.type.downcase}_certificate.pdf",
type: 'application/pdf', disposition: 'attachment'
end

private
Expand All @@ -26,15 +36,15 @@ def qualification
def render_certificate?
return if qualification.blank?

case certificate_type.to_sym
case qualification.type.to_sym
when :induction
teacher.passed_induction?
when :qts
teacher.qts_awarded?
when :eyts
teacher.eyts_awarded?
when :npq
teacher.npq.present
when :NPQEL,:NPQLTD,:NPQLT,:NPQH,:NPQML,:NPQLL,:NPQEYL,:NPQSL,:NPQLBC
teacher.npq_awarded?
else
qualification.awarded_at.present?
end
Expand Down
3 changes: 2 additions & 1 deletion app/lib/qualifications_api/certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module QualificationsApi
class Certificate
include ActiveModel::Model

VALID_TYPES = %i[eyts induction itt mq npq qts].freeze
VALID_TYPES = %i[eyts induction itt NPQEL NPQLTD NPQLT NPQH NPQML NPQLL NPQEYL NPQSL NPQLBC qts].freeze

attr_accessor :name, :type, :file_data

def file_name
Expand Down
4 changes: 4 additions & 0 deletions app/lib/qualifications_api/teacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def eyts_awarded?
api_data.eyts&.awarded.present?
end

def npq_awarded?
api_data.npq_qualifications.first&.awarded.present?
end

def eyps_awarded?
api_data.eyps&.awarded.present?
end
Expand Down
19 changes: 18 additions & 1 deletion app/models/qualification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ class Qualification
attr_accessor :awarded_at, :certificate_url, :name, :status_description, :type
attr_writer :details

FORMATTED_QUALIFICATION_TEXT = {
NPQEL: "National Professional <br/> Qualification for <br/> Executive Leadership",
NPQLTD: "National Professional <br/> Qualification for Leading <br/> Teacher Development",
NPQLT: "National Professional <br/> Qualification for Leading <br/> Teaching",
NPQH: "National Professional <br/> Qualification for <br/> Headship",
NPQML:"National Professional <br/> Qualification for Middle <br/> Leadership",
NPQLL: "National Professional <br/> Qualification for Leading <br/> Literacy",
NPQEYL: "National Professional <br/> Qualification for Early <br/> Years Leadership",
NPQSL: "National Professional <br/> Qualification for Senior <br/> Leadership",
NPQLBC: "National Professional <br/> Qualification for Leading <br/> Behaviour and Culture"
}.freeze

def certificate_type
return :npq if type&.downcase&.starts_with?("npq")

Expand Down Expand Up @@ -33,7 +45,7 @@ def mq?
end

def npq?
type&.downcase&.starts_with?("npq")
type&.starts_with?("NPQ")
end

def qts?
Expand All @@ -43,4 +55,9 @@ def qts?
def eyts?
type == :eyts
end

def formatted_qualification_name
FORMATTED_QUALIFICATION_TEXT[type].html_safe
end

end
19 changes: 19 additions & 0 deletions app/views/qualifications/certificates/_induction.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<img src="/induction-certificate.jpg" class="header-image" alt="Department for Education" />

<div class="content">
<h2 class="heading">Induction</h2>
<p class="text">This is to certify that: <strong><%= teacher.name %></strong></p>
<p class="text">Teacher Reference Number: <strong><%= teacher.trn %></strong></p>
<p>&#160;</p>
<p class="text">has successfully completed a statutory induction period at a maintained school,<br/>
maintained nursery school, maintained children’s centre, non-maintained special school,<br/>
independent school, academy school, 16-19 academy, sixth form college or further education<br/>
institution. The holder of this certificate is a qualified teacher and has obtained the required<br/>
qualifications and completed the necessary training for the profession of school teacher in England.</p>
<p>&#160;</p>
<p class="text">Date Induction Completed:&#160;<strong><%= qualification.awarded_at.to_fs(:long_uk) %></strong></p>
<p>&#160;</p>
<p class="text">Congratulations and best wishes for your future career.</p>
<p>&#160;</p>
<p class="text">Any potential employer can independently confirm your teacher status online at:<br/>https://teacherservices.education.gov.uk</p>
</div>
20 changes: 10 additions & 10 deletions app/views/qualifications/certificates/_npq.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<img src="/qts-certificate.jpg" class="header-image" alt="Department for Education" />
<img src="/npq-certificate.jpg" class="header-image" alt="Department for Education" />

<div class="content">

<p class="text">This is to certify that: <strong><%= teacher.name %></strong></p>
<p>&#160;</p>
<p class="text">has been awarded the</p>
<p>&#160;</p>
<h2 class="heading"> <strong><%= qualification.name %></strong></h2>
<p>&#160;</p>
<p class="text">Any potential employer can independently confirm your teacher status online at:<br/>https://teacherservices.education.gov.uk</p>
<div class="content-npq">
<p class="text-npq">This is to certify that:</p>
<h2 class="heading-npq"> <%= teacher.name %></h2>
<p class="text-npq">has been awarded the</p>
<h2 class="heading-npq">
<strong>
<%= qualification.formatted_qualification_name %>
</strong>
</h2>
</div>
6 changes: 6 additions & 0 deletions app/views/qualifications/certificates/_qts.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
<p class="text">This is to certify that: <strong><%= teacher.name %></strong></p>
<p class="text">Teacher Reference Number: <strong><%= teacher.trn %></strong></p>
<p>&#160;</p>
<% if teacher.exempt_from_induction? %>
<p class="text">has attained qualified teacher status (QTS), meets the requirements for employment in <br/>
maintained schools and non-maintained special schools in England and is exempt from the <br/>
requirements to serve a statutory induction period.</p>
<% else %>
<p class="text">has attained qualified teacher status (QTS), meets the requirements for employment in<br/>
maintained schools and non-maintained special schools in England provided that statutory<br/>
induction period is completed satisfactorily.</p>
<% end %>
<p>&#160;</p>
<p class="text">Date of QTS: <strong><%= qualification.awarded_at.to_fs(:long_uk) %></strong></p>
<p>&#160;</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/qualifications/certificates/show.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render "#{@qualification.type}", teacher: @teacher, qualification: @qualification %>
<%= render "#{@qualification.certificate_type}", teacher: @teacher, qualification: @qualification %>
2 changes: 1 addition & 1 deletion config/initializers/grover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
config.use_jpeg_middleware = false
config.use_png_middleware = false
config.ignore_path = ->(path) do
path !~ /^\/qualifications\/certificates\/(eyts|itt|induction|mq|npq|qts)/
path !~ /^\/qualifications\/certificates\/(eyts|itt|induction|mq|npq|qts)/i
end
end
Binary file modified public/eyts-certificate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/induction-certificate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/npq-certificate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/qts-certificate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion spec/support/fake_qualifications_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def quals_data(trn: nil, itt: true)
induction: {
startDate: "2022-09-01",
endDate: "2022-10-01",
status: "pass",
status: "Pass",
statusDescription: "Passed Induction",
certificateUrl: "/v3/certificates/induction",
periods: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def then_i_see_results
expect(page).to have_content "1 teacher record found"
expect(page).to have_content "Terry Walsh"
expect(page).to have_content "Restriction"
expect(page).to have_content "No induction"
expect(page).to have_content "Passed induction"
end

def and_my_search_is_logged
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def and_my_induction_certificate_is_downloadable
"attachment"
)
expect(page.response_headers["Content-Disposition"]).to include(
"filename=\"Test User_induction_certificate.pdf\""
"filename=\"Terry Walsh_induction_certificate.pdf\""
)
end

Expand All @@ -73,7 +73,7 @@ def and_my_qts_certificate_is_downloadable
"attachment"
)
expect(page.response_headers["Content-Disposition"]).to include(
"filename=\"Test User_qts_certificate.pdf\";"
"filename=\"Terry Walsh_qts_certificate.pdf\";"
)
end

Expand All @@ -84,7 +84,7 @@ def and_my_eyts_certificate_is_downloadable
"attachment"
)
expect(page.response_headers["Content-Disposition"]).to include(
"filename=\"Test User_eyts_certificate.pdf\";"
"filename=\"Terry Walsh_eyts_certificate.pdf\";"
)
end

Expand Down Expand Up @@ -114,7 +114,7 @@ def and_my_npq_certificate_is_downloadable
"attachment"
)
expect(page.response_headers["Content-Disposition"]).to include(
"filename=\"Test User_npq_certificate.pdf\";"
"filename=\"Terry Walsh_npqh_certificate.pdf\";"
)
end

Expand Down

0 comments on commit 597af08

Please sign in to comment.