Fix destroy in structure

Fix sorting
This commit is contained in:
Christophe Vilayphiou committed 2012-05-22 17:55:45 +08:00
1 parent 541aa5831e
commit 11a371cbb9
2 files changed
+12 -6

No files matched your search

+8 -4
View File
@@ -33,6 +33,7 @@ class OrbitBackendController< ApplicationController
def get_sorted_and_filtered(object_class, query=nil)
objects = get_objects(object_class, query)
object_class = object_class.classify.constantize
if !params[:sort].blank?
options = params[:sort_options]
options = [options] if !options.class.eql?(Array)
@@ -87,7 +88,7 @@ class OrbitBackendController< ApplicationController
end if value.size > 0
end
end
Kaminari.paginate_array(objects).page(params[:page]).per(10)
Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10)
end
def get_string_value_from_object(object)
@@ -159,13 +160,16 @@ class OrbitBackendController< ApplicationController
end
def get_objects(object_class, query=nil)
object_class = object_class.classify.constantize
if query
objects = object_class.all.where(query).entries
objects = object_class.all.where(query)
else
objects = object_class.all.entries
objects = object_class.all
end
objects
end
def filter_authorized_objects(objects)
if(!is_admin? || !is_manager?)
objects.delete_if{ |object|
if object.is_pending == true