From 557109662c104d8f869f52a20a2f48baf799e9f1 Mon Sep 17 00:00:00 2001 From: Liam Morley Date: Wed, 1 Dec 2021 16:34:17 -0500 Subject: [PATCH] Move legacy layouts into a legacy folder --- app/controllers/application_controller.rb | 21 +++----------- app/controllers/home_controller.rb | 15 +--------- app/controllers/legacy/admin_controller.rb | 2 +- .../legacy/application_controller.rb | 29 +++++++++++++++++++ app/controllers/legacy/attempts_controller.rb | 2 +- .../legacy/categories_controller.rb | 2 +- .../legacy/districts_controller.rb | 2 +- .../legacy/question_lists_controller.rb | 2 +- .../legacy/questions_controller.rb | 2 +- .../legacy/recipient_lists_controller.rb | 2 +- .../legacy/recipients_controller.rb | 2 +- .../legacy/schedules_controller.rb | 2 +- app/controllers/legacy/schools_controller.rb | 2 +- app/controllers/legacy/users_controller.rb | 2 +- app/controllers/legacy/welcome_controller.rb | 2 +- app/controllers/sqm_application_controller.rb | 13 +-------- .../{sqm => }/_empty_dataset_modal.html.erb | 0 app/views/layouts/{sqm => }/_footer.html.erb | 0 app/views/layouts/{sqm => }/_header.html.erb | 0 .../layouts/{sqm => }/application.html.erb | 6 ++-- app/views/layouts/home.html.erb | 2 +- .../layouts/{ => legacy}/_header.html.haml | 0 .../{ => legacy}/_school_header.html.haml | 0 .../{ => legacy}/application.html.haml | 2 +- .../layouts/{ => legacy}/mailer.html.haml | 0 .../layouts/{ => legacy}/mailer.text.haml | 0 app/views/legacy/categories/show.html.haml | 2 +- app/views/legacy/schools/show.html.haml | 2 +- 28 files changed, 54 insertions(+), 62 deletions(-) create mode 100644 app/controllers/legacy/application_controller.rb rename app/views/layouts/{sqm => }/_empty_dataset_modal.html.erb (100%) rename app/views/layouts/{sqm => }/_footer.html.erb (100%) rename app/views/layouts/{sqm => }/_header.html.erb (100%) rename app/views/layouts/{sqm => }/application.html.erb (87%) rename app/views/layouts/{ => legacy}/_header.html.haml (100%) rename app/views/layouts/{ => legacy}/_school_header.html.haml (100%) rename app/views/layouts/{ => legacy}/application.html.haml (96%) rename app/views/layouts/{ => legacy}/mailer.html.haml (100%) rename app/views/layouts/{ => legacy}/mailer.text.haml (100%) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1c8be323..7414ec42 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,25 +1,12 @@ class ApplicationController < ActionController::Base - protect_from_forgery with: :exception, prepend: true before_action :set_google_analytics_id + before_action :set_hotjar_id - - def verify_admin - return true #if current_user.admin?(@school) - - redirect_to root_path, notice: 'You must be logged in as an admin of that school to access that page.' - return false - end - - def authenticate(username, password) - return true if username == "boston" - authenticate_or_request_with_http_basic do |u, p| - u == username && p == password - end - end - - private def set_google_analytics_id @google_analytics_id = ENV['GOOGLE_ANALYTICS_ID'] end + def set_hotjar_id + @hotjar_id = ENV['HOTJAR_ID'] + end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index f5ce4ac9..e1e72c3e 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,21 +1,8 @@ -class HomeController < ActionController::Base - before_action :set_google_analytics_id - before_action :set_hotjar_id - +class HomeController < ApplicationController def index @districts = District.all.order(:name) @schools = School.all @categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) } end - - private - - def set_google_analytics_id - @google_analytics_id = ENV['GOOGLE_ANALYTICS_ID'] - end - - def set_hotjar_id - @hotjar_id = ENV['HOTJAR_ID'] - end end diff --git a/app/controllers/legacy/admin_controller.rb b/app/controllers/legacy/admin_controller.rb index 4e7f572f..bd26b05e 100644 --- a/app/controllers/legacy/admin_controller.rb +++ b/app/controllers/legacy/admin_controller.rb @@ -1,5 +1,5 @@ module Legacy - class AdminController < ApplicationController + class AdminController < Legacy::ApplicationController def index end diff --git a/app/controllers/legacy/application_controller.rb b/app/controllers/legacy/application_controller.rb new file mode 100644 index 00000000..fa08bd9a --- /dev/null +++ b/app/controllers/legacy/application_controller.rb @@ -0,0 +1,29 @@ +module Legacy + class ApplicationController < ActionController::Base + protect_from_forgery with: :exception, prepend: true + before_action :set_google_analytics_id + + layout "legacy/application" + + def verify_admin + return true #if current_user.admin?(@school) + + redirect_to root_path, notice: 'You must be logged in as an admin of that school to access that page.' + return false + end + + def authenticate(username, password) + return true if username == "boston" + authenticate_or_request_with_http_basic do |u, p| + u == username && p == password + end + end + + private + + def set_google_analytics_id + @google_analytics_id = ENV['GOOGLE_ANALYTICS_ID'] + end + + end +end diff --git a/app/controllers/legacy/attempts_controller.rb b/app/controllers/legacy/attempts_controller.rb index 4a682e68..75481040 100644 --- a/app/controllers/legacy/attempts_controller.rb +++ b/app/controllers/legacy/attempts_controller.rb @@ -1,5 +1,5 @@ module Legacy - class AttemptsController < ApplicationController + class AttemptsController < Legacy::ApplicationController # before_action :set_attempt, only: [:edit, :update] protect_from_forgery :except => [:twilio] diff --git a/app/controllers/legacy/categories_controller.rb b/app/controllers/legacy/categories_controller.rb index 8a49ec0e..4af54115 100644 --- a/app/controllers/legacy/categories_controller.rb +++ b/app/controllers/legacy/categories_controller.rb @@ -1,5 +1,5 @@ module Legacy - class CategoriesController < ApplicationController + class CategoriesController < Legacy::ApplicationController before_action :set_school, only: [:show] before_action :set_category, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/legacy/districts_controller.rb b/app/controllers/legacy/districts_controller.rb index d900f039..4d8a5711 100644 --- a/app/controllers/legacy/districts_controller.rb +++ b/app/controllers/legacy/districts_controller.rb @@ -1,5 +1,5 @@ module Legacy - class DistrictsController < ApplicationController + class DistrictsController < Legacy::ApplicationController before_action :set_district, only: [:show, :edit, :update, :destroy] # GET /districts diff --git a/app/controllers/legacy/question_lists_controller.rb b/app/controllers/legacy/question_lists_controller.rb index 1d3914c8..b7efc71b 100644 --- a/app/controllers/legacy/question_lists_controller.rb +++ b/app/controllers/legacy/question_lists_controller.rb @@ -1,5 +1,5 @@ module Legacy - class QuestionListsController < ApplicationController + class QuestionListsController < Legacy::ApplicationController before_action :set_question_list, only: [:show, :edit, :update, :destroy] # GET /question_lists diff --git a/app/controllers/legacy/questions_controller.rb b/app/controllers/legacy/questions_controller.rb index e479591b..25aec47b 100644 --- a/app/controllers/legacy/questions_controller.rb +++ b/app/controllers/legacy/questions_controller.rb @@ -1,5 +1,5 @@ module Legacy - class QuestionsController < ApplicationController + class QuestionsController < Legacy::ApplicationController before_action :authenticate_user!, except: [:show] before_action :verify_super_admin, except: [:show] before_action :set_school, only: [:show] diff --git a/app/controllers/legacy/recipient_lists_controller.rb b/app/controllers/legacy/recipient_lists_controller.rb index 1c50a2ec..4887dabc 100644 --- a/app/controllers/legacy/recipient_lists_controller.rb +++ b/app/controllers/legacy/recipient_lists_controller.rb @@ -1,5 +1,5 @@ module Legacy - class RecipientListsController < ApplicationController + class RecipientListsController < Legacy::ApplicationController before_action :authenticate_user! before_action :set_school before_action :verify_admin diff --git a/app/controllers/legacy/recipients_controller.rb b/app/controllers/legacy/recipients_controller.rb index fa06b91f..15cd0655 100644 --- a/app/controllers/legacy/recipients_controller.rb +++ b/app/controllers/legacy/recipients_controller.rb @@ -1,5 +1,5 @@ module Legacy - class RecipientsController < ApplicationController + class RecipientsController < Legacy::ApplicationController before_action :authenticate_user! before_action :set_school before_action :verify_admin diff --git a/app/controllers/legacy/schedules_controller.rb b/app/controllers/legacy/schedules_controller.rb index 359a8248..10931695 100644 --- a/app/controllers/legacy/schedules_controller.rb +++ b/app/controllers/legacy/schedules_controller.rb @@ -1,5 +1,5 @@ module Legacy - class SchedulesController < ApplicationController + class SchedulesController < Legacy::ApplicationController before_action :authenticate_user!, except: [:show] before_action :set_school before_action :verify_admin diff --git a/app/controllers/legacy/schools_controller.rb b/app/controllers/legacy/schools_controller.rb index 28c35d18..05e4b83a 100644 --- a/app/controllers/legacy/schools_controller.rb +++ b/app/controllers/legacy/schools_controller.rb @@ -1,5 +1,5 @@ module Legacy - class SchoolsController < ApplicationController + class SchoolsController < Legacy::ApplicationController before_action :authenticate_user!, except: [:show] before_action :set_school, only: [:admin, :show, :edit, :update, :destroy] before_action :verify_admin, except: [:show, :create, :new] diff --git a/app/controllers/legacy/users_controller.rb b/app/controllers/legacy/users_controller.rb index 56dd2edf..4c80ea83 100644 --- a/app/controllers/legacy/users_controller.rb +++ b/app/controllers/legacy/users_controller.rb @@ -1,5 +1,5 @@ module Legacy - class UsersController < ApplicationController + class UsersController < Legacy::ApplicationController def show; end # private diff --git a/app/controllers/legacy/welcome_controller.rb b/app/controllers/legacy/welcome_controller.rb index 3f6f72a3..c064eecd 100644 --- a/app/controllers/legacy/welcome_controller.rb +++ b/app/controllers/legacy/welcome_controller.rb @@ -1,5 +1,5 @@ module Legacy - class WelcomeController < ApplicationController + class WelcomeController < Legacy::ApplicationController def index @districts = Legacy::District.all.alphabetic diff --git a/app/controllers/sqm_application_controller.rb b/app/controllers/sqm_application_controller.rb index cbede2e5..863829c8 100644 --- a/app/controllers/sqm_application_controller.rb +++ b/app/controllers/sqm_application_controller.rb @@ -1,10 +1,7 @@ -class SqmApplicationController < ActionController::Base +class SqmApplicationController < ApplicationController protect_from_forgery with: :exception, prepend: true - layout "sqm/application" before_action :set_schools_and_districts before_action :authenticate_district - before_action :set_google_analytics_id - before_action :set_hotjar_id private @@ -35,12 +32,4 @@ class SqmApplicationController < ActionController::Base u == username && p == password end end - - def set_google_analytics_id - @google_analytics_id = ENV['GOOGLE_ANALYTICS_ID'] - end - - def set_hotjar_id - @hotjar_id = ENV['HOTJAR_ID'] - end end diff --git a/app/views/layouts/sqm/_empty_dataset_modal.html.erb b/app/views/layouts/_empty_dataset_modal.html.erb similarity index 100% rename from app/views/layouts/sqm/_empty_dataset_modal.html.erb rename to app/views/layouts/_empty_dataset_modal.html.erb diff --git a/app/views/layouts/sqm/_footer.html.erb b/app/views/layouts/_footer.html.erb similarity index 100% rename from app/views/layouts/sqm/_footer.html.erb rename to app/views/layouts/_footer.html.erb diff --git a/app/views/layouts/sqm/_header.html.erb b/app/views/layouts/_header.html.erb similarity index 100% rename from app/views/layouts/sqm/_header.html.erb rename to app/views/layouts/_header.html.erb diff --git a/app/views/layouts/sqm/application.html.erb b/app/views/layouts/application.html.erb similarity index 87% rename from app/views/layouts/sqm/application.html.erb rename to app/views/layouts/application.html.erb index 331b4e6b..2c33ca5f 100644 --- a/app/views/layouts/sqm/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,7 +16,7 @@
- <%= render partial: 'layouts/sqm/header' %> + <%= render partial: 'layouts/header' %>
@@ -30,10 +30,10 @@
- <%= render partial: 'layouts/sqm/footer' %> + <%= render partial: 'layouts/footer' %>
-<%= render partial: 'layouts/sqm/empty_dataset_modal' if @has_empty_dataset %> +<%= render partial: 'layouts/empty_dataset_modal' if @has_empty_dataset %> diff --git a/app/views/layouts/home.html.erb b/app/views/layouts/home.html.erb index 0c24291e..26dc8a0e 100644 --- a/app/views/layouts/home.html.erb +++ b/app/views/layouts/home.html.erb @@ -24,7 +24,7 @@ <%= yield %>
- <%= render partial: 'layouts/sqm/footer' %> + <%= render partial: 'layouts/footer' %>