名师更多列表

及相关入口路由
This commit is contained in:
huang 2016-05-13 14:23:36 +08:00
parent e90da9d812
commit 0feb1280fd
4 changed files with 12 additions and 3 deletions

View File

@ -159,6 +159,10 @@ 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?
@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
@ -169,6 +173,9 @@ class OrganizationsController < ApplicationController
elsif params[: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 params[: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

View File

@ -1,5 +1,7 @@
<div class="sn-teacher-wrap" style="display:<%= field.hide == 0?'block':'none' %>;">
<h2 class="h2-title sn-mb5">名师风采<a href="javascript:void(0);" target="_blank" class="more">更多</a></h2>
<h2 class="h2-title sn-mb5"><%= field.name %>
<%= link_to "更多", teachers_organization_path(@organization, :type => "famous"), :target => "_blank", :class => "more" %>
</h2>
<% excellent_teachers.each do |teacher| %>
<div class="sn-teacher-list">
<%= link_to image_tag(url_to_avatar(teacher), :width => "60", :height => "60", :class => "sn-fl", :style => "display:block;"), user_path(teacher), :alt => "用户头像", :target => '_blank' %>

View File

@ -19,7 +19,7 @@
</div>
<div class="block-slice"></div>
<div class="teacher-social-block">
<div class="block-num"><%= org_teacher.my_students %>500</div>
<div class="block-num"><%= org_teacher.my_students %></div>
<div class="block-title">学生数</div>
</div>
<div class="block-slice"></div>

View File

@ -15,7 +15,7 @@
<!--<option value="3">资源数</option>-->
<!--</select>-->
<div class="sn-font-grey fr">
<%= link_to "名师列表", teachers_organization_path(@organization), :class => "fontGrey" %>
<%= link_to "名师列表", teachers_organization_path(@organization, :type => "famous"), :class => "fontGrey" %>
</div>
<div class="cl"></div>
</div>