app/controllers/class_lists_controller.rb
# Suggest the schools and grade levels that this educator will want to create.
# This isn't an authorization gate, more a helpful UI suggestion than anything else.
Suggest the schools and grade levels that this educator will want to create.
This isn't an authorization gate, more a helpful UI suggestion than anything else.
Suggest the schools and grade levels that this educator will want to create . This isn ' t an authorization gate more a helpful UI suggestion than anything else .
def available_grade_levels_json
    params.require(:workspace_id)
    school_ids = queries.supported_schools.map(&:id).select do |school_id|
      queries.is_authorized_for_school_id?(school_id)
    end
    schools_json = School.find(school_ids).as_json(only: [:id, :name])
    grade_levels_next_year = queries.supported_grade_levels_next_year.select do |grade_level_next_year|
      grade_level_now = GradeLevels.new.previous(grade_level_next_year)
      school_ids.any? {|school_id| queries.is_authorized_for_grade_level_now?(school_id, grade_level_now) }
    end
    render json: {
      schools: schools_json,
      grade_levels_next_year: grade_levels_next_year
    }
  end
def available_grade_levels_json params . require ( :workspace_id ) school_ids = queries . supported_schools . map ( & :id ) . select do | school_id | queries . is_authorized_for_school_id? ( school_id ) end schools_json = School . find ( school_ids ) . as_json ( only : [ :id , :name ] ) grade_levels_next_year = queries . supported_grade_levels_next_year . select do | grade_level_next_year | grade_level_now = GradeLevels . new . previous ( grade_level_next_year ) school_ids . any? { | school_id | queries . is_authorized_for_grade_level_now? ( school_id , grade_level_now ) } end render json : { schools : schools_json , grade_levels_next_year : grade_levels_next_year } end
Suggest the schools and grade levels that this educator will want to create.
Suggest the schools and grade levels that this educator will want to create .
# schools # grade levels (include if any of their schools would allow it)