diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 2505a3bf..9f7b42e6 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -97,9 +97,12 @@ class CollegesController < ApplicationController shixun_ids = HomeworkCommonsShixuns.find_by_sql("SELECT hcs.shixun_id FROM homework_commons_shixuns hcs, homework_commons hc WHERE hc.course_id in (#{all_course_ids.map(&:id).join(',').strip == "" ? -1 : all_course_ids.map(&:id).join(',')}) AND hcs.homework_common_id = hc.id").map(&:shixun_id) - shixun_tags = TagRepertoire.find_by_sql("SELECT tr.`name`, COUNT(str.shixun_id) as shixun_count FROM tag_repertoires tr, shixun_tag_repertoires str WHERE tr.id = str.tag_repertoire_id AND str.shixun_id IN (#{shixun_ids.join(',').strip == "" ? -1 : shixun_ids.join(',')}) GROUP BY tr.id order by shixun_count desc") + shixun_tags = TagRepertoire.find_by_sql("SELECT tr.`name`, COUNT(str.shixun_id) as shixun_count FROM tag_repertoires tr, + shixun_tag_repertoires str WHERE tr.id = str.tag_repertoire_id AND str.shixun_id + IN (#{shixun_ids.join(',').strip == "" ? -1 : shixun_ids.join(',')}) GROUP BY tr.id + order by shixun_count desc") all_shixun_count = shixun_tags.map(&:shixun_count).sum - other_count = all_shixun_count - shixun_tags[0..8].map(&:shixun_count).sum + other_count = all_shixun_count.to_i - shixun_tags[0..8].map(&:shixun_count).sum.to_i @shixun_tags_name = [] @shixun_tags_data = [] shixun_tags[0..8].each do |tag| @@ -254,7 +257,7 @@ class CollegesController < ApplicationController def manager_auth # unless (User.current.admin? || DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present?) - unless (User.current.admin? || + unless (User.current.admin? || User.current.business? || DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present? || (User.current.user_extensions.try(:school_id) == @department.school_id && User.current.user_extensions.try(:identity) == 0) || (@department.school.try(:customer_id) && User.current.try(:partner).try(:customer_ids) && User.current.try(:partner).try(:customer_ids).include?(@department.school.try(:customer_id))))