mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-15 01:35:54 -07:00
chore: start adding overview page
This commit is contained in:
parent
1b0af124f7
commit
64b4d599c7
33 changed files with 783 additions and 199 deletions
44
app/controllers/dashboard/sqm_application_controller.rb
Normal file
44
app/controllers/dashboard/sqm_application_controller.rb
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Dashboard
|
||||
class SqmApplicationController < ApplicationController
|
||||
protect_from_forgery with: :exception, prepend: true
|
||||
before_action :set_schools_and_districts
|
||||
before_action :authenticate_district
|
||||
|
||||
helper HeaderHelper
|
||||
|
||||
private
|
||||
|
||||
def authenticate_district
|
||||
authenticate(district_name, "#{district_name}!")
|
||||
end
|
||||
|
||||
def district_name
|
||||
@district_name ||= @district.name.split(" ").first.downcase
|
||||
end
|
||||
|
||||
def set_schools_and_districts
|
||||
@district = District.find_by_slug district_slug
|
||||
@districts = District.all.order(:name)
|
||||
@school = School.find_by_slug(school_slug)
|
||||
@schools = School.includes([:district]).where(district: @district).order(:name)
|
||||
@academic_year = AcademicYear.find_by_range params[:year]
|
||||
@academic_years = AcademicYear.all.order(range: :desc)
|
||||
end
|
||||
|
||||
def district_slug
|
||||
params[:district_id]
|
||||
end
|
||||
|
||||
def school_slug
|
||||
params[:school_id]
|
||||
end
|
||||
|
||||
def authenticate(username, password)
|
||||
authenticate_or_request_with_http_basic do |u, p|
|
||||
u == username && p == password
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue