名师默认显示5个,没有则不显示

This commit is contained in:
huang 2016-05-13 15:37:04 +08:00
parent 41214bd762
commit 467ee60657
2 changed files with 33 additions and 30 deletions

View File

@ -183,7 +183,7 @@ module OrganizationsHelper
end
def excellent_teachers
User.where("excellent_teacher =?",true)
User.where("excellent_teacher =?",true).first(5)
end
end

View File

@ -1,30 +1,33 @@
<div class="sn-teacher-wrap" style="display:<%= field.hide == 0?'block':'none' %>;">
<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' %>
<!--<a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>-->
<div class="sn-teacher-info">
<%=link_to teacher.try(:realname) ? teacher.try(:realname) :teacher.try(:login), user_path(teacher), :class => "sn-teacher-name sn-hidden", :title => '', :target => '_blank' %></a>
<span class="sn-teacher-unit sn-hidden" title="<%= teacher.my_workplace %>"><%= teacher.my_workplace %></span> </div>
<div class="sn-teacher-social">
<% unless teacher.my_blogs_count == 0 %>
<span class="sn-mr20">博客 <%= teacher.my_blogs_count %></span>
<% end %>
<% unless teacher.courses.count == 0 %>
<span class="sn-mr20">课程 <%= teacher.courses.count %></span>
<% end %>
<% unless teacher.my_students == 0 %>
<span>学生 <%= teacher.my_students %></span>
<% end %>
</div>
<div class="sn-cl"></div>
</div>
<% end %>
</div>
<% unless excellent_teachers.count == 0 %>
<div class="sn-teacher-wrap" style="display:<%= field.hide == 0?'block':'none' %>;">
<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' %>
<!--<a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>-->
<div class="sn-teacher-info">
<%=link_to teacher.try(:realname) ? teacher.try(:realname) :teacher.try(:login), user_path(teacher), :class => "sn-teacher-name sn-hidden", :title => '', :target => '_blank' %></a>
<span class="sn-teacher-unit sn-hidden" title="<%= teacher.my_workplace %>"><%= teacher.my_workplace %></span> </div>
<div class="sn-teacher-social">
<% unless teacher.my_blogs_count == 0 %>
<span class="sn-mr20">博客 <%= teacher.my_blogs_count %></span>
<% end %>
<% unless teacher.courses.count == 0 %>
<span class="sn-mr20">课程 <%= teacher.courses.count %></span>
<% end %>
<% unless teacher.my_students == 0 %>
<span>学生 <%= teacher.my_students %></span>
<% end %>
</div>
<div class="sn-cl"></div>
</div>
<% end %>
</div>
<script>
$(".sn-teacher-list:last").addClass("sn-border-none");
</script>
<% end %>
<script>
$(".sn-teacher-list:last").addClass("sn-border-none");
</script>