Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpattinson committed Nov 12, 2024
1 parent f46e879 commit 1f62c85
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 21 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
14 changes: 11 additions & 3 deletions app/controllers/qualifications/certificates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def show
redirect_to qualifications_dashboard_path,
alert: "Certificate not found"
end
Rails.logger.debug @qualification.certificate_type.downcase
html = render_to_string(template: "qualifications/certificates/_#{@qualification.certificate_type.downcase}",
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 +34,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
2 changes: 1 addition & 1 deletion app/lib/qualifications_api/certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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
27 changes: 26 additions & 1 deletion app/models/qualification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def mq?
end

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

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

def pretty_qualification_name
if certificate_type == :npq
case type
when :NPQEL
"National Professional <br/> Qualification for <br/> Executive Leadership"
when :NPQLTD
"National Professional <br/> Qualification for Leading <br/> Teaching"
when :NPQLT
"National Professional <br/> Qualification for Leading <br/> Teaching"
when :NPQH
"National Professional <br/> Qualification for <br/> Headship"
when :NPQML
"National Professional <br/> Qualification for Middle <br/> Leadership"
when :NPQLL
"National Professional <br/> Qualification for Leading <br/> Literacy"
when :NPQEYL
"National Professional <br/> Qualification for Early <br/> Years Leadership"
when :NPQSL
"National Professional <br/> Qualification for Senior <br/> Leadership"
when :NPQLBC
"National Professional <br/> Qualification for Leading <br/> Behaviour and Culture"
end
end
end
end
19 changes: 19 additions & 0 deletions app/views/qualifications/certificates/_induction.hmtl.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>
35 changes: 26 additions & 9 deletions app/views/qualifications/certificates/_npq.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
<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>
<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>
<% case qualification.type %>
<% when :NPQEL %>
<%= "National Professional <br/> Qualification for <br/> Executive Leadership".html_safe %>
<% when :NPQLTD, :NPQLT %>
<%= "National Professional <br/> Qualification for Leading <br/> Teaching".html_safe %>
<% when :NPQH %>
<%= "National Professional <br/> Qualification for <br/> Headship".html_safe %>
<% when :NPQML %>
<%= "National Professional <br/> Qualification for Middle <br/> Leadership".html_safe %>
<% when :NPQLL %>
<%= "National Professional <br/> Qualification for Leading <br/> Literacy".html_safe %>
<% when :NPQEYL %>
<%= "National Professional <br/> Qualification for Early <br/> Years Leadership".html_safe %>
<% when :NPQSL %>
<%= "National Professional <br/> Qualification for Senior <br/> Leadership".html_safe %>
<% when :NPQLBC %>
<%= "National Professional <br/> Qualification for Leading <br/> Behaviour and Culture".html_safe %>
<% end %>
</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 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.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def then_i_see_my_induction_details
end

def and_my_induction_certificate_is_downloadable

click_on "Download Induction certificate"
expect(page.response_headers["Content-Type"]).to eq("application/pdf")
expect(page.response_headers["Content-Disposition"]).to include(
Expand Down

0 comments on commit 1f62c85

Please sign in to comment.