From 1467d1e8d67b85e7cda9b1bf1b46d5cbad66fb3a Mon Sep 17 00:00:00 2001 From: David Carlos Date: Tue, 12 May 2015 13:24:07 +0000 Subject: [PATCH] Improves scope to manage organizations. --- app/controllers/admin/admin_panel_controller.rb | 24 +++++++++++------------- lib/noosfero/plugin.rb | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/controllers/admin/admin_panel_controller.rb b/app/controllers/admin/admin_panel_controller.rb index 4ffcec4..4b424d8 100644 --- a/app/controllers/admin/admin_panel_controller.rb +++ b/app/controllers/admin/admin_panel_controller.rb @@ -77,16 +77,16 @@ class AdminPanelController < AdminController @title = "Organization profiles" @title = @title+" - "+@filter if @filter != 'any' @type = params[:type] || "any" - @types_filter = [['All', 'any'], [_('Community'), 'communities'], [_('Enterprise'), 'enterprises']] - @types_filter = @types_filter | @plugins.dispatch_without_flatten(:organization_types_filter_options).flatten(1) - - scope = if @type == "communities" - environment.communities - elsif @type == "enterprises" - environment.enterprises - else - environment.organizations - end + @types_filter = [['All', 'any'], [_('Community'), 'Community'], [_('Enterprise'), 'Enterprise']] + @types_filter = @types_filter | @plugins.dispatch_first(:organization_types_filter_options) + + scope = if @type == 'any' + environment.organizations + else + @plugins.dispatch_first(:filter_manage_organization_scope, @type) + end + + scope = environment.profiles.where(:type => @type) if scope.blank? if @filter == 'enabled' scope = scope.visible @@ -94,9 +94,7 @@ class AdminPanelController < AdminController scope = scope.disabled end - scope = scope.order('name ASC') - result_plugin = @plugins.dispatch(:filter_manage_organization_scope, scope, @type) - scope = result_plugin if !result_plugin.blank? + scope = scope.sort_by{ |m| m.name } @q = params[:q] @collection = find_by_contents(:organizations, environment, scope, @q, {:per_page => 10, :page => params[:npage]})[:results] diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 3e673ea..6b28190 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -279,7 +279,7 @@ class Noosfero::Plugin # -> Filters the types of organizations that are shown on manage organizations # returns a scope filtered by the specified type - def filter_manage_organization_scope scope, type + def filter_manage_organization_scope type nil end -- libgit2 0.21.2