Changeset 4724
- Timestamp:
- 08/08/06 18:41:00 (2 years ago)
- Files:
-
- applications/plugins (modified) (1 prop)
- applications/plugins/app/controllers/users_controller.rb (modified) (3 diffs)
- applications/plugins/app/views/sessions/new.rhtml (modified) (1 diff)
- applications/plugins/app/views/users/admin.rjs (added)
- applications/plugins/app/views/users/show.rhtml (modified) (1 diff)
- applications/plugins/config (modified) (1 prop)
- applications/plugins/config/routes.rb (modified) (1 diff)
- applications/plugins/db (modified) (1 prop)
- applications/plugins/lib/authenticated_system.rb (modified) (2 diffs)
- applications/plugins/log (modified) (1 prop)
- applications/plugins/public/images/progress.gif (added)
- applications/plugins/public/javascripts/application.js (modified) (1 diff)
- applications/plugins/test/functional/users_controller_test.rb (modified) (2 diffs)
- applications/plugins/vendor (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
applications/plugins
- Property svn:ignore set to
.rake_tasks
- Property svn:ignore set to
applications/plugins/app/controllers/users_controller.rb
r4722 r4724 1 1 class UsersController < ApplicationController 2 before_filter :find_user, :except => [:index, :new, :create] 3 before_filter :login_required, :except => [:index, :new, :create, :show] 4 2 5 def index 3 6 @user_pages, @users = paginate :users, :order => 'login', :per_page => 50 … … 9 12 10 13 def show 11 @user = User.find params[:id]12 14 @ratings = @user.rated_plugins.find(:all, :order => 'plugins.created_at desc', 13 15 :conditions => ['plugins.score = 1 and plugins.user_id != ?', @user.id], :limit => 15) … … 25 27 flash[:notice] = "Thanks for signing up!" 26 28 end 29 30 def admin 31 @user.update_attribute(:admin, !@user.admin?) 32 end 33 34 protected 35 def authorized? 36 current_user.admin? 37 end 38 39 def find_user 40 @user = User.find params[:id] 41 end 27 42 end applications/plugins/app/views/sessions/new.rhtml
r4723 r4724 1 <%= start_form_tag sessions_ url%>1 <%= start_form_tag sessions_path %> 2 2 <p><label for="login">Login</label><br/> 3 3 <%= text_field_tag 'login' %></p> applications/plugins/app/views/users/show.rhtml
r4722 r4724 25 25 </div> 26 26 </div> 27 28 <% if admin? -%> 29 <div id="user-admin"> 30 <p> 31 <label>Admin? <%= check_box_tag :admin, '1', @user.admin?, :onchange => "User.toggleAdmin('#{@user.id}')" %></label> 32 <%= image_tag 'progress.gif', :id => 'user-admin-spinner', :style => 'display:none' %> 33 </p> 34 </div> 35 <% end -%> applications/plugins/config
- Property svn:ignore set to
database.yml
deploy.rb
- Property svn:ignore set to
applications/plugins/config/routes.rb
r4722 r4724 3 3 plugin.resources :comments, :ratings 4 4 end 5 map.resources :users, :sessions, :releases 5 map.resources :users, :member => { :admin => :post } 6 map.resources :sessions, :releases 6 7 7 8 map.signup '/signup', :controller => 'users', :action => 'new' applications/plugins/db
- Property svn:ignore set to
*.sqlite2
- Property svn:ignore set to
applications/plugins/lib/authenticated_system.rb
r4722 r4724 32 32 def authorized? 33 33 true 34 end 35 36 def admin? 37 logged_in? && current_user.admin? 34 38 end 35 39 … … 94 98 # available as ActionView helper methods. 95 99 def self.included(base) 96 base.send :helper_method, :current_user, :logged_in? 100 base.send :helper_method, :current_user, :logged_in?, :admin? 97 101 end 98 102 applications/plugins/log
- Property svn:ignore set to
*
- Property svn:ignore set to
applications/plugins/public/javascripts/application.js
r4722 r4724 4 4 } 5 5 } 6 7 var User = { 8 toggleAdmin: function(user_id) { 9 new Ajax.Request('/users/' + user_id + ';admin'); 10 $('user-admin-spinner').show(); 11 } 12 } applications/plugins/test/functional/users_controller_test.rb
r4722 r4724 40 40 assert_equal users(:quentin), assigns(:user) 41 41 assert_no_tag :tag => 'user' 42 assert_no_tag 'div', :attributes => { :id => 'user-admin' } 43 end 44 45 def test_should_show_admin_panel 46 login_as :quentin 47 get :show, :id => users(:quentin).id 48 assert_response :success 49 assert_tag 'div', :attributes => { :id => 'user-admin' } 42 50 end 43 51 … … 89 97 end 90 98 end 99 100 def test_should_require_admin_to_change_admin_status 101 [nil, :aaron].each do |u| 102 assert_requires_login u do |c| 103 c.post :admin, :id => users(:quentin).id 104 end 105 end 106 end 107 108 def test_should_disable_admin_status 109 login_as :quentin 110 post :admin, :id => users(:quentin).id 111 assert !users(:quentin).reload.admin? 112 end 113 114 def test_should_enable_admin_status 115 login_as :quentin 116 post :admin, :id => users(:aaron).id 117 assert users(:aaron).reload.admin? 118 end 91 119 92 120 protected applications/plugins/vendor
- Property svn:ignore set to
rails
- Property svn:ignore set to