now only approved announcement can be viewed when backend is open

This commit is contained in:
Harry Bomrah 2013-11-05 18:18:11 +08:00
parent 9d7af2ccac
commit 98a03c2e40
1 changed files with 9 additions and 0 deletions

View File

@ -341,9 +341,18 @@ class ApplicationController < ActionController::Base
else else
objects = get_viewable(object_class, query) objects = get_viewable(object_class, query)
end 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) Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10)
end 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) def get_string_value_from_object(object)
s = object.name_translations[I18n.locale.to_s] unless s rescue nil s = object.name_translations[I18n.locale.to_s] unless s rescue nil
s = object.title_translations[I18n.locale.to_s] unless s rescue nil s = object.title_translations[I18n.locale.to_s] unless s rescue nil