Skip to content

Commit

Permalink
Merge pull request #515 from commercekitchen/develop
Browse files Browse the repository at this point in the history
Release 8_17_2021
  • Loading branch information
tmichaelreis authored Aug 17, 2021
2 parents 81e5185 + 609adbb commit ed65cdb
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
@import "admin/custom/*";
@import "scaffolds";
@import "pdf";
@import "att_pdf";
45 changes: 45 additions & 0 deletions app/assets/stylesheets/att_pdf.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@import "vars";

.att-pdf-cert {
background-color: $att-light-blue;
padding: 2em;

.cert-box {
height: auto;
text-align: center;
border: none;
padding: 3rem;
background-color: $white;
color: $att-light-blue;
display: flex;
justify-content: space-between;
flex-direction: column;

p {
font-size: 1.5em;
}

h1 {
font-size: 3.5em;
margin: 0 0 1em 0;
}

.name-fill {
border-bottom: 1px solid $att-light-blue;
width: 75%;
margin: 3em auto 1em auto;
}

h2 {
font-size: 2.5em;
font-weight: lighter;
margin-bottom: 2em;
}

img {
margin: 2em;
position: relative;
height: 5em;
}
}
}
6 changes: 5 additions & 1 deletion app/assets/stylesheets/pdf.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
border-color: $teal;
height: 43.5em;
text-align: center;
color: $dark-grey;
color: $grey;

h1 {
font-size: 3.5em;
margin: 1.5em 0;
}

h2 {
font-size: 2.5em;
margin: 0.5em 0;
Expand All @@ -21,10 +23,12 @@
color: $teal;
}
}

p {
font-size: 1.5em;
margin: 0.2em 0;
}

img {
position: absolute;
bottom: 2em;
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/subdomains/_att.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
.congrats-banner {
background-color: $att-light-blue;
}

.login-button-container {
display: none;
}
}

.att-certificate {
Expand Down
12 changes: 11 additions & 1 deletion app/controllers/course_completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def show
format.html
format.pdf do
@pdf = render_to_string pdf: 'file_name',
template: 'course_completions/show.pdf.erb',
template: pdf_template_path,
layout: 'pdf.html.erb',
orientation: 'Landscape',
page_size: 'Letter',
Expand All @@ -44,4 +44,14 @@ def show
end
end

private

def pdf_template_path
if current_organization.custom_certificate_enabled?
"course_completions/custom_certificates/#{current_organization.subdomain}.pdf.erb"
else
"course_completions/show.pdf.erb"
end
end

end
1 change: 1 addition & 0 deletions app/helpers/admin/custom/translations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def en_keys
texts = {
'home.%<subdomain>s.custom_banner_greeting' => 'Homepage Greeting',
'home.choose_a_course.%<subdomain>s' => 'Course Selection Greeting',
'home.choose_course_subheader.%<subdomain>s' => 'Course Selection Subheader',
'completed_courses_page.%<subdomain>s.retake_the_quiz' => 'Retake the Quiz Button'
}

Expand Down
25 changes: 25 additions & 0 deletions app/views/course_completions/custom_certificates/att.pdf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="att-pdf-cert">
<div class="cert-box">
<h1><%= t('completed_courses_page.certificate_of_completion') %></h1>

<p>
<%= t('certificate.this_award') %>
</p>

<div class="name-fill">&nbsp;</div>

<p>
<%= t('certificate.has_completed') %>
</p>

<%= content_tag :h2, "#{@course.title}", class: "course" %>

<div class="image-container">
<%= wicked_pdf_image_tag "att_certificate_logo.png" %>
</div>

<div class="disclaimer">
<%= t('certificate.att.disclaimer').html_safe %>
</div>
</div>
</div>
8 changes: 3 additions & 5 deletions app/views/course_completions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
<% end %>

<div class="form-row">
<% if !current_organization.custom_certificate_enabled? %>
<%= link_to(course_completion_path(@course, format: 'pdf')) do %>
<%= button_tag(type: 'button', class: "congrats-button button-color") do %>
<%= t('course_completion_page.download_certificate') %>
<% end %>
<%= link_to(course_completion_path(@course, format: 'pdf')) do %>
<%= button_tag(type: 'button', class: "congrats-button button-color") do %>
<%= t('course_completion_page.download_certificate') %>
<% end %>
<% end %>

Expand Down
6 changes: 5 additions & 1 deletion app/views/layouts/pdf.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<html>
<head>
<meta charset='utf-8' />
<%= wicked_pdf_stylesheet_link_tag "pdf" -%>
<% if current_organization.custom_certificate_enabled? %>
<%= wicked_pdf_stylesheet_link_tag "#{current_organization.subdomain}_pdf" -%>
<% else %>
<%= wicked_pdf_stylesheet_link_tag "pdf" -%>
<% end %>
</head>
<body class="<%= current_organization.subdomain %>">
<div class="pdf-page">
Expand Down
9 changes: 9 additions & 0 deletions app/views/shared/_course_intro_text.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
<h2 class="slogan centered text-color">
<%= i18n_with_default("home.choose_a_course.#{current_organization.subdomain}") %>
</h2>

<% custom_subheader = i18n_with_default("home.choose_course_subheader.#{current_organization.subdomain}") %>

<% unless custom_subheader.blank? %>
<p class="custom-subheader-text">
<%= custom_subheader %>
</p>
<% end %>

<% if current_organization.courses.authenticated_users.exists? %>
<p class="center">
<%= t('home.more_courses') %>
Expand Down
1 change: 0 additions & 1 deletion config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
set :linked_dirs, fetch(:linked_dirs, []).push(
'log',
'tmp/pids',
'tmp/cache',
'tmp/sockets',
'vendor/bundle',
'public/system',
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.precompile += %w(ckeditor/*)

Rails.application.config.assets.precompile += ['pdf.css', 'att_pdf.css']
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ en:
ebrpl: "Choose a topic below to start learning or use the search box at the top of the screen."
carnegielibrary: "Choose a topic below to start learning or use the search box at the top of the screen."
kclibrary: "Choose a course below to start learning or search courses."
choose_course_subheader:
default_org: ""
new_to_computers: "If you are new to computers, haven't used them for a while, are a little unsure and uncomfortable, or just need a bit of a refresher, we have the tools to help you tackle technology at your own pace and gain the confidence you need to succeed."
search_courses: "Search Courses"
trainer_link: "Tools and Resources for Trainers"
Expand Down
2 changes: 2 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ es:
pima: "Seleccione un curso de los que aparecen a continuación para comenzar."
ebrpl: "Seleccione un tema a continuación para comenzar a aprender o utilice el cuadro de búsqueda en la parte superior de la pantalla."
carnegielibrary: "Seleccione un tema a continuación para comenzar a aprender o utilice el cuadro de búsqueda en la parte superior de la pantalla."
choose_course_subheader:
default_org: ""
new_to_computers: "Si usted no tiene experiencia con las computadoras, no las ha usado recientemente, no se siente cómodo usándolas, o necesita un repaso, aquí encontrará tutoriales prácticos que le ayudarán a entender cómo usar una computadora, y a adquirir la confianza para usar el internet en su vida diaria."
search_courses: "¿Qué le gustaría aprender?"
trainer_link: "Herramientas y recursos para instructores"
Expand Down
48 changes: 48 additions & 0 deletions spec/features/admin/translation_management_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

require 'feature_helper'

feature 'Admin updates translations' do
let(:organization) { FactoryBot.create(:organization) }
let(:admin) { FactoryBot.create(:user, :admin, organization: organization) }

before do
switch_to_subdomain(organization.subdomain)
log_in_with admin.email, admin.password
end

scenario 'Admin sees correct content on custom translations page' do
visit admin_custom_translations_path

# Page Header
expect(page).to have_content 'Custom Text - English'

# Table Headers
expect(page).to have_content 'Section'
expect(page).to have_content 'Default Text'
expect(page).to have_content 'Actions'

# Translation labels
expect(page).to have_content 'Homepage Greeting'
expect(page).to have_content 'Course Selection Greeting'
expect(page).to have_content 'Course Selection Subheader'
expect(page).to have_content 'Retake the Quiz Button'

# Translation values
expect(page).to have_content 'Choose a course below to start learning or search courses.'
expect(page).to have_content 'Retake the Quiz'
end

scenario 'Admin can change a translation' do
visit admin_custom_translations_path

find(:xpath, "//tr[td[contains(.,'Course Selection Subheader')]]/td/a", text: 'Edit').click
expect(current_path).to eq(new_admin_custom_translation_path('en'))

fill_in 'Course Selection Subheader in English', with: 'New Subheader text'
click_on 'Submit'

expect(page).to have_content 'Text for Course Selection Subheader updated.'
expect(page).to have_content 'New Subheader text'
end
end
16 changes: 16 additions & 0 deletions spec/features/anonymous_user_walkthrough_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@
expect(page).to have_content('Choose a course below to start learning or search courses.')
end

scenario 'visits home page for subdomain with custom translations' do
org = FactoryBot.create(:organization)
switch_to_subdomain(org.subdomain)

header_translation_key = "home.choose_a_course.#{org.subdomain}"
subhead_translation_key = "home.choose_course_subheader.#{org.subdomain}"
custom_heading = "Custom Courses Header"
custom_subheading = "Custom course subheader with more info"
FactoryBot.create(:translation, locale: :en, key: header_translation_key, value: custom_heading)
FactoryBot.create(:translation, locale: :en, key: subhead_translation_key, value: custom_subheading)

visit root_path
expect(page).to have_content custom_heading
expect(page).to have_content custom_subheading
end

scenario 'can visit the customization page' do
page = create(:cms_page, title: 'Pricing & Features')
visit cms_page_path(page)
Expand Down

0 comments on commit ed65cdb

Please sign in to comment.