diff --git a/app/models/user.rb b/app/models/user.rb index 3386836ed..ed17010c6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -431,6 +431,12 @@ class User < Principal name = lastname + firstname name.empty? || name.nil? ? login : name end + + def show_occupation + if self.user_extensions && self.user_extensions.school + self.user_extensions.school.name + end + end ## end def get_at_show_name diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index 69ee1756b..4d3cc393d 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -16,11 +16,12 @@
<%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><%= get_user_identity(User.find(item.id).user_extensions.identity) %>
-
  • <%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
  • + <% user = User.find(item.id)%> +
  • <%= user.user_extensions && user.user_extensions.brief_introduction.present? ? user.user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
  • - 加入时间:<%= format_date( User.find(item.id).created_on)%> - 最后登录时间:<%= format_date( User.find(item.id).last_login_on)%> - <%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%>
  • + 加入时间:<%= format_date( user.created_on)%> + 最后登录时间:<%= format_date( user.last_login_on)%> + <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
    @@ -29,13 +30,15 @@ <% when 'course'%> @@ -51,10 +54,11 @@
  • <%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %>
  • - 教师:<%= User.find(item.tea_id).realname %> + <% user = User.find(item.tea_id)%> + 教师:<%= user.realname %> 授课时间:<%= item.time.to_s + item.term%> 更新时间:<%= format_date(item.updated_at)%> - <%= User.find(item.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(item.tea_id).user_extensions.occupation : ''%>
  • + <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
    @@ -69,7 +73,8 @@
    <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>资源
    -
  • 发布者:<%= User.find(item.author_id).login%>(<%= User.find(item.author_id).realname%>) + <% user = User.find(item.author_id)%> +
  • 发布者:<%= user.login%>(<%= user.realname%>) 发布时间:<%= format_date(item.created_on)%> 下载次数:<%= item.downloads%>次 diff --git a/app/views/welcome/_search_attachment_results.html.erb b/app/views/welcome/_search_attachment_results.html.erb index e51706085..fa0468385 100644 --- a/app/views/welcome/_search_attachment_results.html.erb +++ b/app/views/welcome/_search_attachment_results.html.erb @@ -10,7 +10,8 @@
    <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>资源
  • -
  • 发布者:<%= User.find(attachment.author_id).login%>(<%= User.find(attachment.author_id).realname%>) + <% user = User.find(attachment.author_id)%> +
  • 发布者:<%= user.login%>(<%= user.realname%>) 发布时间:<%= format_date(attachment.created_on)%> 下载次数:<%= attachment.downloads%>次 diff --git a/app/views/welcome/_search_course_results.html.erb b/app/views/welcome/_search_course_results.html.erb index 322a47de5..dd4c9f405 100644 --- a/app/views/welcome/_search_course_results.html.erb +++ b/app/views/welcome/_search_course_results.html.erb @@ -13,10 +13,11 @@
  • <%= course.try(:highlight).try(:description) ? course.highlight.description[0].html_safe : (course.description.present? ? course.description : '暂时没有该班级描述') %>
  • - 教师:<%= User.find(course.tea_id).realname %> + <% user = User.find(course.tea_id)%> + 教师:<%= user.realname %> 授课时间:<%= course.time.to_s + course.term%> 更新时间:<%= format_date(course.updated_at)%> - <%= User.find(course.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(course.tea_id).user_extensions.occupation : ''%>
  • + <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
    diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb index 779570a4e..163392341 100644 --- a/app/views/welcome/_search_syllabus_results.html.erb +++ b/app/views/welcome/_search_syllabus_results.html.erb @@ -1,16 +1,18 @@ <% unless syllabuses.nil? || syllabuses.empty?%> - <% syllabuses.each do |syllabus|%> + <% syllabuses.each do |item|%> <% end %> diff --git a/app/views/welcome/_search_user_results.html.erb b/app/views/welcome/_search_user_results.html.erb index 06a40d021..3b9e18fba 100644 --- a/app/views/welcome/_search_user_results.html.erb +++ b/app/views/welcome/_search_user_results.html.erb @@ -1,20 +1,21 @@ <% unless users.nil? || users.empty?%> -<% users.each do |user|%> +<% users.each do |item|%>