搜索修改及代码优化
This commit is contained in:
parent
9ca685ea94
commit
b94553edcd
|
@ -431,6 +431,12 @@ class User < Principal
|
||||||
name = lastname + firstname
|
name = lastname + firstname
|
||||||
name.empty? || name.nil? ? login : name
|
name.empty? || name.nil? ? login : name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_occupation
|
||||||
|
if self.user_extensions && self.user_extensions.school
|
||||||
|
self.user_extensions.school.name
|
||||||
|
end
|
||||||
|
end
|
||||||
## end
|
## end
|
||||||
|
|
||||||
def get_at_show_name
|
def get_at_show_name
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(User.find(item.id).user_extensions.identity) %></span></div>
|
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(User.find(item.id).user_extensions.identity) %></span></div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
<li class="fontGrey3 mb5"><%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
|
<% user = User.find(item.id)%>
|
||||||
|
<li class="fontGrey3 mb5"><%= user.user_extensions && user.user_extensions.brief_introduction.present? ? user.user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
|
||||||
<li class="f12 fontGrey2">
|
<li class="f12 fontGrey2">
|
||||||
<span class="mr30">加入时间:<%= format_date( User.find(item.id).created_on)%></span><span class="mr30">
|
<span class="mr30">加入时间:<%= format_date( user.created_on)%></span><span class="mr30">
|
||||||
最后登录时间:<%= format_date( User.find(item.id).last_login_on)%></span><span class="mr30">
|
最后登录时间:<%= format_date( user.last_login_on)%></span><span class="mr30">
|
||||||
<%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%></span></li>
|
<%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
@ -29,13 +30,15 @@
|
||||||
<ul class="searchContent w968">
|
<ul class="searchContent w968">
|
||||||
<li class="f16 mb5 fontGrey3">
|
<li class="f16 mb5 fontGrey3">
|
||||||
<a href="<%= syllabus_path(item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程</a>
|
<a href="<%= syllabus_path(item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程</a>
|
||||||
<div class="mt5 fl"><img src="images/search_icon_03.png" width="8" height="16" class="fl" /><span class="searchTag">课程</span></div><div class="cl"></div></li>
|
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">课程</span></div><div class="cl"></div></li>
|
||||||
<li class="f12 fontGrey2">
|
<li class="f12 fontGrey2">
|
||||||
<span class="mr30">创建者:<%=item.user.login+"("+item.user.show_name+")"%></span>
|
<% user = User.find(item.user_id)%>
|
||||||
<span class="mr30">教师团队:<%=item.syllabus_members.count%></span>
|
<% syllabus = Syllabus.find(item.id) %>
|
||||||
<span class="mr30">班级:<%=item.courses.count%></span>
|
<span class="mr30">创建者:<%=user.login+"("+user.show_name+")"%></span>
|
||||||
|
<span class="mr30">教师团队:<%=syllabus.syllabus_members.count%></span>
|
||||||
|
<span class="mr30">班级:<%=syllabus.courses.count%></span>
|
||||||
<span class="mr30">更新时间:<%=format_date(item.updated_at)%></span>
|
<span class="mr30">更新时间:<%=format_date(item.updated_at)%></span>
|
||||||
<span class="mr30">单位:<%=item.user.user_extensions.occupation.present? ? item.user.user_extensions.occupation : '' %></span>
|
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<% when 'course'%>
|
<% when 'course'%>
|
||||||
|
@ -51,10 +54,11 @@
|
||||||
</li>
|
</li>
|
||||||
<li class="fontGrey3 mb5"><%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %></li>
|
<li class="fontGrey3 mb5"><%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %></li>
|
||||||
<li class="f12 fontGrey2">
|
<li class="f12 fontGrey2">
|
||||||
<span class="mr30">教师:<%= User.find(item.tea_id).realname %></span>
|
<% user = User.find(item.tea_id)%>
|
||||||
|
<span class="mr30">教师:<%= user.realname %></span>
|
||||||
<span class="mr30">授课时间:<%= item.time.to_s + item.term%></span>
|
<span class="mr30">授课时间:<%= item.time.to_s + item.term%></span>
|
||||||
<span class="mr30">更新时间:<%= format_date(item.updated_at)%></span>
|
<span class="mr30">更新时间:<%= format_date(item.updated_at)%></span>
|
||||||
<span class="mr30"><%= User.find(item.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(item.tea_id).user_extensions.occupation : ''%></span></li>
|
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
@ -69,7 +73,8 @@
|
||||||
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">资源</span></div>
|
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">资源</span></div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= User.find(item.author_id).login%>(<%= User.find(item.author_id).realname%>)</span>
|
<% user = User.find(item.author_id)%>
|
||||||
|
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= user.login%>(<%= user.realname%>)</span>
|
||||||
<!--<span class="mr30">职称:<%#= get_technical_title User.find(item.author_id) %></span>-->
|
<!--<span class="mr30">职称:<%#= get_technical_title User.find(item.author_id) %></span>-->
|
||||||
<span class="mr30">发布时间:<%= format_date(item.created_on)%></span>
|
<span class="mr30">发布时间:<%= format_date(item.created_on)%></span>
|
||||||
<span class="mr30">下载次数:<%= item.downloads%>次</span>
|
<span class="mr30">下载次数:<%= item.downloads%>次</span>
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">资源</span></div>
|
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">资源</span></div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= User.find(attachment.author_id).login%>(<%= User.find(attachment.author_id).realname%>)</span>
|
<% user = User.find(attachment.author_id)%>
|
||||||
|
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= user.login%>(<%= user.realname%>)</span>
|
||||||
<!--<span class="mr30">职称:<%#= get_technical_title User.find(attachment.author_id) %></span>-->
|
<!--<span class="mr30">职称:<%#= get_technical_title User.find(attachment.author_id) %></span>-->
|
||||||
<span class="mr30">发布时间:<%= format_date(attachment.created_on)%></span>
|
<span class="mr30">发布时间:<%= format_date(attachment.created_on)%></span>
|
||||||
<span class="mr30">下载次数:<%= attachment.downloads%>次</span>
|
<span class="mr30">下载次数:<%= attachment.downloads%>次</span>
|
||||||
|
|
|
@ -13,10 +13,11 @@
|
||||||
</li>
|
</li>
|
||||||
<li class="fontGrey3 mb5"><%= course.try(:highlight).try(:description) ? course.highlight.description[0].html_safe : (course.description.present? ? course.description : '暂时没有该班级描述') %></li>
|
<li class="fontGrey3 mb5"><%= course.try(:highlight).try(:description) ? course.highlight.description[0].html_safe : (course.description.present? ? course.description : '暂时没有该班级描述') %></li>
|
||||||
<li class="f12 fontGrey2">
|
<li class="f12 fontGrey2">
|
||||||
<span class="mr30">教师:<%= User.find(course.tea_id).realname %></span>
|
<% user = User.find(course.tea_id)%>
|
||||||
|
<span class="mr30">教师:<%= user.realname %></span>
|
||||||
<span class="mr30">授课时间:<%= course.time.to_s + course.term%></span>
|
<span class="mr30">授课时间:<%= course.time.to_s + course.term%></span>
|
||||||
<span class="mr30">更新时间:<%= format_date(course.updated_at)%></span>
|
<span class="mr30">更新时间:<%= format_date(course.updated_at)%></span>
|
||||||
<span class="mr30"><%= User.find(course.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(course.tea_id).user_extensions.occupation : ''%></span></li>
|
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
<% unless syllabuses.nil? || syllabuses.empty?%>
|
<% unless syllabuses.nil? || syllabuses.empty?%>
|
||||||
<% syllabuses.each do |syllabus|%>
|
<% syllabuses.each do |item|%>
|
||||||
<ul class="searchContent w968">
|
<ul class="searchContent w968">
|
||||||
<li class="f16 mb5 fontGrey3">
|
<li class="f16 mb5 fontGrey3">
|
||||||
<!--<a href="<%#= syllabus_path(syllabus.id)%>" class="fontGrey3 fl"><span class="c_red"><%#= syllabus.title %></span>课程</a>-->
|
<!--<a href="<%#= syllabus_path(syllabus.id)%>" class="fontGrey3 fl"><span class="c_red"><%#= syllabus.title %></span>课程</a>-->
|
||||||
<a href="<%= syllabus_path(syllabus.id)%>" class="fontGrey3 fl"><%= syllabus.try(:highlight).try(:title) ? syllabus.highlight.title[0].html_safe : syllabus.title %>课程</a>
|
<a href="<%= syllabus_path(item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程</a>
|
||||||
<div class="mt5 fl"><img src="images/search_icon_03.png" width="8" height="16" class="fl" /><span class="searchTag">课程</span></div><div class="cl"></div></li>
|
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">课程</span></div><div class="cl"></div></li>
|
||||||
<li class="f12 fontGrey2">
|
<li class="f12 fontGrey2">
|
||||||
<span class="mr30">创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%></span>
|
<% user = User.find(item.user_id)%>
|
||||||
|
<% syllabus = Syllabus.find(item.id) %>
|
||||||
|
<span class="mr30">创建者:<%=user.login+"("+user.show_name+")"%></span>
|
||||||
<span class="mr30">教师团队:<%=syllabus.syllabus_members.count%></span>
|
<span class="mr30">教师团队:<%=syllabus.syllabus_members.count%></span>
|
||||||
<span class="mr30">班级:<%=syllabus.courses.count%></span>
|
<span class="mr30">班级:<%=syllabus.courses.count%></span>
|
||||||
<span class="mr30">更新时间:<%=format_date(syllabus.updated_at)%></span>
|
<span class="mr30">更新时间:<%=format_date(syllabus.updated_at)%></span>
|
||||||
<span class="mr30">单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation : '' %></span>
|
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
<% unless users.nil? || users.empty?%>
|
<% unless users.nil? || users.empty?%>
|
||||||
<% users.each do |user|%>
|
<% users.each do |item|%>
|
||||||
<ul class="searchContent">
|
<ul class="searchContent">
|
||||||
<li class="fl">
|
<li class="fl">
|
||||||
<!--<img src="images/homepageImage.jpg" alt="个人图片" width="75" height="75" class="searchCourseImage" />-->
|
<!--<img src="images/homepageImage.jpg" alt="个人图片" width="75" height="75" class="searchCourseImage" />-->
|
||||||
<%= 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 => "用户头像" %>
|
||||||
</li>
|
</li>
|
||||||
<li class="fl searchContentDes">
|
<li class="fl searchContentDes">
|
||||||
<ul class="fl">
|
<ul class="fl">
|
||||||
<li class="f16 mb5"><a href="<%= user_path(user.id)%>" class="fontGrey3 fl"><%= user.try(:highlight).try(:login) ? user.highlight.login[0].html_safe : user.login %>(<%= user.try(:highlight).try(:lastname) ? user.highlight.lastname[0].html_safe : user.lastname%><%= user.try(:highlight).try(:firstname) ? user.highlight.firstname[0].html_safe : user.firstname %>)</a>
|
<li class="f16 mb5"><a href="<%= user_path(user.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:login) ? item.highlight.login[0].html_safe : user.login %>(<%= item.try(:highlight).try(:lastname) ? item.highlight.lastname[0].html_safe : user.lastname%><%= item.try(:highlight).try(:firstname) ? item.highlight.firstname[0].html_safe : user.firstname %>)</a>
|
||||||
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(User.find(user.id).user_extensions.identity) %></span></div>
|
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(user.user_extensions.identity) %></span></div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</li>
|
</li>
|
||||||
<li class="fontGrey3 mb5"><%= User.find(user.id).user_extensions && User.find(user.id).user_extensions.brief_introduction.present? ? User.find(user.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
|
<li class="fontGrey3 mb5"><%= user.user_extensions && user.user_extensions.brief_introduction.present? ? user.user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
|
||||||
<li class="f12 fontGrey2"><span class="mr30">加入时间:<%= format_date( User.find(user.id).created_on)%></span><span class="mr30">
|
<li class="f12 fontGrey2"><span class="mr30">加入时间:<%= format_date( user.created_on)%></span><span class="mr30">
|
||||||
最后登录时间:<%= format_date( User.find(user.id).last_login_on)%></span><span class="mr30">
|
最后登录时间:<%= format_date( user.last_login_on)%></span><span class="mr30">
|
||||||
<%= User.find(user.id).user_extensions.occupation.present? ? '单位:'+User.find(user.id).user_extensions.occupation : ''%></span></li>
|
<%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
|
@ -7,21 +7,6 @@ namespace :importer do
|
||||||
ENV['BATCH']='1000'
|
ENV['BATCH']='1000'
|
||||||
Rake::Task["elasticsearch:import:model"].execute
|
Rake::Task["elasticsearch:import:model"].execute
|
||||||
end
|
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
|
task :importsyllabus => :environment do
|
||||||
ENV['CLASS']='Syllabus'
|
ENV['CLASS']='Syllabus'
|
||||||
ENV['SCOPE']='indexable'
|
ENV['SCOPE']='indexable'
|
||||||
|
@ -29,6 +14,13 @@ namespace :importer do
|
||||||
ENV['BATCH']='1000'
|
ENV['BATCH']='1000'
|
||||||
Rake::Task["elasticsearch:import:model"].execute
|
Rake::Task["elasticsearch:import:model"].execute
|
||||||
end
|
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
|
task :importattachment => :environment do
|
||||||
ENV['CLASS']='Attachment'
|
ENV['CLASS']='Attachment'
|
||||||
ENV['SCOPE']='indexable'
|
ENV['SCOPE']='indexable'
|
||||||
|
@ -36,6 +28,14 @@ namespace :importer do
|
||||||
ENV['BATCH']='1000'
|
ENV['BATCH']='1000'
|
||||||
Rake::Task["elasticsearch:import:model"].execute
|
Rake::Task["elasticsearch:import:model"].execute
|
||||||
end
|
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
|
task :importmemo => :environment do
|
||||||
ENV['CLASS']='Memo'
|
ENV['CLASS']='Memo'
|
||||||
ENV['SCOPE']='indexable'
|
ENV['SCOPE']='indexable'
|
||||||
|
@ -45,5 +45,5 @@ namespace :importer do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Run all tasks"
|
desc "Run all tasks"
|
||||||
task :all => [:importuser,:importproject,:importsyllabus,:importcourse,:importattachment,:importmemo]
|
task :all => [:importuser,:importsyllabus,:importcourse,:importattachment,:importproject,:importmemo]
|
||||||
end
|
end
|
Loading…
Reference in New Issue