Sha256: 8df5d81a3f29b980a77e523aa87872d1db52cb0928880b65007dd9039e492d54

Contents?: true

Size: 1.71 KB

Versions: 17

Compression:

Stored size: 1.71 KB

Contents

class Admin::Muck::RolesController < Admin::Muck::BaseController
  unloadable
  
  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

17 entries across 17 versions & 1 rubygems

Version Path
muck-users-0.3.20 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.19 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.18 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.17 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.16 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.15 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.14 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.13 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.12 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.11 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.10 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.9 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.8 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.7 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.6 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.4 app/controllers/admin/muck/roles_controller.rb
muck-users-0.3.3 app/controllers/admin/muck/roles_controller.rb