diff --git a/app/controllers/cooperates_controller.rb b/app/controllers/cooperates_controller.rb index 09895193..8a014d62 100644 --- a/app/controllers/cooperates_controller.rb +++ b/app/controllers/cooperates_controller.rb @@ -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 diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 9c8f4a8d..9e07db32 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -52,6 +52,9 @@