课程主题可以搜索

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