From 98a03c2e40c0358828b831477bc44a86d8b9a68b Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 5 Nov 2013 18:18:11 +0800 Subject: [PATCH] now only approved announcement can be viewed when backend is open --- app/controllers/application_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 442980438..2564ae5e7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -341,9 +341,18 @@ class ApplicationController < ActionController::Base else objects = get_viewable(object_class, query) end + + if (!user_signed_in? && object_class == "bulletin") + objects = get_bulletins_for_open_backend(objects) + end + Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10) end + def get_bulletins_for_open_backend(objects) + objects.select{|object| object.is_rejected == false && object.is_pending == false} + end + def get_string_value_from_object(object) s = object.name_translations[I18n.locale.to_s] unless s rescue nil s = object.title_translations[I18n.locale.to_s] unless s rescue nil