You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
class CooperatesController < ApplicationController
|
|
|
|
before_filter :require_login
|
|
|
|
before_filter :find_partner, only: [:partner_list]
|
|
|
|
before_filter :is_admin, only: [:partner_list]
|
|
|
|
|
|
|
|
def partner_list
|
|
|
|
search = params[:search]
|
|
|
|
@schools = School.where(customer_id: @partner.customer_ids)
|
|
|
|
@all_count = @schools.size
|
|
|
|
|
|
|
|
unless search.blank?
|
|
|
|
@schools = @schools.where("name like ?", "%#{search}%")
|
|
|
|
end
|
|
|
|
@search_count = @schools.size
|
|
|
|
@schools = paginateHelper @schools, 15
|
|
|
|
@schools = @schools.includes(:courses, users: :user_extensions)
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
|
|
|
format.html{render :layout => "base_edu"}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_partner
|
|
|
|
@partner = Partner.find_by_id(params[:id])
|
|
|
|
render_404 if @partner.nil?
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_admin
|
|
|
|
unless User.current.admin? || (User.current.partner.present? && User.current.partner == @partner)
|
|
|
|
render_403
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|