app/controllers/class_lists_controller.rb
# For showing the list of all workspaces that the user can read
For showing the list of all workspaces that the user can read
For showing the list of all workspaces that the user can read
def workspaces_json
    workspaces = queries.all_authorized_workspaces
    workspaces_json = workspaces.map do |workspace|
      {
        workspace_id: workspace.workspace_id,
        revisions_count: workspace.revisions_count,
        class_list: workspace.class_list.as_json({
          only: [
            :id,
            :workspace_id,
            :grade_level_next_year,
            :created_at,
            :updated_at,
            :submitted
          ],
          include: {
            created_by_teacher_educator: {
              only: [:id, :email, :full_name]
            },
            revised_by_principal_educator: {
              only: [:id, :email, :full_name]
            },
            school: {
              only: [:id, :name]
            }
          }
        })
      }
    end
    render json: {
      workspaces: workspaces_json
    }
  end
def workspaces_json workspaces = queries . all_authorized_workspaces workspaces_json = workspaces . map do | workspace | { workspace_id : workspace . workspace_id , revisions_count : workspace . revisions_count , class_list : workspace . class_list . as_json ( { only : [ :id , :workspace_id , :grade_level_next_year , :created_at , :updated_at , :submitted ] , include : { created_by_teacher_educator : { only : [ :id , :email , :full_name ] } , revised_by_principal_educator : { only : [ :id , :email , :full_name ] } , school : { only : [ :id , :name ] } } } ) } end render json : { workspaces : workspaces_json } end
For showing the list of all workspaces that the user can read
For showing the list of all workspaces that the user can read