From 1be86721b0ef64fc66db4f9b3be5a95c0d84d46f Mon Sep 17 00:00:00 2001 From: Liam Morley Date: Wed, 17 Nov 2021 09:44:45 -0500 Subject: [PATCH] Always reference fully-qualified School/District/Category in controllers --- app/controllers/legacy/categories_controller.rb | 12 ++++++------ app/controllers/legacy/districts_controller.rb | 8 ++++---- app/controllers/legacy/questions_controller.rb | 2 +- app/controllers/legacy/recipient_lists_controller.rb | 2 +- app/controllers/legacy/recipients_controller.rb | 2 +- app/controllers/legacy/schedules_controller.rb | 2 +- app/controllers/legacy/schools_controller.rb | 10 +++++----- app/controllers/legacy/welcome_controller.rb | 4 ++-- app/views/legacy/districts/show.html.haml | 2 +- app/views/legacy/welcome/index.html.haml | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/controllers/legacy/categories_controller.rb b/app/controllers/legacy/categories_controller.rb index 0232652b..8a49ec0e 100644 --- a/app/controllers/legacy/categories_controller.rb +++ b/app/controllers/legacy/categories_controller.rb @@ -6,7 +6,7 @@ module Legacy # GET /categories # GET /categories.json def index - @categories = Category.all + @categories = Legacy::Category.all end # GET /categories/1 @@ -25,7 +25,7 @@ module Legacy @school_category = school_categories.select { |sc| sc.year.to_s == @year.to_s }.first @child_school_categories = SchoolCategory.for_parent_category(@school, @category).in(@year).valid.to_a - missing_categories = Category.for_parent(@category) - @child_school_categories.map(&:category) + missing_categories = Legacy::Category.for_parent(@category) - @child_school_categories.map(&:category) missing_categories.each do |category| next if category.benchmark.present? @child_school_categories << category.school_categories.new(school: @school) @@ -40,7 +40,7 @@ module Legacy # GET /categories/new def new - @category = Category.new + @category = Legacy::Category.new end # GET /categories/1/edit @@ -50,7 +50,7 @@ module Legacy # POST /categories # POST /categories.json def create - @category = Category.new(category_params) + @category = Legacy::Category.new(category_params) respond_to do |format| if @category.save @@ -91,12 +91,12 @@ module Legacy def set_school redirect_to root_path and return false unless params.include?(:school_id) - @school = School.friendly.find(params[:school_id]) + @school = Legacy::School.friendly.find(params[:school_id]) redirect_to root_path and return false if @school.nil? end def set_category - @category = Category.friendly.find(params[:id]) + @category = Legacy::Category.friendly.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/legacy/districts_controller.rb b/app/controllers/legacy/districts_controller.rb index e4c988b6..d900f039 100644 --- a/app/controllers/legacy/districts_controller.rb +++ b/app/controllers/legacy/districts_controller.rb @@ -5,7 +5,7 @@ module Legacy # GET /districts # GET /districts.json def index - @districts = District.all.alphabetic + @districts = Legacy::District.all.alphabetic end # GET /districts/1 @@ -17,7 +17,7 @@ module Legacy # GET /districts/new def new - @district = District.new + @district = Legacy::District.new end # GET /districts/1/edit @@ -27,7 +27,7 @@ module Legacy # POST /districts # POST /districts.json def create - @district = District.new(district_params) + @district = Legacy::District.new(district_params) respond_to do |format| if @district.save @@ -68,7 +68,7 @@ module Legacy # Use callbacks to share common setup or constraints between actions. def set_district - @district = District.find_by_slug(params[:id]) + @district = Legacy::District.find_by_slug(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/legacy/questions_controller.rb b/app/controllers/legacy/questions_controller.rb index c7b369ff..e479591b 100644 --- a/app/controllers/legacy/questions_controller.rb +++ b/app/controllers/legacy/questions_controller.rb @@ -69,7 +69,7 @@ module Legacy def set_school redirect_to root_path and return false unless params.include?(:school_id) - @school = School.friendly.find(params[:school_id]) + @school = Legacy::School.friendly.find(params[:school_id]) redirect_to root_path and return false if @school.nil? end diff --git a/app/controllers/legacy/recipient_lists_controller.rb b/app/controllers/legacy/recipient_lists_controller.rb index e8b8969e..1c50a2ec 100644 --- a/app/controllers/legacy/recipient_lists_controller.rb +++ b/app/controllers/legacy/recipient_lists_controller.rb @@ -54,7 +54,7 @@ module Legacy # Use callbacks to share common setup or constraints between actions. def set_school - @school = School.friendly.find(params[:school_id]) + @school = Legacy::School.friendly.find(params[:school_id]) end def set_recipient_list diff --git a/app/controllers/legacy/recipients_controller.rb b/app/controllers/legacy/recipients_controller.rb index 1e864a9b..fa06b91f 100644 --- a/app/controllers/legacy/recipients_controller.rb +++ b/app/controllers/legacy/recipients_controller.rb @@ -76,7 +76,7 @@ module Legacy # Use callbacks to share common setup or constraints between actions. def set_school - @school = School.friendly.find(params[:school_id]) + @school = Legacy::School.friendly.find(params[:school_id]) end # Use callbacks to share common setup or constraints between actions. diff --git a/app/controllers/legacy/schedules_controller.rb b/app/controllers/legacy/schedules_controller.rb index 15b1d1dc..359a8248 100644 --- a/app/controllers/legacy/schedules_controller.rb +++ b/app/controllers/legacy/schedules_controller.rb @@ -50,7 +50,7 @@ module Legacy # Use callbacks to share common setup or constraints between actions. def set_school - @school = School.friendly.find(params[:school_id]) + @school = Legacy::School.friendly.find(params[:school_id]) end def set_schedule diff --git a/app/controllers/legacy/schools_controller.rb b/app/controllers/legacy/schools_controller.rb index e86deba8..28c35d18 100644 --- a/app/controllers/legacy/schools_controller.rb +++ b/app/controllers/legacy/schools_controller.rb @@ -14,10 +14,10 @@ module Legacy @year = (params[:year] || @years.last).to_i if @district.name == "Boston" - @categories = Category.joins(:questions) + @categories = Legacy::Category.joins(:questions) @school_categories = SchoolCategory.where(school: @school).where(category: @categories).in(@year).to_a else - @categories = Category.root + @categories = Legacy::Category.root @school_categories = @school.school_categories.for_parent_category(@school, nil).valid.in(@year).sort end @@ -34,7 +34,7 @@ module Legacy # GET /schools/new def new - @school = School.new + @school = Legacy::School.new end # GET /schools/1/edit @@ -44,7 +44,7 @@ module Legacy # POST /schools # POST /schools.json def create - @school = School.new(school_params) + @school = Legacy::School.new(school_params) respond_to do |format| if @school.save @@ -85,7 +85,7 @@ module Legacy # Use callbacks to share common setup or constraints between actions. def set_school - @school = School.friendly.find(params[:id] || params[:school_id]) + @school = Legacy::School.friendly.find(params[:id] || params[:school_id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/legacy/welcome_controller.rb b/app/controllers/legacy/welcome_controller.rb index 9fe15c62..3f6f72a3 100644 --- a/app/controllers/legacy/welcome_controller.rb +++ b/app/controllers/legacy/welcome_controller.rb @@ -2,8 +2,8 @@ module Legacy class WelcomeController < ApplicationController def index - @districts = District.all.alphabetic - @schools = School.all.alphabetic + @districts = Legacy::District.all.alphabetic + @schools = Legacy::School.all.alphabetic end end diff --git a/app/views/legacy/districts/show.html.haml b/app/views/legacy/districts/show.html.haml index a573eb49..f0836b54 100644 --- a/app/views/legacy/districts/show.html.haml +++ b/app/views/legacy/districts/show.html.haml @@ -1,7 +1,7 @@ - if user_signed_in? && current_user.super_admin? .row.super-admin .col-12 - %p= link_to "Create A New School In This District", new_district_school_path(@district) + %p= link_to "Create A New School In This District", new_legacy_district_legacy_school_path(@district) - if true || user_signed_in? diff --git a/app/views/legacy/welcome/index.html.haml b/app/views/legacy/welcome/index.html.haml index cffd65a6..ee32c88a 100644 --- a/app/views/legacy/welcome/index.html.haml +++ b/app/views/legacy/welcome/index.html.haml @@ -1,9 +1,9 @@ - if user_signed_in? && current_user.super_admin? .row.super-admin .col-12 - %p= link_to "Create A New District", new_district_path + %p= link_to "Create A New District", new_legacy_district_path - %p= link_to "Create A New School", new_school_path + %p= link_to "Create A New School", new_legacy_school_path - if true || user_signed_in?