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.
pgfqe6ch8/app/controllers/cooperates_controller.rb

37 lines
1011 B

class CooperatesController < ApplicationController
before_filter :require_login
before_filter :find_partner, only: [:partner_list]
before_filter :is_admin, only: [:partner_list]
6 years ago
def partner_list
search = params[:search]
@schools = School.where(customer_id: @partner.customer_ids)
6 years ago
@all_count = @schools.size
6 years ago
unless search.blank?
@schools = @schools.where("name like ?", "%#{search}%")
6 years ago
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? || @partner.status == -1
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