Class: Admin::Muck::UsersController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::Muck::UsersController
- Defined in:
- app/controllers/admin/muck/users_controller.rb
Instance Method Summary collapse
- #activate_all ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #inactive ⇒ Object
- #inactive_emails ⇒ Object
- #index ⇒ Object
- #permissions ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#activate_all ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/controllers/admin/muck/users_controller.rb', line 46 def activate_all User.activate_all respond_to do |format| format.html do redirect_to inactive_admin_users_path end end end |
#destroy ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'app/controllers/admin/muck/users_controller.rb', line 120 def destroy if @user.admin? flash[:notice] = translate('muck.users.cant_delete_admin') else @user.destroy flash[:notice] = translate('muck.users.user_successfully_deleted', :login => @user.login) end respond_to do |format| format.html { redirect_to admin_users_path } format.js do if @user.admin? else render :js => "jQuery('##{@user.dom_id('row')}').fadeOut();" end end end end |
#edit ⇒ Object
64 65 66 |
# File 'app/controllers/admin/muck/users_controller.rb', line 64 def edit render :template => 'admin/users/edit', :layout => false end |
#inactive ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/controllers/admin/muck/users_controller.rb', line 30 def inactive @user_inactive_count = User.inactive_count @users = User.inactive.paginate(:page => @page, :per_page => @per_page) respond_to do |format| format.html { render :template => 'admin/users/inactive' } end end |
#inactive_emails ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/controllers/admin/muck/users_controller.rb', line 38 def inactive_emails @user_inactive_count = User.inactive_count @users = User.inactive respond_to do |format| format.html { render :template => 'admin/users/inactive_emails' } end end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/admin/muck/users_controller.rb', line 6 def index respond_to do |format| format.html do @user_count = User.count @user_inactive_count = User.inactive_count @users = User.by_newest.paginate(:page => @page, :per_page => @per_page, :include => ['roles']) render :template => 'admin/users/index' end format.csv do @users = User.find(:all) headers["Content-Type"] = 'text/csv' headers["Content-Disposition"] = "attachment; filename=\"users.csv\"" render :template => 'admin/users/index', :layout => false end end end |
#permissions ⇒ Object
139 140 141 |
# File 'app/controllers/admin/muck/users_controller.rb', line 139 def render :template => 'admin/users/permissions', :layout => false end |
#search ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'app/controllers/admin/muck/users_controller.rb', line 55 def search @is_search = true @users = User.where("first_name LIKE ? OR last_name LIKE ? OR email LIKE ?", params[:query], params[:query], params[:query] ).paginate(:page => @page, :per_page => @per_page ) respond_to do |format| format.html { render :template => 'admin/users/index' } format.js { render :partial => 'admin/users/table', :layout => false } end end |
#show ⇒ Object
23 24 25 26 27 28 |
# File 'app/controllers/admin/muck/users_controller.rb', line 23 def show @user = User.find(params[:id]) respond_to do |format| format.html { render :template => 'admin/users/show' } end end |
#update ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'app/controllers/admin/muck/users_controller.rb', line 68 def update if params[:deactivate] if is_me?(@user) flash[:notice] = translate("muck.users.cannot_deactivate_yourself") else if @user.admin? flash[:notice] = translate('muck.users.cant_disable_admin') else if @user.deactivate! return update_activate(translate('muck.users.user_marked_inactive')) else flash[:notice] = translate('muck.users.user_not_deactivated_error') end end end elsif params[:activate] if @user.activate! return update_activate(translate('muck.users.user_marked_active')) else flash[:notice] = translate('muck.users.user_not_activated_error') end elsif params[:update_roles] params[:user] ||= {} params[:user][:role_ids] ||= [] if @user.update_attributes(params[:user]) return end else # Standard update if @user.update_attributes(params[:user]) respond_to do |format| format.html do flash[:notice] = translate('muck.users.user_update_sucess') redirect_to admin_users_path end format.js { render :template => 'admin/users/row', :layout => false } end else respond_to do |format| format.html { render :template => 'admin/users/edit' } format.js { (@user) } end end return end respond_to do |format| format.html { redirect_to admin_users_path } format.js { (@user) } end end |