]> source.dussan.org Git - redmine.git/commitdiff
Preserve status filter and page number when using lock/unlock/activate links on the...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 6 Apr 2008 13:15:09 +0000 (13:15 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 6 Apr 2008 13:15:09 +0000 (13:15 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1334 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/users_controller.rb
app/helpers/users_helper.rb
app/views/users/list.rhtml

index ceb70ab924f614060d9ab3a22485c4a0eec54979..48fc6fade7371a5ffff738869a56352c5761e965 100644 (file)
@@ -83,7 +83,8 @@ class UsersController < ApplicationController
       end
       if @user.update_attributes(params[:user])
         flash[:notice] = l(:notice_successful_update)
-        redirect_to :action => 'list'
+        # Give a string to redirect_to otherwise it would use status param as the response code
+        redirect_to(url_for(:action => 'list', :status => params[:status], :page => params[:page]))
       end
     end
     @auth_sources = AuthSource.find(:all)
index 7bd1371617c3a4220353720f50b2698517afdd41..250ed8ce82399ddd05d07787c7043f778dc23604 100644 (file)
@@ -22,4 +22,16 @@ module UsersHelper
                         [l(:status_registered), 2],
                         [l(:status_locked), 3]], selected)
   end
+  
+  def change_status_link(user)
+    url = {:action => 'edit', :id => user, :page => params[:page], :status => params[:status]}
+    
+    if user.locked?
+      link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
+    elsif user.registered?
+      link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :post, :class => 'icon icon-unlock'
+    else
+      link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :post, :class => 'icon icon-lock'
+    end
+  end
 end
index e12aa34256e396158faac02daf84d9928e6fdc10..d89672d1958c841b014162067cd56737af338eed 100644 (file)
        <td align="center"><%= image_tag('true.png') if user.admin? %></td>
        <td class="created_on" align="center"><%= format_time(user.created_on) %></td>
        <td class="last_login_on" align="center"><%= format_time(user.last_login_on) unless user.last_login_on.nil? %></td>
-    <td>
-    <small>
-    <% if user.locked? -%>
-        <%= link_to l(:button_unlock), {:action => 'edit', :id => user, :user => {:status => User::STATUS_ACTIVE}}, :method => :post, :class => 'icon icon-unlock' %>
-    <% elsif user.registered? -%>
-        <%= link_to l(:button_activate), {:action => 'edit', :id => user, :user => {:status => User::STATUS_ACTIVE}}, :method => :post, :class => 'icon icon-unlock' %>
-    <% else -%>
-        <%= link_to l(:button_lock), {:action => 'edit', :id => user, :user => {:status => User::STATUS_LOCKED}}, :method => :post, :class => 'icon icon-lock' %>
-    <% end -%>
-    </small>
-    </td>
+    <td><small><%= change_status_link(user) %></small></td>
   </tr>
 <% end -%>
   </tbody>