Skip to content

Commit

Permalink
Merge pull request #490 from commercekitchen/develop
Browse files Browse the repository at this point in the history
Release 5/7/2021
  • Loading branch information
tmichaelreis authored May 7, 2021
2 parents 840707f + c0eb2c1 commit db547b3
Show file tree
Hide file tree
Showing 26 changed files with 133 additions and 48 deletions.
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,3 @@ group :test do
gem 'webdrivers'
gem 'webmock'
end

group :development, :staging do
gem 'mail_interceptor'
end
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ GEM
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
mail_interceptor (0.0.7)
activesupport
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
Expand Down Expand Up @@ -461,7 +459,6 @@ DEPENDENCIES
letter_opener
listen
local_time (>= 2.0)
mail_interceptor
mocha
nilify_blanks
paperclip
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
//= require jquery_ujs
//= require select2.full
//= require html.sortable
//= require local-time
//= require ckeditor/init
//= require_tree .
2 changes: 1 addition & 1 deletion app/controllers/course_completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def show

if current_user
send_data(@pdf,
filename: "#{current_user.profile.first_name} #{@course.title} completion certificate.pdf",
filename: "#{current_user.first_name} #{@course.title} completion certificate.pdf",
type: 'application/pdf')
else
send_data(@pdf,
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/course_completion_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

module CourseCompletionHelper
def course_completion_date(user, course)
completion_date = user.present? ? user.course_progresses.find_by(course_id: course.id).completed_at : Time.zone.now
local_time(completion_date, :date_only)
end
end
2 changes: 1 addition & 1 deletion app/helpers/courses_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def courses_completed
end

def categorized_courses(courses)
courses.group_by do |course|
courses.includes(:category).order('categories.category_order').group_by do |course|
if course.category&.enabled?
course.category.name
else
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/nav_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def user_greeting
if org_admin?
"#{t('logged_in_user.hi')} Admin!"
else
"#{t('logged_in_user.hi')} #{current_user.profile.first_name}!"
"#{t('logged_in_user.hi')} #{current_user.first_name}!"
end
end

Expand Down
6 changes: 5 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class User < ApplicationRecord
serialize :quiz_responses_object

# Expose some information from profile
delegate :library_location_name, :library_location_zipcode, to: :profile, allow_nil: true
delegate :first_name,
:last_name,
:full_name,
:library_location_name,
:library_location_zipcode, to: :profile, allow_nil: true

### Devise overrides to allow library card number login
# TODO: Pull this into a concern
Expand Down
4 changes: 2 additions & 2 deletions app/views/course_completions/_certificate.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= t('certificate.this_award') %>
</p>
<% if current_user %>
<%= content_tag :h2, "#{current_user.profile.full_name}", class: "name" %>
<%= content_tag :h2, "#{current_user.full_name}", class: "name" %>
<% else %>
<%= t('certificate.name_fill') %>
<% end %>
Expand All @@ -14,7 +14,7 @@
</p>
<%= content_tag :h2, "#{@course.title}", class: "course-title" %>
<p>
<%= t('certificate.as_of') %> <% if current_user %> <%= local_time(current_user.course_progresses.where(course_id: @course.id).first.completed_at, '%B %e, %Y') %> <% else %> <%= local_time(Time.zone.now, '%B %e, %Y') %> <% end %>
<%= t('certificate.as_of') %> <%= course_completion_date(current_user, @course) %>
</p>
<div class='certificate-logo'>
<%= image_tag "dl_logo.png", alt: "DigitalLearn Logo" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/course_completions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<%= course.title %>
</td>
<td>
<%= local_time(current_user.course_progresses.where(course_id: course.id).first.completed_at, '%B %e, %Y') %>
<%= course_completion_date(current_user, course) %>
</td>
<td>
<%= link_to "Download Certificate", course_completion_path(course, format: 'pdf') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/course_completions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="congrats-banner color">
<div class="form-row">
<% if current_user %>
<%= content_tag :p, "#{t('course_completion_page.congratulations')}, #{current_user.profile.first_name}." %>
<%= content_tag :p, "#{t('course_completion_page.congratulations')}, #{current_user.first_name}." %>
<% end %>
<%= content_tag :p, "#{t('course_completion_page.you_successfully_completed')} #{@course.title}!", class: "small-margin" %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/course_completions/show.pdf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= t('certificate.this_award') %>
</p>
<% if current_user %>
<%= content_tag :h2, "#{current_user.profile.first_name} #{current_user.profile.last_name}", class: "name" %>
<%= content_tag :h2, "#{current_user.first_name} #{current_user.last_name}", class: "name" %>
<% else %>
<br/><br/>
<%= t('certificate.name_fill_long') %>
Expand All @@ -15,7 +15,7 @@
</p>
<%= content_tag :h2, "#{@course.title}", class: "course" %>
<p>
<%= t('certificate.as_of') %> <% if current_user %> <%= local_time(current_user.course_progresses.where(course_id: @course.id).first.completed_at, '%B %e, %Y') %> <% else %> <%= local_time(Time.zone.now, '%B %e, %Y') %> <% end %>
<%= t('certificate.as_of') %> <%= course_completion_date(current_user, @course) %>
</p>
<%= wicked_pdf_image_tag "dl_logo.png" %>
</div>
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= render "shared/layout/meta_tags" %>
<%= render "shared/layout/analytics" %>
</head>
<body class="<%= "#{controller_name}-#{action_name}" %> <%= current_organization.subdomain %>">
<body class="<%= "#{controller_name}-#{action_name}" %> <%= current_organization.subdomain %>" data-locale="<%= I18n.locale %>">
<%= render "shared/layout/header" %>
<%= render "shared/layout/banner" %>
<%= render "shared/courses/preview_notice" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/quiz_responses/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= content_for(:callout) do %>
<h1><%= current_user.profile.first_name %>, <%= t('quiz.intro_text') %> </h1>
<h1><%= current_user.first_name %>, <%= t('quiz.intro_text') %> </h1>
<% end %>

<h2 class="text-color"><%= t('quiz.answer_3_questions') %> </h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_logo_banner.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 class="slogan">
<% if user_signed_in? %>
<%= t('logged_in_user.hi') %> <%=current_user.profile.first_name%><%= "(ADMIN)" if current_user.admin? %>!
<%= t('logged_in_user.hi') %> <%=current_user.first_name%><%= "(ADMIN)" if current_user.admin? %>!
<br>
<% end %>
<%= raw i18n_with_default("home.#{current_organization.subdomain}.custom_banner_greeting") %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_quiz_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="modal-fade-screen">
<div class="modal-inner quiz-modal-inner">
<div class="modal-close" for="quiz-start-modal"></div>
<h2 class="text-color"><%= current_user.profile.first_name %>, <%= t('quiz.intro_text') %> </h2>
<h2 class="text-color"><%= current_user.first_name %>, <%= t('quiz.intro_text') %> </h2>
<h2 class="text-color"><%= t('quiz.answer_3_questions') %> </h2>
<div>
<%= form_tag new_quiz_response_path, id: "msform" do %>
Expand Down
9 changes: 9 additions & 0 deletions app/views/shared/analytics/_ga_mdpls.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-37972615-15"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-37972615-15');
</script>
25 changes: 16 additions & 9 deletions config/initializers/mail_interceptor.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
unless Rails.env.test? || Rails.env.production?
options = { forward_emails_to:
["[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"] }
interceptor = MailInterceptor::Interceptor.new(options)
ActionMailer::Base.register_interceptor(interceptor)
end
if Rails.env.staging?
class MailInterceptor
def self.delivering_email(message)
allowed_domains = /@ckdtech.co$|@commercekitchen.com$|@annealinc.com$/i
recipients = Array(message.to).select { |recipient| (recipient =~ allowed_domains).present? }

# If filtered recipients doesn't include any acceptable
# recipient, auto populate with some employees
recipients = %w[[email protected] [email protected]] if recipients.empty?

message.to = recipients
end
end

ActionMailer::Base.register_interceptor(MailInterceptor)
end
6 changes: 5 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ en:
password: "Password"
course:
pub_status: "Publication Status"
date:
formats:
date_only: "%-m/%-d/%Y"
common:
submit: "Submit"
save: "Save"
Expand Down Expand Up @@ -259,7 +262,7 @@ en:
this_award: "This award certifies that"
name_fill: "_____________________"
name_fill_long: "_________________________________________"
has_completed: "has completed:"
has_completed: "has completed"
as_of: "as of"
quiz:
intro_text: " what would you like to learn?"
Expand Down Expand Up @@ -295,6 +298,7 @@ en:
carnegielibrary: "https://analytics.google.com/analytics/web/#embed/report-home/a37972615w160560212p161760560/"
cleveland: "https://analytics.google.com/analytics/web/#embed/report-home/a37972615w216325566p206666986/"
yclibrary: "https://analytics.google.com/analytics/web/#embed/report-home/a37972615w216335491p206727926"
mdpls: "https://analytics.google.com/analytics/web/#/report-home/a37972615w270389568p241859444"
google_studio_url:
chipublib: "https://datastudio.google.com/open/1SAr1D4QfApB4KmerUiIeDMTT-UDO8jik"
npl: "https://datastudio.google.com/open/1Z4sv_djbM53ZRAkcGOOlq8tjVM3AS8gb"
Expand Down
8 changes: 6 additions & 2 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ es:
attributes:
last_name:
blank: "no puede estar en blanco"
date:
formats:
date_only: "%-d/%-m/%Y"
common:
submit: "Enviar"
save: "Guardar"
Expand Down Expand Up @@ -261,8 +264,8 @@ es:
this_award: "Este diploma certifica que"
name_fill: "_____________________"
name_fill_long: "_________________________________________"
has_completed: "ha culminado la clase de"
as_of: "en el mes de"
has_completed: "ha completado el curso de"
as_of: "el"
quiz:
intro_text: " ¿qué le gustaría aprender?"
answer_3_questions: "Responda tres preguntas y le recomendaremos qué cursos tomar."
Expand Down Expand Up @@ -297,6 +300,7 @@ es:
carnegielibrary: "https://analytics.google.com/analytics/web/#embed/report-home/a37972615w160560212p161760560/"
cleveland: "https://analytics.google.com/analytics/web/#embed/report-home/a37972615w216325566p206666986/"
yclibrary: "https://analytics.google.com/analytics/web/#embed/report-home/a37972615w216335491p206727926"
mdpls: "https://analytics.google.com/analytics/web/#/report-home/a37972615w270389568p241859444"
google_studio_url:
chipublib: "https://datastudio.google.com/open/1SAr1D4QfApB4KmerUiIeDMTT-UDO8jik"
npl: "https://datastudio.google.com/open/1Z4sv_djbM53ZRAkcGOOlq8tjVM3AS8gb"
Expand Down
2 changes: 1 addition & 1 deletion db/data/20210209193144_create_mdpls_subsite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def up
end

# Import branches
Rake::Task["data_import:import_branches"].invoke(subdomain)
Rake::Task['data_import:import_branches'].invoke(subdomain)
end

def down
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/profile_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
language: @english, opt_out_of_recommendations: true }
put :update, params: { id: @user.profile, profile: profile_params, authenticity_token: set_authenticity_token }
@user.reload
expect(@user.profile.first_name).to eq('Robby')
expect(@user.first_name).to eq('Robby')
expect(@user.profile.zip_code).to eq('12345')
expect(@user.profile.language.name).to eq('English')
expect(@user.profile.opt_out_of_recommendations).to be true
Expand Down
8 changes: 4 additions & 4 deletions spec/features/user/account_settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
click_button 'Save'

@user.reload
expect(@user.profile.first_name).to eq('Alex')
expect(@user.first_name).to eq('Alex')
expect(@user.profile.zip_code).to eq('12345')
expect(@user.profile.language.name).to eq('English')
end
Expand Down Expand Up @@ -81,8 +81,8 @@
click_button 'Save'

@program_user.reload
expect(@program_user.profile.first_name).to eq('Alex')
expect(@program_user.profile.last_name).to eq('Monroe')
expect(@program_user.first_name).to eq('Alex')
expect(@program_user.last_name).to eq('Monroe')
expect(@program_user.profile.zip_code).to eq('12345')
expect(@program_user.profile.language.name).to eq('English')
end
Expand Down Expand Up @@ -123,7 +123,7 @@
click_button 'Save'

user.reload
expect(user.profile.first_name).to eq('Alex')
expect(user.first_name).to eq('Alex')
expect(user.profile.zip_code).to eq('12345')
expect(user.profile.language.name).to eq('English')
end
Expand Down
6 changes: 3 additions & 3 deletions spec/features/user/registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
expect(page).to have_content('This is the first time you have logged in, please update your profile.')

user = User.last
expect(user.profile.first_name).to eq('Alejandro')
expect(user.first_name).to eq('Alejandro')
expect(user.profile.zip_code).to eq('')
end

Expand Down Expand Up @@ -84,7 +84,7 @@
expect(page).to have_content('This is the first time you have logged in, please update your profile.')

user = User.last
expect(user.profile.first_name).to eq(first_name)
expect(user.first_name).to eq(first_name)
expect(user.profile.zip_code).to eq(zip_code)
end

Expand Down Expand Up @@ -129,7 +129,7 @@
expect(page).to have_content('This is the first time you have logged in, please update your profile.')

user = User.last
expect(user.profile.first_name).to eq(first_name)
expect(user.first_name).to eq(first_name)
expect(user.profile.zip_code).to eq('')
end

Expand Down
Loading

0 comments on commit db547b3

Please sign in to comment.