diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 98483bb64..b48488fb8 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -159,16 +159,24 @@ class OrganizationsController < ApplicationController end def teachers + unless @organization.allow_set_teachers + render_403 + return + end q = params[:search].nil? ? "" : "#{params[:search].strip}" - if params[:type] == "courses" || params[:type].nil? + @type = params[:type] + if @type == "courses" || @type.nil? @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "students" + elsif @type == "students" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") - elsif params[:type] == "resources" + elsif @type == "resources" @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif @type == "famous" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") end limit = 10 # @is_remote = true diff --git a/app/views/organizations/_org_subfield_rightM2.html.erb b/app/views/organizations/_org_subfield_rightM2.html.erb index 5c82e52dc..86b69ac05 100644 --- a/app/views/organizations/_org_subfield_rightM2.html.erb +++ b/app/views/organizations/_org_subfield_rightM2.html.erb @@ -1,5 +1,7 @@
-

名师风采更多

+

<%= field.name %> + <%= link_to "更多", teachers_organization_path(@organization, :type => "famous"), :target => "_blank", :class => "more" %> +

<% excellent_teachers.each do |teacher| %>
<%= link_to image_tag(url_to_avatar(teacher), :width => "60", :height => "60", :class => "sn-fl", :style => "display:block;"), user_path(teacher), :alt => "用户头像", :target => '_blank' %> @@ -25,4 +27,4 @@ \ No newline at end of file + diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb index 3f8f5af8e..f2523fb9f 100644 --- a/app/views/organizations/_org_teachers_list.html.erb +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -1,4 +1,4 @@ -<% @org_teachers.each do |org_teacher| %> +<% org_teachers.each do |org_teacher| %> <% school = School.where("id =?", org_teacher.school_id).first %>
@@ -6,7 +6,7 @@ <%= link_to image_tag(url_to_avatar(org_teacher), :width => "90", :height => "90"), user_url_in_org(org_teacher), :alt => "用户头像" %>
-
<%= org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname) %> +
<%=link_to org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname), user_url_in_org(org_teacher) %> <% unless school.nil? %> <%= school.name %> <% end %> @@ -19,7 +19,7 @@
-
<%= org_teacher.my_students %>500
+
<%= org_teacher.my_students %>
学生数
@@ -28,12 +28,15 @@
资源数
- <% if User.current.admin? %> + <% if User.current.admin_of_org?(@organization) %> <%= org_teacher.excellent_teacher==0?"设为名师":"取消设置" %> <% else %> - <%= render :partial => 'layouts/user_watch_btn', :locals => {:target => org_teacher} %> - 关注 + + + + + <% end %>
diff --git a/app/views/organizations/teachers.html.erb b/app/views/organizations/teachers.html.erb index 062130336..4b50a2a81 100644 --- a/app/views/organizations/teachers.html.erb +++ b/app/views/organizations/teachers.html.erb @@ -2,8 +2,8 @@
名师榜
-
- <%= form_tag( url_for(:controller => 'organizations', :action => 'teachers'), + diff --git a/app/views/organizations/teachers.js.erb b/app/views/organizations/teachers.js.erb index c2920716c..cd7323a4a 100644 --- a/app/views/organizations/teachers.js.erb +++ b/app/views/organizations/teachers.js.erb @@ -1,2 +1,3 @@ -$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list')%>'); -$("#pages").html('<%= pagination_links_full @atta_pages, @teachers_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file +$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list', :locals => {:org_teachers => @org_teachers})%>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @teachers_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +$("#org_teacher_search").attr('href','<%= teachers_organization_path(@organization, :type => @type) %>'); \ No newline at end of file