Sha256: 2fefb849ec5ab8d9cb438d6732df12059d491af0b8fbcf5cc4958ab74fe5ecd9

Contents?: true

Size: 1.16 KB

Versions: 24

Compression:

Stored size: 1.16 KB

Contents

class Admin::UsersController < Admin::ResourceController
  paginate_models
  only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
    :when => :admin,
    :denied_url => { :controller => 'pages', :action => 'index' },
    :denied_message => 'You must have administrative privileges to perform this action.'

  before_filter :ensure_deletable, :only => [:remove, :destroy]
  
  def show
    redirect_to edit_admin_user_path(params[:id])
  end
  
  def update
    user_params = params[model_symbol]
    if user_params && user_params['admin'] == false && model == current_user
      user_params.delete('admin')
      annouce_cannot_remove_self_from_admin_role
    end
    model.update_attributes!(user_params)
    response_for :update
  end
  
  def ensure_deletable
    if current_user.id.to_s == params[:id].to_s
      announce_cannot_delete_self
      redirect_to admin_users_url
    end
  end
  
  private
  
    def announce_cannot_delete_self
      flash[:error] = t('users_controller.cannot_delete_self')
    end  
    
    def annouce_cannot_remove_self_from_admin_role
      flash[:error] = 'You cannot remove yourself from the admin role.'
    end
end

Version data entries

24 entries across 24 versions & 5 rubygems

Version Path
trusty-cms-1.0.0 app/controllers/admin/users_controller.rb
radiant-1.1.4 app/controllers/admin/users_controller.rb
radiant-1.1.3 app/controllers/admin/users_controller.rb
radiant-1.1.2 app/controllers/admin/users_controller.rb
radiant-1.1.1 app/controllers/admin/users_controller.rb
radiant-1.1.0 app/controllers/admin/users_controller.rb
radiant-1.1.0.rc1 app/controllers/admin/users_controller.rb
radiant-1.1.0.beta app/controllers/admin/users_controller.rb
radiant-1.0.1 app/controllers/admin/users_controller.rb
radiant-1.1.0.alpha app/controllers/admin/users_controller.rb
radiant-1.0.0 app/controllers/admin/users_controller.rb
radiant-1.0.0.rc5 app/controllers/admin/users_controller.rb
radiant-1.0.0.rc4 app/controllers/admin/users_controller.rb
radiant-1.0.0.rc3 app/controllers/admin/users_controller.rb
kajam-1.0.3.rc2 app/controllers/admin/users_controller.rb
radiant-1.0.0.rc2 app/controllers/admin/users_controller.rb
radiant-1.0.0.rc1 app/controllers/admin/users_controller.rb
radiant-rails3-0.1 app/controllers/admin/users_controller.rb
radiantcms-couchrest_model-0.1.4 app/controllers/admin/users_controller.rb
radiantcms-couchrest_model-0.1.3 app/controllers/admin/users_controller.rb