add category to export

json
This commit is contained in:
JiangRu 2015-09-14 16:14:32 +08:00
parent 308370c4df
commit 497dc63351
1 changed files with 10 additions and 0 deletions

View File

@ -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)