Orbit/lib/orbit_category/categorizing.rb

28 lines
637 B
Ruby
Raw Permalink Normal View History

module OrbitCategory
module Categorizing
def get_categories_for_index
if is_manager? || is_admin?
@module_app.categories.all
else
@module_app.categories.enabled
end
end
2013-08-19 10:54:35 +00:00
def get_categories_for_form
categories = if is_manager? || is_admin?
@module_app.categories.enabled
elsif is_sub_manager?
2013-08-19 10:54:35 +00:00
@module_app.categories.enabled.entries.delete_if{|category| !category.user_can_sub_manage?(current_user)}
end
if categories.empty?
flash[:alert] = t(:no_category)
redirect_to :action => :index
end
categories
end
end
end