diff --git a/.gitignore b/.gitignore
index ecffea34..bbb5f95f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,4 +60,7 @@ config/secrets.yml
.byebug_history
# Local environment
-/config/local_env.yml
\ No newline at end of file
+/config/local_env.yml
+
+# asdf version
+.tool-versions
\ No newline at end of file
diff --git a/.tool-versions b/.tool-versions
new file mode 100644
index 00000000..1c44dd0c
--- /dev/null
+++ b/.tool-versions
@@ -0,0 +1 @@
+ruby 2.6.6
diff --git a/Gemfile.lock b/Gemfile.lock
index 65cfbfd1..6c485734 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -42,7 +42,7 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
- addressable (2.7.0)
+ addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.0)
@@ -195,9 +195,11 @@ GEM
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
- mimemagic (0.3.4)
+ mimemagic (0.3.10)
+ nokogiri (~> 1)
+ rake
mini_mime (1.0.2)
- mini_portile2 (2.5.0)
+ mini_portile2 (2.5.1)
minitest (5.14.0)
mocha (1.11.2)
msgpack (1.3.3)
@@ -210,7 +212,7 @@ GEM
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
nio4r (2.5.2)
- nokogiri (1.11.1)
+ nokogiri (1.11.4)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
orm_adapter (0.5.0)
@@ -237,7 +239,7 @@ GEM
pry-remote (0.1.8)
pry (~> 0.9)
slop (~> 3.0)
- public_suffix (4.0.3)
+ public_suffix (4.0.6)
pundit (2.1.0)
activesupport (>= 3.0.0)
racc (1.5.2)
diff --git a/app/assets/images/att_logo_header.png b/app/assets/images/att_logo_header.png
new file mode 100644
index 00000000..44bf6893
Binary files /dev/null and b/app/assets/images/att_logo_header.png differ
diff --git a/app/assets/stylesheets/subdomains/_att.scss b/app/assets/stylesheets/subdomains/_att.scss
new file mode 100644
index 00000000..8a999421
--- /dev/null
+++ b/app/assets/stylesheets/subdomains/_att.scss
@@ -0,0 +1,8 @@
+.att {
+ @include color_scheme($att-dark-blue, $att-light-blue, $att-light-blue);
+ @include banner($att-light-blue);
+ @include buttons($att-dark-blue);
+ @include course_widget($att-light-blue, $att-dark-blue);
+ @include lesson_tile($att-light-blue, $grey, $att-orange);
+ @include icons($att-light-blue, $orange);
+}
diff --git a/app/assets/stylesheets/vars.scss b/app/assets/stylesheets/vars.scss
index 924c6124..36392576 100644
--- a/app/assets/stylesheets/vars.scss
+++ b/app/assets/stylesheets/vars.scss
@@ -64,6 +64,11 @@ $mdpls-blue: #145a92;
$mdpls-green: #046434;
$mdpls-gray: #808080;
+/* AT&T */
+$att-dark-blue: #0057b8;
+$att-light-blue: #009fdb;
+$att-orange: #ffb000;
+
$purple: #8945a1;
$purple-2: #7b439b;
$dark-purple: #7d3191;
diff --git a/app/controllers/admin/lessons_controller.rb b/app/controllers/admin/lessons_controller.rb
index 1c372f25..d23778d4 100644
--- a/app/controllers/admin/lessons_controller.rb
+++ b/app/controllers/admin/lessons_controller.rb
@@ -54,10 +54,10 @@ def update
end
def destroy_asl_attachment
- @lesson = @course.lessons.friendly.find(params[:format])
+ @lesson = @course.lessons.friendly.find(params[:lesson_id])
authorize @lesson, :update?
- @lesson.story_line = nil
+ @lesson.story_line.destroy
@lesson.save
FileUtils.remove_dir "#{Rails.root}/public/storylines/#{@lesson.id}", true
flash[:notice] = 'Story Line successfully removed, please upload a new story line .zip file.'
diff --git a/app/models/organization.rb b/app/models/organization.rb
index 1c7de0f9..eed335c6 100644
--- a/app/models/organization.rb
+++ b/app/models/organization.rb
@@ -89,6 +89,17 @@ def assignable_roles
end
end
+ def training_site_link
+ training_site_base = Rails.application.secrets.training_site_base
+ training_site_domain = Rails.application.secrets.training_site_domain
+
+ if use_subdomain_for_training_site
+ [training_site_base, subdomain, training_site_domain].join('.')
+ else
+ [training_site_base, training_site_domain].join('.')
+ end
+ end
+
def self.pla
find_by(subdomain: 'www')
end
diff --git a/app/views/admin/lessons/_form.html.erb b/app/views/admin/lessons/_form.html.erb
index 72c9a565..820af903 100644
--- a/app/views/admin/lessons/_form.html.erb
+++ b/app/views/admin/lessons/_form.html.erb
@@ -65,7 +65,7 @@
to upload a new one, you need to delete the current one first.
<%= @lesson.story_line.instance.story_line_file_name %>
- <%= link_to "Remove", destroy_asl_attachment_admin_course_lessons_path(@course, @lesson), method: "delete", data: { confirm: "Are you sure?" } %>
+ <%= link_to "Remove", destroy_asl_attachment_admin_course_lessons_path(course_id: @course.id, lesson_id: @lesson.id), method: "delete", data: { confirm: "Are you sure?" } %>
<% end %>
diff --git a/app/views/shared/analytics/_ga_att.html.erb b/app/views/shared/analytics/_ga_att.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/shared/header/_trainers_link.html.erb b/app/views/shared/header/_trainers_link.html.erb
index f8a5be7e..4afc60c1 100644
--- a/app/views/shared/header/_trainers_link.html.erb
+++ b/app/views/shared/header/_trainers_link.html.erb
@@ -1,5 +1,5 @@
- <%= link_to t('home.trainer_link'), "https://training.digitallearn.org" %>
+ <%= link_to t('home.trainer_link'), current_organization.training_site_link %>
\ No newline at end of file
diff --git a/config/deploy.rb b/config/deploy.rb
index 08485f7f..9ce6d735 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -3,7 +3,7 @@
require 'colorize'
# GIT Repo URL
-set :repo_url, "git@github.com:PublicLibraryAssoc/cpldl.git"
+set :repo_url, "git@github.com:commercekitchen/cpldl.git"
# Ruby Version (used for RVM) - MUST MATCH PASSENGER/SERVER CONFIG!
set :ruby_version, '2.6.4'
@@ -83,7 +83,6 @@
'tmp/sockets',
'vendor/bundle',
'public/system',
- 'public/storylines',
'public/ckeditor_assets'
)
diff --git a/db/data/20210630052420_create_att_subsite.rb b/db/data/20210630052420_create_att_subsite.rb
new file mode 100644
index 00000000..494b3ff2
--- /dev/null
+++ b/db/data/20210630052420_create_att_subsite.rb
@@ -0,0 +1,29 @@
+class CreateAttSubsite < ActiveRecord::Migration[5.2]
+ def up
+ # Subsite Attributes
+ subsite_attributes = {
+ name: 'AT&T',
+ subdomain: 'att',
+ branches: false,
+ accepts_programs: false,
+ accepts_partners: false
+ }
+
+ # Admin users
+ admins = ['susie+att_admin@ckdtech.co,
+ alex+att_admin@ckdtech.co,
+ tom+att_admin@ckdtech.co']
+
+ # Create the subdomain organization
+ subsite = Organization.create!(subsite_attributes)
+
+ # Invite Admins
+ admins.each do |email|
+ AdminInvitationService.invite(email: email, organization: subsite)
+ end
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/db/data_schema.rb b/db/data_schema.rb
index 1c11c4c2..7600fc90 100644
--- a/db/data_schema.rb
+++ b/db/data_schema.rb
@@ -1,3 +1,2 @@
-# frozen_string_literal: true
-
-DataMigrate::Data.define(version: 20_210_209_193_144)
+# encoding: UTF-8
+DataMigrate::Data.define(version: 20210630052420)
diff --git a/db/migrate/20210726182520_add_use_subdomain_for_training_site_flag_to_organizations.rb b/db/migrate/20210726182520_add_use_subdomain_for_training_site_flag_to_organizations.rb
new file mode 100644
index 00000000..9bbbf877
--- /dev/null
+++ b/db/migrate/20210726182520_add_use_subdomain_for_training_site_flag_to_organizations.rb
@@ -0,0 +1,5 @@
+class AddUseSubdomainForTrainingSiteFlagToOrganizations < ActiveRecord::Migration[5.2]
+ def change
+ add_column :organizations, :use_subdomain_for_training_site, :boolean, default: false, null: false
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 20595284..32983739 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -595,7 +595,8 @@ CREATE TABLE public.organizations (
accepts_custom_branches boolean DEFAULT false,
login_required boolean DEFAULT true,
preferences jsonb DEFAULT '{}'::jsonb NOT NULL,
- accepts_partners boolean DEFAULT false
+ accepts_partners boolean DEFAULT false,
+ use_subdomain_for_training_site boolean DEFAULT false NOT NULL
);
@@ -1829,6 +1830,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200327172506'),
('20200327214039'),
('20200618155234'),
-('20200707133604');
+('20200707133604'),
+('20210726182520');
diff --git a/erd.pdf b/erd.pdf
index 8c4901af..7760b553 100644
Binary files a/erd.pdf and b/erd.pdf differ
diff --git a/spec/controllers/admin/lessons_controller_spec.rb b/spec/controllers/admin/lessons_controller_spec.rb
index 3eb617c3..c91b3bd7 100644
--- a/spec/controllers/admin/lessons_controller_spec.rb
+++ b/spec/controllers/admin/lessons_controller_spec.rb
@@ -195,4 +195,13 @@
expect(child_lesson2.reload.lesson_order).to eq(1)
end
end
+
+ describe 'DELETE #destroy_asl_attachment' do
+ let(:params) { { course_id: pla_course.id, lesson_id: lesson1.id } }
+
+ it 'should remove lesson upload' do
+ delete :destroy_asl_attachment, params: params
+ expect(lesson1.reload.story_line.exists?).to be_falsey
+ end
+ end
end
diff --git a/spec/features/admin/edit_course_spec.rb b/spec/features/admin/edit_course_spec.rb
index 41d59a3b..c5ffd5b0 100644
--- a/spec/features/admin/edit_course_spec.rb
+++ b/spec/features/admin/edit_course_spec.rb
@@ -90,7 +90,6 @@
expect(current_path).to eq(edit_admin_course_path(subsite_course))
expect(page).to have_content('Course was successfully updated.')
expect(page).to have_select('Publication Status', selected: 'Draft')
-
end
scenario 'selects existing category for course' do
diff --git a/spec/features/admin/edit_lesson_spec.rb b/spec/features/admin/edit_lesson_spec.rb
new file mode 100644
index 00000000..295e3100
--- /dev/null
+++ b/spec/features/admin/edit_lesson_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'feature_helper'
+
+feature 'Admin user updates lesson' do
+ let(:story_line) do
+ fixture_file_upload(Rails.root.join('spec', 'fixtures', 'BasicSearch1.zip'), 'application/zip')
+ end
+
+ let(:pla) { FactoryBot.create(:default_organization) }
+
+ let(:course) { FactoryBot.create(:course, organization: pla) }
+ let(:lesson) { FactoryBot.create(:lesson, course: course) }
+
+ let(:user) { FactoryBot.create(:user, :admin, organization: pla) }
+
+ before do
+ switch_to_subdomain(pla.subdomain)
+ log_in_with user.email, user.password
+ end
+
+ scenario 'can change lesson attachment', js: true do
+ visit edit_admin_course_lesson_path(course, lesson)
+ expect(page).to have_content('BasicSearch1.zip')
+ accept_confirm do
+ click_link 'Remove'
+ end
+ expect(page).not_to have_content('BasicSearch1.zip')
+ expect(page).to have_content('Story Line successfully removed, please upload a new story line .zip file.')
+
+ # Re-attach file
+ attach_file 'Articulate Storyline Package', Rails.root.join('spec', 'fixtures', 'BasicSearch1.zip')
+ click_button 'Save Lesson'
+
+ expect(current_path).to eq(edit_admin_course_lesson_path(course.to_param, Lesson.last.to_param))
+ expect(page).to have_content('Lesson successfully updated.')
+ end
+end
diff --git a/spec/features/admin/new_course_spec.rb b/spec/features/admin/new_course_spec.rb
index d6759a8f..c7825d81 100644
--- a/spec/features/admin/new_course_spec.rb
+++ b/spec/features/admin/new_course_spec.rb
@@ -100,7 +100,7 @@ def fill_basic_course_info
expect(page).to have_content('Why_Use_a_Computer_Worksheet.pdf')
end
- scenario 'adds a lesson' do
+ scenario 'adds a lesson', js: true do
visit edit_admin_course_path(course_id: course, id: course.id)
click_button 'Save & Edit Lessons'
expect(current_path).to eq(new_admin_course_lesson_path(course))
@@ -108,10 +108,13 @@ def fill_basic_course_info
fill_in :lesson_summary, with: 'Summary for new lesson'
fill_in :lesson_duration, with: '05:15'
attach_file 'Articulate Storyline Package', Rails.root.join('spec', 'fixtures', 'BasicSearch1.zip')
+
click_button 'Save Lesson'
expect(page).to have_content('Lesson was successfully created.')
expect(current_path).to eq(edit_admin_course_lesson_path(course.to_param, Lesson.last.to_param))
+ expect(page).to have_content 'BasicSearch1.zip'
+
click_link 'Add Another Lesson'
expect(current_path).to eq(new_admin_course_lesson_path(course.to_param))
end
diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb
index 47cb21a0..8bc59c86 100644
--- a/spec/models/organization_spec.rb
+++ b/spec/models/organization_spec.rb
@@ -89,4 +89,15 @@
expect(Organization.pla).to eq(pla)
end
end
+
+ describe '#training_site_link' do
+ it 'returns main training site by default' do
+ expect(org.training_site_link).to eq('https://training.test.org')
+ end
+
+ it 'returns subsite link if configured' do
+ org.update(use_subdomain_for_training_site: true)
+ expect(org.training_site_link).to eq("https://training.#{org.subdomain}.test.org")
+ end
+ end
end