|
|
|
@ -1,8 +1,11 @@
|
|
|
|
|
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(id: [117, 179, 3181, 3216])
|
|
|
|
|
@schools = School.where(customer_id: @partner.customer_ids)
|
|
|
|
|
@all_count = @schools.size
|
|
|
|
|
|
|
|
|
|
unless search.blank?
|
|
|
|
@ -17,4 +20,17 @@ class CooperatesController < ApplicationController
|
|
|
|
|
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
|
|
|
|
|