Skip to content

Commit

Permalink
mend
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpattinson committed Jan 16, 2025
1 parent 31356c3 commit 7715629
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 28 deletions.
25 changes: 24 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ RUN DATABASE_PASSWORD=required-to-run-but-not-used \
bundle exec rails assets:precompile

# Cleanup to save space in the production image
RUN rm -rf node_modules log/* tmp/* /tmp && \
RUN rm -rf log/* tmp/* /tmp && \
rm -rf /usr/local/bundle/cache && \
rm -rf .env && \
find /usr/local/bundle/gems -name "*.c" -delete && \
Expand Down Expand Up @@ -85,6 +85,29 @@ COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
ARG COMMIT_SHA
ENV GIT_SHA=$COMMIT_SHA
ENV SHA=$GIT_SHA
# Set up puppeteer (for PDF generation)
# https://pptr.dev/troubleshooting#running-on-alpine
RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# SSH access specific to Azure
# Install OpenSSH and set the password for root to "Docker!".
RUN apk add --no-cache openssh && echo "root:Docker!" | chpasswd

# Copy the Azure specific sshd_config file to the /etc/ssh/ directory
RUN ssh-keygen -A && mkdir -p /var/run/sshd
COPY azure/.sshd_config /etc/ssh/sshd_config

# Open port 2222 for Azure SSH access
EXPOSE 2222
>>>>>>> 5151546 (mend)

CMD bundle exec rails db:migrate:ignore_concurrent_migration_exceptions && \
bundle exec rails data:migrate:ignore_concurrent_migration_exceptions && \
Expand Down
65 changes: 65 additions & 0 deletions app/assets/builds/certificates.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
body {
margin: 0;
padding: 0;
}

.container {
position: absolute;
top: 0px;
left: 0px;
margin: 0;
padding: 0;
width: 100%;
}

.content {
position: absolute;
top: 350px;
left: 100px;
width: 100%;
}

.header-image {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
}

.heading {
font-size: 82px;
font-family: Helvetica;
color: #063961;
}

.text {
font-size: 18px;
font-family: Helvetica;
color: #231f20;
}

.content-npq {
position: absolute;
top: 350px;
left: 85px;
width: 100%;
}

.text-npq {
font-size: 32px;
font-family: Arial;
color: #231f20;
}

.heading-npq {
font-size: 48px;
font-family: Arial;
color: #231f20;
}

.name-heading-npq {
max-width: 70%;
text-align: left;
font-size: clamp(16px, 4vw, 40px);
white-space: nowrap;
}
22 changes: 22 additions & 0 deletions app/assets/stylesheets/certificates.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,25 @@ body {
font-family: Helvetica;
color: #231f20;
}
.content-npq {
position: absolute;
top: 350px;
left: 85px;
width: 100%;
}
.text-npq {
font-size: 32px;
font-family: Arial;
color: #231f20;
}
.heading-npq {
font-size: 48px;
font-family: Arial;
color: #231f20;
}
.name-heading-npq {
max-width: 70%;
text-align: left;
font-size: clamp(16px, 4vw, 40px);
white-space: nowrap;
}
6 changes: 3 additions & 3 deletions app/components/induction_summary_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class InductionSummaryComponent < ViewComponent::Base

attr_accessor :qualification

delegate :awarded_at, :certificate_type, :details, :name, to: :qualification
delegate :awarded_at, :type, :details, :name, to: :qualification

def detail_classes
"app__induction-details"
Expand Down Expand Up @@ -71,7 +71,7 @@ def rows
}
]

if details.respond_to?(:certificate_url) && details.certificate_url.present?
if details.status == "Pass"
@rows << {
key: {
text: "Certificate"
Expand All @@ -80,7 +80,7 @@ def rows
text:
link_to(
"Download Induction certificate",
qualifications_certificate_path(certificate_type, format: :pdf),
qualifications_certificate_path(:induction, format: :pdf),
class: "govuk-link"
)
}
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/qualifications/certificates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def show
formats: [:html],
locals: { teacher: @teacher, qualification: @qualification },
layout: "layouts/certificate")
grover = Grover.new(html, format: 'A4', display_url: request.base_url)
grover = Grover.new(html, format: 'A4', display_url: ENV["HOSTING_DOMAIN"])
pdf = grover.to_pdf
send_data pdf, filename: "#{@teacher.name}_#{@qualification.type.downcase}_certificate.pdf",
type: 'application/pdf', disposition: 'attachment'
Expand All @@ -22,7 +22,12 @@ def show
private

def client
@client ||= QualificationsApi::Client.new(token: session[:identity_user_token])
token = if FeatureFlags::FeatureFlag.active?(:one_login)
:onelogin_user_token
else
:identity_user_token
end
@client ||= QualificationsApi::Client.new(token: session[token])
end

def teacher
Expand Down
2 changes: 1 addition & 1 deletion app/views/qualifications/certificates/_eyts.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="/eyts-certificate.jpg" class="header-image" alt="Department for Education" />

<div class="content">
<h2 class="heading">Early years<br/>Teacher Status</h2>
<h1 class="heading">Early Years<br/>Teacher Status</h1>
<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>
Expand Down
6 changes: 3 additions & 3 deletions app/views/qualifications/certificates/_induction.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="/induction-certificate.jpg" class="header-image" alt="Department for Education" />

<div class="content">
<h2 class="heading">Induction</h2>
<h1 class="heading">Induction</h1>
<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>
Expand All @@ -11,9 +11,9 @@
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 class="text">Date Induction Completed:&#160;<strong><%= qualification.details.periods.first.end_date.to_date.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>
<p class="text">Any potential employer can independently confirm your teacher status online at:<br/><a>https://www.gov.uk/guidance/check-a-teachers-record</a></p>
</div>
2 changes: 1 addition & 1 deletion app/views/qualifications/certificates/_npq.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="content-npq">
<p class="text-npq">This is to certify that:</p>
<h2 class="heading-npq"> <%= teacher.name %></h2>
<h2 class="heading-npq name-heading-npq"> <%= teacher.name %></h2>
<p class="text-npq">has been awarded the</p>
<h2 class="heading-npq">
<strong>
Expand Down
4 changes: 2 additions & 2 deletions app/views/qualifications/certificates/_qts.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="/qts-certificate.jpg" class="header-image" alt="Department for Education" />

<div class="content">
<h2 class="heading">Qualified<br/>Teacher Status</h2>
<h1 class="heading">Qualified<br/>Teacher Status</h1>
<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>
Expand All @@ -19,5 +19,5 @@
<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>
<p class="text">Any potential employer can independently confirm your teacher status online at:<br/><a>https://www.gov.uk/guidance/check-a-teachers-record</a></p>
</div>
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default: &default
adapter: postgresql
encoding: unicode
url: <%= ENV.fetch('DATABASE_URL', 'postgres://postgres@localhost:5432') %>
url: <%= ENV.fetch('DATABASE_URL', 'postgres://postgres@localhost:5434') %>

development:
<<: *default
Expand Down
3 changes: 2 additions & 1 deletion config/initializers/grover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
bottom: "0",
left: "0",
right: "0"
}
},
launch_args: ["--no-sandbox", "--disable-setuid-sandbox"],
}
config.use_jpeg_middleware = false
config.use_png_middleware = false
Expand Down
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 modified 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 modified 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.
12 changes: 0 additions & 12 deletions spec/components/induction_summary_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,5 @@
expect(rendered.css(".govuk-summary-list__key").map(&:text)).not_to include("Completed")
expect(rendered.css(".govuk-summary-list__key").map(&:text)).not_to include("End date")
end

context "when the certificate URL is missing" do
let(:induction) do
fake_quals_data.fetch("induction").tap do |data|
data.delete(:certificate_url)
end
end

it "does not render the certificate row when certificate URL is missing" do
expect(rendered.css(".govuk-summary-list__key").map(&:text)).not_to include("Certificate")
end
end
end
end
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
WebMock.disable_net_connect!(allow_localhost: true)

Capybara.register_driver(:cuprite) do |app|
Capybara::Cuprite::Driver.new(app, timeout: 30, process_timeout: 40, window_size: [1200, 800])
Capybara::Cuprite::Driver.new(app, timeout: 200, process_timeout: 120, window_size: [1200, 800])
end
Capybara.default_driver = :cuprite
Capybara.javascript_driver = :cuprite
Expand Down

0 comments on commit 7715629

Please sign in to comment.