Permalink
Browse files

adding unban action

  • Loading branch information...
1 parent 32a4133 commit c82548a7e49b2963e152b4043a61d6183ef9bc91 erik committed Jul 9, 2012
Showing with 14 additions and 2 deletions.
  1. +8 −1 app/controllers/profiles_controller.rb
  2. +5 −1 app/views/profiles/_profile.html.erb
  3. +1 −0 config/routes.rb
@@ -1,7 +1,7 @@
class ProfilesController < ApplicationController
#resources_controller_for :profiles, :class => User #, :only => [:show]
#before_filter :redirect_appropriately, :except => [:show]
- before_filter :get_profile, :unless => :ban
+ before_filter :get_profile, :except => :ban
def ban
@profile = User.find(params[:id])
@@ -10,6 +10,13 @@ def ban
return
end
+ def unban
+ @profile = User.find(params[:id])
+ @profile.update_attributes({:is_banned => false}) if current_user && current_user.is_a?(Admin) && @profile
+ redirect_to :back
+ return
+ end
+
private
def redirect_appropriately
@@ -67,7 +67,11 @@
<h3>Admin</h3>
<%=link_to 'Show', admin_user_path(@profile)%> |
<%=link_to 'Edit', edit_admin_user_path(@profile)%> |
- <%=link_to 'Ban', "/profiles/#{@profile.id}/ban"%> |
+ <%unless @profile.is_banned?%>
+ <%=link_to 'Ban', "/profiles/#{@profile.id}/ban"%> |
+ <%else%>
+ <%=link_to 'Unban', "/profiles/#{@profile.id}/unban"%> |
+ <%end%>
<%=link_to 'Destroy', admin_user_path(@profile), :confirm => 'Are you sure?', :method => :delete%> |
<%=link_to 'Log in as', log_in_as_admin_user_path(@profile)%>
<%unless @profile.is_a?(Sponsor)%>
View
@@ -36,6 +36,7 @@
map.connect "/pages/sponsors", :controller => "pages", :action => "sponsors"
map.resources :donations, :credit_pitches, :affiliations, :pledges, :pages, :groups
map.connect "/profiles/:id/ban", :controller => "profiles", :action => "ban"
+ map.connect "/profiles/:id/unban", :controller => "profiles", :action => "unban"
map.resources :profiles
map.resources :stories, :member => {:accept => :put, :reject => :put, :fact_check => :put, :publish => :put}, :has_many => :comments
map.resources :tips, :has_many => [:affiliations, :comments]

0 comments on commit c82548a

Please sign in to comment.