Move legacy layouts into a legacy folder

pull/1/head
Liam Morley 4 years ago
parent 6477792f1d
commit 557109662c

@ -1,25 +1,12 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, prepend: true
before_action :set_google_analytics_id 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 def set_google_analytics_id
@google_analytics_id = ENV['GOOGLE_ANALYTICS_ID'] @google_analytics_id = ENV['GOOGLE_ANALYTICS_ID']
end end
def set_hotjar_id
@hotjar_id = ENV['HOTJAR_ID']
end
end end

@ -1,21 +1,8 @@
class HomeController < ActionController::Base class HomeController < ApplicationController
before_action :set_google_analytics_id
before_action :set_hotjar_id
def index def index
@districts = District.all.order(:name) @districts = District.all.order(:name)
@schools = School.all @schools = School.all
@categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) } @categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) }
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 end

@ -1,5 +1,5 @@
module Legacy module Legacy
class AdminController < ApplicationController class AdminController < Legacy::ApplicationController
def index def index
end end

@ -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

@ -1,5 +1,5 @@
module Legacy module Legacy
class AttemptsController < ApplicationController class AttemptsController < Legacy::ApplicationController
# before_action :set_attempt, only: [:edit, :update] # before_action :set_attempt, only: [:edit, :update]
protect_from_forgery :except => [:twilio] protect_from_forgery :except => [:twilio]

@ -1,5 +1,5 @@
module Legacy module Legacy
class CategoriesController < ApplicationController class CategoriesController < Legacy::ApplicationController
before_action :set_school, only: [:show] before_action :set_school, only: [:show]
before_action :set_category, only: [:show, :edit, :update, :destroy] before_action :set_category, only: [:show, :edit, :update, :destroy]

@ -1,5 +1,5 @@
module Legacy module Legacy
class DistrictsController < ApplicationController class DistrictsController < Legacy::ApplicationController
before_action :set_district, only: [:show, :edit, :update, :destroy] before_action :set_district, only: [:show, :edit, :update, :destroy]
# GET /districts # GET /districts

@ -1,5 +1,5 @@
module Legacy module Legacy
class QuestionListsController < ApplicationController class QuestionListsController < Legacy::ApplicationController
before_action :set_question_list, only: [:show, :edit, :update, :destroy] before_action :set_question_list, only: [:show, :edit, :update, :destroy]
# GET /question_lists # GET /question_lists

@ -1,5 +1,5 @@
module Legacy module Legacy
class QuestionsController < ApplicationController class QuestionsController < Legacy::ApplicationController
before_action :authenticate_user!, except: [:show] before_action :authenticate_user!, except: [:show]
before_action :verify_super_admin, except: [:show] before_action :verify_super_admin, except: [:show]
before_action :set_school, only: [:show] before_action :set_school, only: [:show]

@ -1,5 +1,5 @@
module Legacy module Legacy
class RecipientListsController < ApplicationController class RecipientListsController < Legacy::ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_school before_action :set_school
before_action :verify_admin before_action :verify_admin

@ -1,5 +1,5 @@
module Legacy module Legacy
class RecipientsController < ApplicationController class RecipientsController < Legacy::ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_school before_action :set_school
before_action :verify_admin before_action :verify_admin

@ -1,5 +1,5 @@
module Legacy module Legacy
class SchedulesController < ApplicationController class SchedulesController < Legacy::ApplicationController
before_action :authenticate_user!, except: [:show] before_action :authenticate_user!, except: [:show]
before_action :set_school before_action :set_school
before_action :verify_admin before_action :verify_admin

@ -1,5 +1,5 @@
module Legacy module Legacy
class SchoolsController < ApplicationController class SchoolsController < Legacy::ApplicationController
before_action :authenticate_user!, except: [:show] before_action :authenticate_user!, except: [:show]
before_action :set_school, only: [:admin, :show, :edit, :update, :destroy] before_action :set_school, only: [:admin, :show, :edit, :update, :destroy]
before_action :verify_admin, except: [:show, :create, :new] before_action :verify_admin, except: [:show, :create, :new]

@ -1,5 +1,5 @@
module Legacy module Legacy
class UsersController < ApplicationController class UsersController < Legacy::ApplicationController
def show; end def show; end
# private # private

@ -1,5 +1,5 @@
module Legacy module Legacy
class WelcomeController < ApplicationController class WelcomeController < Legacy::ApplicationController
def index def index
@districts = Legacy::District.all.alphabetic @districts = Legacy::District.all.alphabetic

@ -1,10 +1,7 @@
class SqmApplicationController < ActionController::Base class SqmApplicationController < ApplicationController
protect_from_forgery with: :exception, prepend: true protect_from_forgery with: :exception, prepend: true
layout "sqm/application"
before_action :set_schools_and_districts before_action :set_schools_and_districts
before_action :authenticate_district before_action :authenticate_district
before_action :set_google_analytics_id
before_action :set_hotjar_id
private private
@ -35,12 +32,4 @@ class SqmApplicationController < ActionController::Base
u == username && p == password u == username && p == password
end end
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 end

@ -16,7 +16,7 @@
<body> <body>
<div> <div>
<%= render partial: 'layouts/sqm/header' %> <%= render partial: 'layouts/header' %>
</div> </div>
<div class="bg-color-light-blue"> <div class="bg-color-light-blue">
@ -30,10 +30,10 @@
</div> </div>
<div> <div>
<%= render partial: 'layouts/sqm/footer' %> <%= render partial: 'layouts/footer' %>
</div> </div>
<%= render partial: 'layouts/sqm/empty_dataset_modal' if @has_empty_dataset %> <%= render partial: 'layouts/empty_dataset_modal' if @has_empty_dataset %>
</body> </body>
</html> </html>

@ -24,7 +24,7 @@
<%= yield %> <%= yield %>
<div> <div>
<%= render partial: 'layouts/sqm/footer' %> <%= render partial: 'layouts/footer' %>
</div> </div>
<script> <script>

@ -25,7 +25,7 @@
.container .container
.row .row
.col-12 .col-12
= render partial: 'layouts/header' = render partial: 'layouts/legacy/header'
- if notice.present? - if notice.present?
%p.notice= notice %p.notice= notice

@ -1,6 +1,6 @@
- valid = @school_category.school.district.name != "Boston" || (((@school_category.valid_child_count || 1) > 0) && (@school_category.category.benchmark.blank?)) - valid = @school_category.school.district.name != "Boston" || (((@school_category.valid_child_count || 1) > 0) && (@school_category.category.benchmark.blank?))
= render 'layouts/school_header' = render 'layouts/legacy/school_header'
- if @school_category.school.district.name != "Boston" - if @school_category.school.district.name != "Boston"
.row .row

@ -1,4 +1,4 @@
= render 'layouts/school_header' = render 'layouts/legacy/school_header'
- if @school_categories.blank? - if @school_categories.blank?
.row.pt-3.mt-3 &nbsp; .row.pt-3.mt-3 &nbsp;

Loading…
Cancel
Save