mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
show all categories on school page
This commit is contained in:
parent
a0e634c993
commit
9ff4cf0d10
2 changed files with 17 additions and 2 deletions
|
|
@ -11,9 +11,16 @@ class SchoolsController < ApplicationController
|
|||
authenticate(district.name.downcase, "#{district.name.downcase}!")
|
||||
|
||||
@school_categories = @school.school_categories.for_parent_category(@school, nil).valid.sort
|
||||
|
||||
@years = @school_categories.map(&:year).map(&:to_i).sort.uniq
|
||||
@year = (params[:year] || @years.last).to_i
|
||||
@year = (params[:year] || @years.last || "2018").to_i
|
||||
@years.delete(@year)
|
||||
|
||||
missing_categories = Category.root - @school_categories.map(&:category)
|
||||
missing_categories.each do |category|
|
||||
@school_categories << category.school_categories.new(school: @school, year: @year)
|
||||
end
|
||||
|
||||
@school_categories = @school_categories.select { |sc| sc.year.to_i == @year }
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ class Category < ApplicationRecord
|
|||
end
|
||||
|
||||
def root_index
|
||||
Category.root_identifiers.index(root_identifier) || 0
|
||||
end
|
||||
|
||||
def self.root_identifiers
|
||||
[
|
||||
"teachers-and-the-teaching-environment",
|
||||
"school-culture",
|
||||
|
|
@ -32,7 +36,11 @@ class Category < ApplicationRecord
|
|||
"academic-learning",
|
||||
"community-and-wellbeing",
|
||||
"pilot-family-questions"
|
||||
].index(root_identifier) || 0
|
||||
]
|
||||
end
|
||||
|
||||
def self.root
|
||||
Category.where(parent_category: nil).select { |c| self.root_identifiers.index(c.slug) }
|
||||
end
|
||||
|
||||
def custom_zones
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue