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 @@
-
<%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程
-
课程
+ <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>课程
-
- 创建者:<%=item.user.login+"("+item.user.show_name+")"%>
- 教师团队:<%=item.syllabus_members.count%>
- 班级:<%=item.courses.count%>
+ <% user = User.find(item.user_id)%>
+ <% syllabus = Syllabus.find(item.id) %>
+ 创建者:<%=user.login+"("+user.show_name+")"%>
+ 教师团队:<%=syllabus.syllabus_members.count%>
+ 班级:<%=syllabus.courses.count%>
更新时间:<%=format_date(item.updated_at)%>
- 单位:<%=item.user.user_extensions.occupation.present? ? item.user.user_extensions.occupation : '' %>
+ <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
<% 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|%>
-
- <%= syllabus.try(:highlight).try(:title) ? syllabus.highlight.title[0].html_safe : syllabus.title %>课程
-
课程
+ <%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程
+ <%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %>课程
-
- 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%>
+ <% user = User.find(item.user_id)%>
+ <% syllabus = Syllabus.find(item.id) %>
+ 创建者:<%=user.login+"("+user.show_name+")"%>
教师团队:<%=syllabus.syllabus_members.count%>
班级:<%=syllabus.courses.count%>
更新时间:<%=format_date(syllabus.updated_at)%>
- 单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation : '' %>
+ <%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %>
<% 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|%>
-
- <%= link_to image_tag(url_to_avatar(User.find(user.id)), :width => "75", :height => "75",:class=>'searchCourseImage'), user_path(user.id), :alt => "用户头像" %>
+ <% user = User.find(item.id)%>
+ <%= link_to image_tag(url_to_avatar(user), :width => "75", :height => "75",:class=>'searchCourseImage'), user_path(user.id), :alt => "用户头像" %>
-
diff --git a/lib/tasks/elasticsearch_batch_op.rake b/lib/tasks/elasticsearch_batch_op.rake
index 6693fcf69..0c041ba8c 100644
--- a/lib/tasks/elasticsearch_batch_op.rake
+++ b/lib/tasks/elasticsearch_batch_op.rake
@@ -7,21 +7,6 @@ namespace :importer do
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
- task :importproject => :environment do
-
- ENV['CLASS']='Project'
- ENV['SCOPE']='indexable'
- ENV['FORCE']='y'
- ENV['BATCH']='1000'
- Rake::Task["elasticsearch:import:model"].execute
- end
- task :importcourse => :environment do
- ENV['CLASS']='Course'
- ENV['SCOPE']='indexable'
- ENV['FORCE']='y'
- ENV['BATCH']='1000'
- Rake::Task["elasticsearch:import:model"].execute
- end
task :importsyllabus => :environment do
ENV['CLASS']='Syllabus'
ENV['SCOPE']='indexable'
@@ -29,6 +14,13 @@ namespace :importer do
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
+ task :importcourse => :environment do
+ ENV['CLASS']='Course'
+ ENV['SCOPE']='indexable'
+ ENV['FORCE']='y'
+ ENV['BATCH']='1000'
+ Rake::Task["elasticsearch:import:model"].execute
+ end
task :importattachment => :environment do
ENV['CLASS']='Attachment'
ENV['SCOPE']='indexable'
@@ -36,6 +28,14 @@ namespace :importer do
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
+ task :importproject => :environment do
+
+ ENV['CLASS']='Project'
+ ENV['SCOPE']='indexable'
+ ENV['FORCE']='y'
+ ENV['BATCH']='1000'
+ Rake::Task["elasticsearch:import:model"].execute
+ end
task :importmemo => :environment do
ENV['CLASS']='Memo'
ENV['SCOPE']='indexable'
@@ -45,5 +45,5 @@ namespace :importer do
end
desc "Run all tasks"
- task :all => [:importuser,:importproject,:importsyllabus,:importcourse,:importattachment,:importmemo]
+ task :all => [:importuser,:importsyllabus,:importcourse,:importattachment,:importproject,:importmemo]
end
\ No newline at end of file