diff --git a/app/controllers/admin/admin_panel_controller.rb b/app/controllers/admin/admin_panel_controller.rb index 6c2b103..1ef33a4 100644 --- a/app/controllers/admin/admin_panel_controller.rb +++ b/app/controllers/admin/admin_panel_controller.rb @@ -71,4 +71,22 @@ class AdminPanelController < AdminController end end end + + def manage_profile_status + scope = environment.profiles + @filter = params[:filter] || 'any' + @title = "All profiles" + @title = @title+" - "+@filter if @filter != 'any' + + if @filter == 'enabled' + scope = scope.visible + elsif @filter == 'disabled' + scope = scope.disabled + end + + scope = scope.order('name ASC') + + @q = params[:q] + @collection = find_by_contents(:people, scope, @q, {:per_page => 10, :page => params[:npage]})[:results] + end end diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 21277ee..cf57ccf 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -90,6 +90,20 @@ class ProfileEditorController < MyProfileController end end - redirect_to "/" + redirect_to request.referer + end + + def activate_profile + if environment.admins.include?(current_person) + profile = Profile.find(params[:id]) + + if profile.enable + session[:notice] = _("The profile '#{profile.name}' was activated.") + else + session[:notice] = _('Could not activate the profile.') + end + end + + redirect_to request.referer end end diff --git a/app/models/profile.rb b/app/models/profile.rb index 3482a52..5e01201 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -121,6 +121,7 @@ class Profile < ActiveRecord::Base end scope :visible, :conditions => { :visible => true } + scope :disabled, :conditions => { :visible => false } scope :public, :conditions => { :visible => true, :public_profile => true } # Subclasses must override this method @@ -900,6 +901,11 @@ private :generate_url, :url_options def disable end + def enable + self.visible = true + self.save + end + def control_panel_settings_button {:title => _('Edit Profile'), :icon => 'edit-profile'} end diff --git a/app/views/admin_panel/index.html.erb b/app/views/admin_panel/index.html.erb index 163a6a0..b238db3 100644 --- a/app/views/admin_panel/index.html.erb +++ b/app/views/admin_panel/index.html.erb @@ -20,6 +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' %> diff --git a/app/views/admin_panel/manage_profile_status.html.erb b/app/views/admin_panel/manage_profile_status.html.erb new file mode 100644 index 0000000..2c38821 --- /dev/null +++ b/app/views/admin_panel/manage_profile_status.html.erb @@ -0,0 +1,64 @@ +

<%= _('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/app/views/profile_editor/edit.html.erb b/app/views/profile_editor/edit.html.erb index 54d594d..0d8ffaa 100644 --- a/app/views/profile_editor/edit.html.erb +++ b/app/views/profile_editor/edit.html.erb @@ -69,7 +69,12 @@ <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> <% if environment.admins.include?(current_person) %> - <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> + + <% if profile.visible? %> + <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> + <% else %> + <%= button(:add, _('Activate profile'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> + <% end %> <% end %> <% end %> <% end %> -- libgit2 0.21.2