Skip to content

Commit

Permalink
Allow User state changes by admin
Browse files Browse the repository at this point in the history
  • Loading branch information
ariejan committed Dec 22, 2008
1 parent 039dc85 commit 2f79a11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ def deleted
def activate
@user = User.find(params[:id])
@user.activate!
redirect_to admin_user_path(@user)
redirect_to admin_users_path
end

def suspend
@user = User.find(params[:id])
@user.suspend!
redirect_to admin_user_path(@user)
redirect_to admin_users_path
end

def unsuspend
@user = User.find(params[:id])
@user.unsuspend!
redirect_to admin_user_path(@user)
redirect_to admin_users_path
end

def purge
Expand All @@ -60,7 +60,7 @@ def destroy
@user = User.find(params[:id])
@user.delete!

redirect_to admin_user_path(@user)
redirect_to admin_users_path
end

# GET /admin_users
Expand Down Expand Up @@ -102,7 +102,7 @@ def create
@user = User.new(params[:user])

respond_to do |format|
if @user.save
if @user.register!
flash[:notice] = "User was successfully created."
format.html { redirect_to(admin_user_url(@user)) }
format.xml { render :xml => @user, :status => :created, :location => @user }
Expand Down
16 changes: 15 additions & 1 deletion app/views/admin/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@
<td><%=h user.email %></td>
<td><%=h user.state %></td>
<td class="actions">
<%= link_to 'Show', admin_user_url(user) %>
<% if user.pending? %>
<%= link_to 'activate', activate_admin_user_url(user), :method => :put %>
<%= link_to 'suspend', suspend_admin_user_url(user), :method => :put %>
<%= link_to 'delete', admin_user_url(user), :method => :delete, :confirm => "Are you sure?" %>
<% elsif user.passive? %>
<%= link_to 'activate', activate_admin_user_url(user), :method => :put %>
<%= link_to 'suspend', suspend_admin_user_url(user), :method => :put %>
<%= link_to 'delete', admin_user_url(user), :method => :delete, :confirm => "Are you sure?" %>
<% elsif user.active? %>
<%= link_to 'suspend', suspend_admin_user_url(user), :method => :put %>
<%= link_to 'delete', admin_user_url(user), :method => :delete, :confirm => "Are you sure?" %>
<% elsif user.suspended? %>
<%= link_to 'unsuspend', unsuspend_admin_user_url(user), :method => :put %>
<%= link_to 'delete', admin_user_url(user), :method => :delete, :confirm => "Are you sure?" %>
<% end %>
</td>
</tr>
<% end %>
Expand Down

0 comments on commit 2f79a11

Please sign in to comment.