完成模式6

This commit is contained in:
huang 2016-05-31 16:03:48 +08:00
parent bb7204846f
commit 8d56d8556f
3 changed files with 85 additions and 106 deletions

View File

@ -42,6 +42,11 @@ module OrganizationsHelper
Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
end
# 获取两种类型的隐藏状态数量大于0说明是可见
def double_field_show org
OrgSubfield.find_by_sql("SELECT * FROM `org_subfields` where organization_id = #{org.id} and (field_type = 'Compstu' or field_type = 'Comptec') and hide = 0;").count
end
def get_attach_org2(field)
org_attachments = field.attachments
attachments = User.current.admin? ? org_attachments.first(5) : visable_attachemnts(org_attachments).first(5)
@ -189,4 +194,17 @@ module OrganizationsHelper
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 order by course_count desc").first(5)
end
def excellent_students
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 = 1 and u.excellent_student = 1 order by course_count desc").first(5)
end
def excellent_teachers_hide? org
org.org_subfields.where(:field_type => "Comptec").first.hide
end
def excellent_students_hide? org
org.org_subfields.where(:field_type => "Compstu").first.hide
end
end

View File

@ -1,7 +1,7 @@
<% if field.field_type == "Resource" %>
<div class="por_teachers" style="display:<%= field.hide == 0?'block':'none' %>;">
<h2 class="por_h2_index clear"><%= field.name %><%= link_to "更多", org_subfield_files_path(field), :target => "_blank", :class => "por_more_index fr" %></h2>
<div id="por_teachers_content_1" >
<div class="por_teachers" style="display:<%= field.hide == 0 ? 'block' : 'none' %>;">
<h2 class="por_h2_index clear"><%= field.name %><%= link_to "更多>", org_subfield_files_path(field), :target => "_blank", :class => "por_more_index fr" %></h2>
<div>
<ul class="por_teachers_li">
<% get_attach_org2(field).each do |attach| %>
<li >
@ -26,121 +26,80 @@
<% end %>
</ul>
</div>
<div id="por_teachers_content_2" class="undis">
<ul class="por_teachers_li">
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华张晓华张晓华张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学学技术大学学技术大学学技术大学学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
</ul>
</div>
</div>
<% else %>
<% elsif field.field_type == "Comptec" || field.field_type == "Compstu" %>
<div class="por_teachers">
<ul id="por_teachers_nav">
<li id="por_teachers_nav_1" class="por_teachers_hover" onclick="HoverLi(1);">
<a href="javascript:void(0);" class="por_teachers_type" >名师风采</a>
<a href="javascript:void(0);" class="por_teachers_type">名师风采</a>
</li>
<li id="por_teachers_nav_2" onclick="HoverLi(2);">
<a href="javascript:void(0);" class="por_teachers_type" >学生英雄榜</a>
<a href="javascript:void(0);" class="por_teachers_type">学生英雄榜</a>
</li>
<a href="javascript:void(0);" target="_blank" class="por_more_index fr mt5">更多></a>
<!--<a href="javascript:void(0);" target="_blank" class="por_more_index fr mt5">更多></a>-->
<div class="cl"></div>
</ul>
<div id="por_teachers_content_1" >
<div id="por_teachers_content_1">
<ul class="por_teachers_li">
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华张晓华张晓华张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学学技术大学学技术大学学技术大学学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<% excellent_teachers.each do |teacher| %>
<li >
<%= link_to image_tag(url_to_avatar(teacher), :width => "43", :height => "43", :class => "por_teachers_img fl mr15"), user_path(teacher), :alt => "用户头像", :target => '_blank', :class => "fl" %>
<div class="por_teachers_txt fl mt5">
<%=link_to teacher.try(:realname) ? teacher.try(:realname) :teacher.try(:login), user_path(teacher), :class => "por_teachers_name fl", :target => '_blank' %>
<p class="por_teachers_p fr" title="<%= teacher.my_workplace %>"><%= teacher.my_workplace %></p>
<div class="cl"></div>
<p class="por_teachers_span ">
<% unless teacher.my_blogs_count == 0 %>
<span class=" mr10">博客 <%= teacher.my_blogs_count %></span>
<% end %>
<% unless teacher.courses.count == 0 %>
<span class="mr10">课程 <%= teacher.courses.count %></span>
<% end %>
<% unless teacher.my_students == 0 %>
<span class="mr10">学生 <%= teacher.my_students %></span>
<% end %>
</p>
</div>
<div class="cl"></div>
</li>
<% end %>
</ul>
</div>
<div id="por_teachers_content_2" class="undis">
<ul class="por_teachers_li">
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华张晓华张晓华张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学学技术大学学技术大学学技术大学学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<li >
<a href="javascript:void(0);" target="_blank" class="fl"><img src="/images/org_custom/homepageImage.jpg" width="43" height="43" alt="" class="por_teachers_img fl mr15"/></a>
<div class="por_teachers_txt fl mt5">
<a href="javascript:void(0);" target="_blank" class=" por_teachers_name fl"> 张晓华 </a>
<p class="por_teachers_p fr">国防科学技术大学</p>
<div class="cl"></div>
<p class="por_teachers_span "><span class=" mr10">博客<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10"> 课程<a href="javascript:void(0);" target="_blank" >20</a></span><span class="mr10">学生 <a href="javascript:void(0);" target="_blank" >20</a></span></p>
</div>
<div class="cl"></div>
</li>
<% excellent_students.each do |student| %>
<li >
<%= link_to image_tag(url_to_avatar(student), :width => "43", :height => "43", :class => "por_teachers_img fl mr15"), user_path(student), :alt => "用户头像", :target => '_blank', :class => "fl" %>
<div class="por_teachers_txt fl mt5">
<%=link_to student.try(:realname) ? student.try(:realname) :student.try(:login), user_path(student), :class => "por_teachers_name fl", :target => '_blank' %>
<p class="por_teachers_p fr" title="<%= student.my_workplace %>"><%= student.my_workplace %></p>
<div class="cl"></div>
<p class="por_teachers_span ">
<% unless student.my_blogs_count == 0 %>
<span class=" mr10">博客 <%= student.my_blogs_count %></span>
<% end %>
<% unless student.courses.count == 0 %>
<span class="mr10">课程 <%= student.courses.count %></span>
<% end %>
</p>
</div>
<div class="cl"></div>
</li>
<% end %>
</ul>
</div>
</div>
<script>
//名师列表
function g(o){return document.getElementById(o);}
function HoverLi(n){
for(var i=1;i<=2;i++){
g('por_teachers_nav_'+i).className='por_teachers_nomal';
g('por_teachers_content_'+i).className='undis';
}
g('por_teachers_content_'+n).className='dis';
g('por_teachers_nav_'+n).className='por_teachers_hover';
}
</script>
<% end %>

View File

@ -22,9 +22,11 @@
<% elsif field.status.to_i == 5 %>
<%= render :partial => 'organizations/org_custom_right2', :locals => {:field => field} %>
<% elsif field.status.to_i == 6 %>
<%= render :partial => 'organizations/org_custom_right3', :locals => {:field => field} %>
<%# elsif field.status.to_i == 23 %>
<%#= render :partial => 'organizations/org_subfield_rightM2', :locals => {:field => field} %>
<% if field.field_type == "Resource" %>
<%= render :partial => 'organizations/org_custom_right3', :locals => {:field => field} %>
<% else %> <%# 只允许显示一个模块 %>
<%= render :partial => 'organizations/org_custom_right3', :locals => {:field => field} %>
<% end %>
<% end %>
<% end %>
</div>