diff --git a/app/controllers/admin/bulletins_controller.rb b/app/controllers/admin/bulletins_controller.rb index 97453e9..5b53d6b 100644 --- a/app/controllers/admin/bulletins_controller.rb +++ b/app/controllers/admin/bulletins_controller.rb @@ -11,12 +11,22 @@ class Admin::BulletinsController < ApplicationController per_page = params[:per_page].blank? ? 10 : params[:per_page].to_i per_page = per_page > 0 ? per_page : 10 + I18n.locale = :zh_tw if !params[:keyword].blank? keyword = Regexp.new(".*"+params[:keyword]+".*") bulletins = Bulletin.any_of({:title=>keyword},{:subtitle=>keyword},{:text=>keyword}) else bulletins = Bulletin.all end + + if !params[:category].blank? + module_id = ModuleApp.where(:key=>"announcement").first.id + category = Regexp.new(".*"+params[:category]+".*") + category_id = Category.where(:title => category, :module_app_id => module_id).first.id + bulletins = bulletins.where(:category_id => category_id) + else + bulletins = bulletins + end bulletins = bulletins.where(:is_preview.in=>[false,nil]) bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true)