From 497dc63351ecfeb107a9d80d25787dae313795b0 Mon Sep 17 00:00:00 2001 From: JiangRu Date: Mon, 14 Sep 2015 16:14:32 +0800 Subject: [PATCH] add category to export json --- app/controllers/admin/bulletins_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) 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)