diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index cd3322283..4d704ba5f 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -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 diff --git a/app/views/organizations/_org_custom_right3.html.erb b/app/views/organizations/_org_custom_right3.html.erb index c29097400..34612a8ee 100644 --- a/app/views/organizations/_org_custom_right3.html.erb +++ b/app/views/organizations/_org_custom_right3.html.erb @@ -1,7 +1,7 @@ <% if field.field_type == "Resource" %> -
-

<%= field.name %><%= link_to "更多", org_subfield_files_path(field), :target => "_blank", :class => "por_more_index fr" %>

-
+
+

<%= field.name %><%= link_to "更多>", org_subfield_files_path(field), :target => "_blank", :class => "por_more_index fr" %>

+
    <% get_attach_org2(field).each do |attach| %>
  • @@ -26,121 +26,80 @@ <% end %>
-
- -
-<% else %> +<% elsif field.field_type == "Comptec" || field.field_type == "Compstu" %>
-
+
    -
  • - -
    - 张晓华张晓华张晓华张晓华 -

    国防科学技术大学学技术大学学技术大学学技术大学学技术大学

    -
    -

    博客20 课程20学生 20

    -
    -
    -
  • -
  • - -
    - 张晓华 -

    国防科学技术大学

    -
    -

    博客20 课程20学生 20

    -
    -
    -
  • -
  • - -
    - 张晓华 -

    国防科学技术大学

    -
    -

    博客20 课程20学生 20

    -
    -
    -
  • -
  • - -
    - 张晓华 -

    国防科学技术大学

    -
    -

    博客20 课程20学生 20

    -
    -
    -
  • -
  • - -
    - 张晓华 -

    国防科学技术大学

    -
    -

    博客20 课程20学生 20

    -
    -
    -
  • - + <% excellent_teachers.each do |teacher| %> +
  • + <%= 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" %> +
    + <%=link_to teacher.try(:realname) ? teacher.try(:realname) :teacher.try(:login), user_path(teacher), :class => "por_teachers_name fl", :target => '_blank' %> +

    <%= teacher.my_workplace %>

    +
    +

    + <% unless teacher.my_blogs_count == 0 %> + 博客 <%= teacher.my_blogs_count %> + <% end %> + <% unless teacher.courses.count == 0 %> + 课程 <%= teacher.courses.count %> + <% end %> + <% unless teacher.my_students == 0 %> + 学生 <%= teacher.my_students %> + <% end %> +

    +
    +
    +
  • + <% end %>
    -
  • - -
    - 张晓华张晓华张晓华张晓华 -

    国防科学技术大学学技术大学学技术大学学技术大学学技术大学

    -
    -

    博客20 课程20学生 20

    -
    -
    -
  • -
  • - -
    - 张晓华 -

    国防科学技术大学

    -
    -

    博客20 课程20学生 20

    -
    -
    -
  • + <% excellent_students.each do |student| %> +
  • + <%= 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" %> +
    + <%=link_to student.try(:realname) ? student.try(:realname) :student.try(:login), user_path(student), :class => "por_teachers_name fl", :target => '_blank' %> +

    <%= student.my_workplace %>

    +
    +

    + <% unless student.my_blogs_count == 0 %> + 博客 <%= student.my_blogs_count %> + <% end %> + <% unless student.courses.count == 0 %> + 课程 <%= student.courses.count %> + <% end %> +

    +
    +
    +
  • + <% end %>
+ + <% end %> diff --git a/app/views/organizations/_show_custom.html.erb b/app/views/organizations/_show_custom.html.erb index fbcc0c5f3..4d0d6470f 100644 --- a/app/views/organizations/_show_custom.html.erb +++ b/app/views/organizations/_show_custom.html.erb @@ -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 %>