mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-07 21:38:14 -08:00
chore: seed academic years, districts and schools
This commit is contained in:
parent
30f9f05a63
commit
cd7b05df73
94 changed files with 697970 additions and 14 deletions
|
|
@ -5,7 +5,7 @@ module Dashboard
|
|||
|
||||
scope :sorted, -> { order(:category_id) }
|
||||
|
||||
has_many :subcategories
|
||||
has_many :subcategories, class_name: "Subcategory", foreign_key: :dashboard_category_id
|
||||
has_many :measures, through: :subcategories
|
||||
has_many :admin_data_items, through: :measures
|
||||
has_many :scales, through: :subcategories
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module Dashboard
|
||||
class District < ApplicationRecord
|
||||
has_many :schools, class_name: "School", foreign_key: :id
|
||||
has_many :schools, class_name: "School", foreign_key: :dashboard_district_id
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
module Dashboard
|
||||
class Respondent < ApplicationRecord
|
||||
belongs_to :school
|
||||
belongs_to :dashboard_academic_year
|
||||
belongs_to :school, class_name: "School", foreign_key: :dashboard_school_id
|
||||
belongs_to :academic_year, class_name: "AcademicYear", foreign_key: :dashboard_academic_year_id
|
||||
|
||||
validates :school, uniqueness: { scope: :academic_year }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
module Dashboard
|
||||
class School < ApplicationRecord
|
||||
include FriendlyId
|
||||
friendly_id :name, use: :slugged
|
||||
|
||||
belongs_to :district, class_name: "District", foreign_key: :dashboard_district_id
|
||||
|
||||
# has_many :dashboard_survey_item_responses, dependent: :delete_all
|
||||
|
|
@ -9,9 +12,6 @@ module Dashboard
|
|||
scope :alphabetic, -> { order(name: :asc) }
|
||||
scope :school_hash, -> { all.map { |school| [school.dese_id, school] }.to_h }
|
||||
|
||||
include FriendlyId
|
||||
friendly_id :name, use: [:slugged]
|
||||
|
||||
def self.find_by_district_code_and_school_code(district_code, school_code)
|
||||
School
|
||||
.joins(:district)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
module Dashboard
|
||||
class Subcategory < ApplicationRecord
|
||||
belongs_to :dashboard_categories, class_name: "Dashboard::Category"
|
||||
belongs_to :category, class_name: "Category", foreign_key: :dashboard_category_id
|
||||
|
||||
has_many :dashboard_measures
|
||||
has_many :dashboard_survey_items, through: :dashboard_measures
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue