From efb69e9805153e52c27119580ce0c87d109f8848 Mon Sep 17 00:00:00 2001 From: Arthur Del Esposte Date: Tue, 2 Sep 2014 13:58:08 +0000 Subject: [PATCH] deactive_and_active_profile: Change to manage only organizations profiles status --- app/controllers/admin/admin_panel_controller.rb | 8 ++++---- app/models/enterprise.rb | 7 ++++++- app/models/profile.rb | 2 ++ app/views/admin_panel/index.html.erb | 2 +- app/views/admin_panel/manage_organizations_status.html.erb | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/views/admin_panel/manage_profile_status.html.erb | 64 ---------------------------------------------------------------- test/unit/profile_test.rb | 9 +++++++++ 7 files changed, 86 insertions(+), 70 deletions(-) create mode 100644 app/views/admin_panel/manage_organizations_status.html.erb delete mode 100644 app/views/admin_panel/manage_profile_status.html.erb diff --git a/app/controllers/admin/admin_panel_controller.rb b/app/controllers/admin/admin_panel_controller.rb index 1ef33a4..86fb9e6 100644 --- a/app/controllers/admin/admin_panel_controller.rb +++ b/app/controllers/admin/admin_panel_controller.rb @@ -72,10 +72,10 @@ class AdminPanelController < AdminController end end - def manage_profile_status - scope = environment.profiles + def manage_organizations_status + scope = environment.organizations @filter = params[:filter] || 'any' - @title = "All profiles" + @title = "Organization profiles" @title = @title+" - "+@filter if @filter != 'any' if @filter == 'enabled' @@ -87,6 +87,6 @@ class AdminPanelController < AdminController scope = scope.order('name ASC') @q = params[:q] - @collection = find_by_contents(:people, scope, @q, {:per_page => 10, :page => params[:npage]})[:results] + @collection = find_by_contents(:organizations, scope, @q, {:per_page => 10, :page => params[:npage]})[:results] end end diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 7abfec7..80a3d08 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -107,7 +107,12 @@ class Enterprise < Organization self.tasks.where(:type => 'EnterpriseActivation').first end - def enable(owner) + def enable(owner = nil) + if owner.nil? + self.visible = true + return self.save + end + return if enabled # must be set first for the following to work self.enabled = true diff --git a/app/models/profile.rb b/app/models/profile.rb index 5e01201..90b462a 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -899,6 +899,8 @@ private :generate_url, :url_options end def disable + self.visible = false + self.save end def enable diff --git a/app/views/admin_panel/index.html.erb b/app/views/admin_panel/index.html.erb index b238db3..f5980be 100644 --- a/app/views/admin_panel/index.html.erb +++ b/app/views/admin_panel/index.html.erb @@ -20,7 +20,7 @@ <%= link_to _('Users'), :controller => 'users' %> <%= link_to _('Profile templates'), :controller => 'templates' %> <%= link_to _('Fields'), :controller => 'features', :action => 'manage_fields' %> - <%= link_to _('Manage profiles status'), :action => 'manage_profile_status' %> + <%= link_to _('Manage organizations status'), :action => 'manage_organizations_status' %> diff --git a/app/views/admin_panel/manage_organizations_status.html.erb b/app/views/admin_panel/manage_organizations_status.html.erb new file mode 100644 index 0000000..089cb98 --- /dev/null +++ b/app/views/admin_panel/manage_organizations_status.html.erb @@ -0,0 +1,64 @@ +

<%= _('Manage organizations') %>

+ +<%= form_tag( { :action => 'manage_organizations_status' }, :method => 'get', :class => 'users-search' ) do %> + +
+ + <%= text_field_tag 'q', @q, :title => _("Find profiles"), :style=>"width:85%" %> + + + <%= submit_button(:search, _('Search')) %> +
+ +
+
<%= @title %>
+ +
+ <%= _("Filter by: ") %> + + +
+
+
+ + + + + + + + + + + + + <% @collection.each do |p| %> + + + + + + <% end %> +
<%= _('Member') %><%= _('Actions') %>
<%= link_to_profile p.short_name, p.identifier, :title => p.name %> +
+ <% if p.visible %> + <%= button_without_text :'deactivate-user', _('Deactivate'), {:controller=>"profile_editor", :action => 'deactivate_profile', :profile=>p.identifier, :id=>p.id}, :confirm => _("Do you want to deactivate this profile ?") %> + <% else %> + <%= button_without_text :'activate-user', _('Activate'), {:controller=>"profile_editor", :action => 'activate_profile', :profile=>p.identifier, :id=>p.id}, :confirm => _("Do you want to activate this profile ?") %> + <% end %> +
+
+ +<% end %> + +<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %> + + \ No newline at end of file diff --git a/app/views/admin_panel/manage_profile_status.html.erb b/app/views/admin_panel/manage_profile_status.html.erb deleted file mode 100644 index 2c38821..0000000 --- a/app/views/admin_panel/manage_profile_status.html.erb +++ /dev/null @@ -1,64 +0,0 @@ -

<%= _('Manage profiles') %>

- -<%= form_tag( { :action => 'manage_profile_status' }, :method => 'get', :class => 'users-search' ) do %> - -
- - <%= text_field_tag 'q', @q, :title => _("Find profiles"), :style=>"width:85%" %> - - - <%= submit_button(:search, _('Search')) %> -
- -
-
<%= @title %>
- -
- <%= _("Filter by: ") %> - - -
-
-
- - - - - - - - - - - - - <% @collection.each do |p| %> - - - - - - <% end %> -
<%= _('Member') %><%= _('Actions') %>
<%= link_to_profile p.short_name, p.identifier, :title => p.name %> -
- <% if p.visible %> - <%= button_without_text :'deactivate-user', _('Deactivate'), {:controller=>"profile_editor", :action => 'deactivate_profile', :profile=>p.identifier, :id=>p.id}, :confirm => _("Do you want to deactivate this profile ?") %> - <% else %> - <%= button_without_text :'activate-user', _('Activate'), {:controller=>"profile_editor", :action => 'activate_profile', :profile=>p.identifier, :id=>p.id}, :confirm => _("Do you want to activate this profile ?") %> - <% end %> -
-
- -<% end %> - -<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %> - - \ No newline at end of file diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 5d03d65..bc8383f 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1955,4 +1955,13 @@ class ProfileTest < ActiveSupport::TestCase p = fast_create(Profile) assert p.folder_types.include?('ProfileTest::Folder1') end + + should 'enable profile visibility' do + profile = fast_create(Profile) + + assert profile.enable, _("Profile should have been enabled") + assert profile.visible, _("Profile should be visible") + profile.disable + assert !profile.visible, _("Profile should not be visible") + end end -- libgit2 0.21.2