Merge branch 'hjq_beidou' of https://git.trustie.net/jacknudt/trustieforge into hjq_beidou

This commit is contained in:
Tim 2016-05-13 16:11:35 +08:00
commit afbe5317cb
5 changed files with 30 additions and 16 deletions

View File

@ -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

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' %>
@ -25,4 +27,4 @@
<script>
$(".sn-teacher-list:last").addClass("sn-border-none");
</script>
</script>

View File

@ -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 %>
<div class="teacher-list-row">
<div>
@ -6,7 +6,7 @@
<%= link_to image_tag(url_to_avatar(org_teacher), :width => "90", :height => "90"), user_url_in_org(org_teacher), :alt => "用户头像" %>
</div>
<div class="fl">
<div class="ml25 mb20"><span class="teacher-name"><%= org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname) %></span>
<div class="ml25 mb20"><span class="teacher-name"><%=link_to org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname), user_url_in_org(org_teacher) %></span>
<% unless school.nil? %>
<span class="f12 fontGrey2 mr15"><%= school.name %></span>
<% end %>
@ -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>
@ -28,12 +28,15 @@
<div class="block-title">资源数</div>
</div>
</div>
<% if User.current.admin? %>
<% if User.current.admin_of_org?(@organization) %>
<a href="javascript:void(0);" class="fr teacher-select" onclick="hide($(this),'<%= org_teacher.id %>');" id="hide_<%= org_teacher.id %>"><%= org_teacher.excellent_teacher==0?"设为名师":"取消设置" %></a>
<!--<a href="javascript:void(0);" class="fr teacher-select">设为名师</a>-->
<% else %>
<%= render :partial => 'layouts/user_watch_btn', :locals => {:target => org_teacher} %>
<a href="javascript:void(0);" class="fr teacher-select">关注</a>
<!--<%# if(org_teacher.watched_by?(User.current)) %>-->
<!--<%#= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>org_teacher.id,:target_id=>org_teacher.id),:class => "fr teacher-select", :method => "delete",:remote => "true", :title => "取消关注"%>-->
<!--<%# else %>-->
<!--<%#= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>org_teacher.id,:target_id=>org_teacher.id),:class => "fr teacher-select", :method => "post",:remote => "true", :title => "添加关注"%>-->
<!--<%# end %>-->
<% end %>
</div>
<div class="cl"></div>

View File

@ -2,8 +2,8 @@
<div class="f16 fontGrey3">名师榜</div>
</div>
<div class="resources mt10">
<div class="function-row">
<%= form_tag( url_for(:controller => 'organizations', :action => 'teachers'),
<div class="function-row" id="org_teacher_search">
<%= form_tag( url_for(:controller => 'organizations', :action => 'teachers', :type => @type),
:remote => true , :method => 'get', :id => 'resource_search_form') do %>
<input type="text" name="search" placeholder="输入教师名进行搜索" class="teacher-list-search fl" />
<%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :class => "teacher-search-icon fl" %>
@ -18,7 +18,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>

View File

@ -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 %>');
$("#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) %>');