课程主题可以搜索

This commit is contained in:
lizanle 2015-07-22 10:23:14 +08:00
parent b8670449c6
commit ffe12b92c8
1 changed files with 11 additions and 4 deletions

View File

@ -73,8 +73,14 @@ class NewsController < ApplicationController
@news_count = scope.count @news_count = scope.count
#@news_pages = Paginator.new @news_count, @limit, params['page'] #@news_pages = Paginator.new @news_count, @limit, params['page']
#@offset ||= scope_page.offset #@offset ||= scope_page.offset
scope_order = scope.all(:include => [:author, :course], if params[:subject].nil?
:order => "#{News.table_name}.created_on DESC") scope_order = scope.all(:include => [:author, :course],
:order => "#{News.table_name}.created_on DESC")
else
scope_order = scope.where("news.title like '#{'%' << params[:subject].to_s << '%'}'").all(:include => [:author, :course],
:order => "#{News.table_name}.created_on DESC")
end
# :offset => @offset, # :offset => @offset,
# :limit => @limit) # :limit => @limit)
@newss = paginateHelper scope_order,10 @newss = paginateHelper scope_order,10
@ -83,6 +89,7 @@ class NewsController < ApplicationController
@news = News.new @news = News.new
render :layout => 'base_courses' render :layout => 'base_courses'
} }
format.js
format.api format.api
format.atom { render_feed(@newss, :title => (@course ? @course.name : Setting.app_title) + ": #{l(:label_news_plural)}") } format.atom { render_feed(@newss, :title => (@course ? @course.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
end end
@ -141,7 +148,7 @@ class NewsController < ApplicationController
ids = params[:asset_id].split(',') ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
end end
# 与我相关动态的记录add start # <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add start
teachers = searchTeacherAndAssistant(@course) teachers = searchTeacherAndAssistant(@course)
for teacher in teachers for teacher in teachers
if(teacher.user_id != User.current.id) if(teacher.user_id != User.current.id)
@ -155,7 +162,7 @@ class NewsController < ApplicationController
notify.save() notify.save()
end end
end end
# 与我相关动态的记录add end # <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>̬<EFBFBD>ļ<EFBFBD>¼add end
render_attachment_warning_if_needed(@news) render_attachment_warning_if_needed(@news)
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)
redirect_to course_news_index_url(@course) redirect_to course_news_index_url(@course)