课程搜索结果不正确
This commit is contained in:
parent
16aea5ef42
commit
6051d0797d
|
@ -106,74 +106,17 @@ class CoursesController < ApplicationController
|
||||||
# 课程搜索
|
# 课程搜索
|
||||||
# add by nwb
|
# add by nwb
|
||||||
def search
|
def search
|
||||||
courses_all = Course.all_course
|
if params[:name].empty?
|
||||||
name = params[:name]
|
courses = Course.visible
|
||||||
if name.blank?
|
@courses = paginateHelper courses,10
|
||||||
@courses = []
|
|
||||||
@courses_all = []
|
|
||||||
@course_count = 0
|
|
||||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
|
||||||
else
|
else
|
||||||
@courses = courses_all.visible
|
courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'")
|
||||||
if params[:name].present?
|
@courses = paginateHelper courses,10
|
||||||
@courses_all = @courses.like(params[:name])
|
|
||||||
else
|
|
||||||
@courses_all = @courses;
|
|
||||||
end
|
|
||||||
@course_count = @courses_all.count
|
|
||||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
|
||||||
|
|
||||||
# 课程的动态数
|
|
||||||
# @course_activity_count=Hash.new
|
|
||||||
# @courses_all.each do |course|
|
|
||||||
# @course_activity_count[course.id]=0
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# case params[:course_sort_type]
|
|
||||||
# when '0'
|
|
||||||
# @courses = @courses_all.order("created_at desc")
|
|
||||||
# @s_type = 0
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# when '1'
|
|
||||||
# @courses = @courses_all.order("course_ac_para desc")
|
|
||||||
# @s_type = 1
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# when '2'
|
|
||||||
# @courses = @courses_all.order("watchers_count desc")
|
|
||||||
# @s_type = 2
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# when '3'
|
|
||||||
# @course_activity_count=get_course_activity @courses_all,@course_activity_count_array
|
|
||||||
# @courses=handle_course @courses_all,@course_activity_count
|
|
||||||
# @s_type = 3
|
|
||||||
# @courses = @courses[@course_pages.offset, @course_pages.per_page]
|
|
||||||
#
|
|
||||||
# else
|
|
||||||
# @s_type = 0
|
|
||||||
# @courses = @courses_all.order("created_at desc")
|
|
||||||
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
|
||||||
#
|
|
||||||
# @course_activity_count=get_course_activity @courses,@course_activity_count
|
|
||||||
#
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
render :layout => 'course_base'
|
render :layout => 'course_base'
|
||||||
scope = Course
|
|
||||||
unless params[:closed]
|
|
||||||
scope = scope.active
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||||
|
|
|
@ -39,17 +39,17 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if @courses.size == 0 %>
|
<% if @courses && !@courses.empty? %>
|
||||||
<%= render :partial => 'layouts/no_content'%>
|
<div id="courses-index">
|
||||||
|
<%= render_course_hierarchy(@courses)%>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div id="courses-index">
|
<%= render :partial => 'layouts/no_content'%>
|
||||||
<%= render_course_hierarchy(@courses)%>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<ul>
|
<ul>
|
||||||
<%= pagination_links_full @course_pages %>
|
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue