Commit 1467d1e8d67b85e7cda9b1bf1b46d5cbad66fb3a

Authored by David Silva
1 parent a8cb8dcf

Improves scope to manage organizations.

Signed-off-by: David Carlos    <ddavidcarlos1392@gmail.com>
Signed-off-by: Fabio Teixeira  <fabio1079@gmail.com>
app/controllers/admin/admin_panel_controller.rb
@@ -77,16 +77,16 @@ class AdminPanelController &lt; AdminController @@ -77,16 +77,16 @@ class AdminPanelController &lt; AdminController
77 @title = "Organization profiles" 77 @title = "Organization profiles"
78 @title = @title+" - "+@filter if @filter != 'any' 78 @title = @title+" - "+@filter if @filter != 'any'
79 @type = params[:type] || "any" 79 @type = params[:type] || "any"
80 - @types_filter = [['All', 'any'], [_('Community'), 'communities'], [_('Enterprise'), 'enterprises']]  
81 - @types_filter = @types_filter | @plugins.dispatch_without_flatten(:organization_types_filter_options).flatten(1)  
82 -  
83 - scope = if @type == "communities"  
84 - environment.communities  
85 - elsif @type == "enterprises"  
86 - environment.enterprises  
87 - else  
88 - environment.organizations  
89 - end 80 + @types_filter = [['All', 'any'], [_('Community'), 'Community'], [_('Enterprise'), 'Enterprise']]
  81 + @types_filter = @types_filter | @plugins.dispatch_first(:organization_types_filter_options)
  82 +
  83 + scope = if @type == 'any'
  84 + environment.organizations
  85 + else
  86 + @plugins.dispatch_first(:filter_manage_organization_scope, @type)
  87 + end
  88 +
  89 + scope = environment.profiles.where(:type => @type) if scope.blank?
90 90
91 if @filter == 'enabled' 91 if @filter == 'enabled'
92 scope = scope.visible 92 scope = scope.visible
@@ -94,9 +94,7 @@ class AdminPanelController &lt; AdminController @@ -94,9 +94,7 @@ class AdminPanelController &lt; AdminController
94 scope = scope.disabled 94 scope = scope.disabled
95 end 95 end
96 96
97 - scope = scope.order('name ASC')  
98 - result_plugin = @plugins.dispatch(:filter_manage_organization_scope, scope, @type)  
99 - scope = result_plugin if !result_plugin.blank? 97 + scope = scope.sort_by{ |m| m.name }
100 98
101 @q = params[:q] 99 @q = params[:q]
102 @collection = find_by_contents(:organizations, environment, scope, @q, {:per_page => 10, :page => params[:npage]})[:results] 100 @collection = find_by_contents(:organizations, environment, scope, @q, {:per_page => 10, :page => params[:npage]})[:results]
lib/noosfero/plugin.rb
@@ -279,7 +279,7 @@ class Noosfero::Plugin @@ -279,7 +279,7 @@ class Noosfero::Plugin
279 279
280 # -> Filters the types of organizations that are shown on manage organizations 280 # -> Filters the types of organizations that are shown on manage organizations
281 # returns a scope filtered by the specified type 281 # returns a scope filtered by the specified type
282 - def filter_manage_organization_scope scope, type 282 + def filter_manage_organization_scope type
283 nil 283 nil
284 end 284 end
285 285