Sha256: e4909a92be347901baecf53a00f771ed2c0812c500151748000b50c07616fc85

Contents?: true

Size: 1.7 KB

Versions: 62

Compression:

Stored size: 1.7 KB

Contents

class Admin::Muck::RolesController < Admin::Muck::BaseController
  
  def index
    @roles = Role.by_alpha
    render :template => 'admin/roles/index'
  end

  def show
    @role = Role.find(params[:id])
    @users = @role.users.paginate(:page => @page, :per_page => @per_page)
    render :template => 'admin/roles/show'
  end

  def new
    @role = Role.new(params[:role])
    render :template => 'admin/roles/new', :layout => false
  end

  def create
    @role = Role.new(params[:role])
    if @role.save
      ajax_update_roles
    else
      output_admin_messages(@role)
    end
  end

  def edit
    @role = Role.find(params[:id])
    render :template => 'admin/roles/edit', :layout => false
  end

  def update
    @role = Role.find(params[:id])
    if @role.update_attributes(params[:role])
      ajax_update_roles
    else
      output_admin_messages(@role)
    end
  end

  def destroy
    @role = Role.find(params[:id])
    if @role.rolename == 'administrator'
      flash[:notice] = translate('muck.users.cant_delete_administrator_role')
      output_admin_messages
    else
      success = @role.destroy
      flash[:notice] = translate('muck.users.role_not_deleted') if !success

      respond_to do |format|
        format.html do
          flash[:notice] = translate('muck.users.role_deleted') if success
          redirect_to admin_roles_path
        end
        format.xml  { head :ok }
        format.js do
          if success
            render :template => 'admin/roles/destroy', :layout => false
          else
            output_admin_messages
          end
        end
      end

    end
  end

  protected
    
    def ajax_update_roles
      render :template => 'admin/roles/ajax_update_roles'
    end
    
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
muck-users-3.2.25 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.24 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.23 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.22 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.21 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.20 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.19 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.18 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.17 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.16 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.15 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.14 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.13 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.12 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.11 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.10 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.9 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.8 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.7 app/controllers/admin/muck/roles_controller.rb
muck-users-3.2.6 app/controllers/admin/muck/roles_controller.rb