Permalink
Browse files

Archiving of users is now working correctly. (refs #34).

I have to go through and check for other instances where the "achived" scope is not being used correctly.
  • Loading branch information...
1 parent 3532a91 commit a67a2553359f9355d4ab53d1ba232f254e6f0acd @rnhurt committed Nov 6, 2010
Showing with 16 additions and 8 deletions.
  1. +2 −2 app/controllers/users_controller.rb
  2. +11 −5 app/views/users/_edit.html.erb
  3. +3 −1 config/routes.rb
@@ -1,6 +1,6 @@
class UsersController < ApplicationController
before_filter :require_user
- before_filter :decode_user_type, :except => ["archive"]
+ before_filter :decode_user_type, :except => ["archive", "impersonate"]
append_before_filter :authorized?
include SortHelper
@@ -12,6 +12,7 @@ def index
params[:sort_clause] = sort_clause
@users = @user_type.active.search(params)
end
+
# Show 'archived' users
def archived
sort_init 'last_name'
@@ -21,7 +22,6 @@ def archived
render :index
end
-
# Show the group of users
def show
sort_init 'last_name'
@@ -1,11 +1,9 @@
<div class='box span-13'>
<% form_for user do |f| %>
<fieldset>
- <% if user.new_record? %>
- <%= content_tag :legend, "New #{user.class.name.titleize}" %>
- <% else %>
- <%= content_tag :legend, "Editing: #{user.full_name}" %>
- <% end %>
+ <%= content_tag :legend, user.new_record? ? "New #{user.class.name.titleize}" : "Editing: #{user.full_name}" %>
+
+ <div class="clear">&nbsp;</div>
<%= f.label :login, {}, :class => 'req' %>
<%= f.text_field :login, :id => 'user_login', :class=>"focus input" %>
@@ -46,6 +44,14 @@
<div class="spacer">
<%= submit_tag 'Save', :class => 'btn positive' %>
<%= link_to 'Cancel', {:action=> 'index', :controller=> 'users/'+user.class.name.tableize}, :class => 'btn standard' %>
+
+ <%= link_to "Impersonate", impersonate_user_path(user),
+ :confirm => "Are you sure you want to impresonate '#{user.full_name}'?",
+ :method => :post, :class => "btn standard right" unless user.new_record? %>
+
+ <%= link_to "Delete", { :action => "destroy", :id => user },
+ :confirm => "** WARNING ** You are about to delete '#{user.full_name}'! Are you sure you want to proceed?",
+ :method => :delete, :class => "btn negative right" unless user.new_record? || user.is_admin? %>
</div>
</fieldset>
<% end %>
View
@@ -6,7 +6,9 @@
# Since we subclass the Users into different types,
# we need to build routes for them.
- map.resources :users, :member => { :archive => :post }, :collection => { :archived => :get }
+ map.resources :users,
+ :member => { :impersonate => :post, :archive => :post },
+ :collection => { :archived => :get }
map.namespace :users do |u|
u.resources :students, :name_prefix => nil
u.resources :teachers, :name_prefix => nil

0 comments on commit a67a255

Please sign in to comment.