Sha256: 44668f3a6f2b3a1bdfcabbae4c7c40d3fca78f29173bc55a58adac508dc68c46

Contents?: true

Size: 1.12 KB

Versions: 6

Compression:

Stored size: 1.12 KB

Contents

class Admin::UsersController < Admin::BaseController

  cache_sweeper :blog_sweeper

  def index
    @users = User.paginate :page => params[:page], :order => 'login asc', :per_page => this_blog.admin_display_elements
  end

  def new
    @user = User.new(params[:user])
    @user.text_filter = TextFilter.find_by_name(this_blog.text_filter)
    setup_profiles
    @user.name = @user.login
    if request.post? and @user.save
      flash[:notice] = _('User was successfully created.')
      redirect_to :action => 'index'
    end
  end

  def edit
    @user = params[:id] ? User.find_by_id(params[:id]) : current_user

    setup_profiles
    @user.attributes = params[:user]
    if request.post? and @user.save
      if @user.id = current_user.id
        current_user = @user
      end
      flash[:notice] = _('User was successfully updated.')
      redirect_to :action => 'index'
    end
  end

  def destroy
    @user = User.find(params[:id])
    if request.post?
      @user.destroy if User.count > 1
      redirect_to :action => 'index'
    end
  end

  private

  def setup_profiles
    @profiles = Profile.find(:all, :order => 'id')
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typo-5.5 app/controllers/admin/users_controller.rb
typo-5.4.4 app/controllers/admin/users_controller.rb
typo-5.4.3 app/controllers/admin/users_controller.rb
typo-5.4.2 app/controllers/admin/users_controller.rb
typo-5.4.1 app/controllers/admin/users_controller.rb
typo-5.4 app/controllers/admin/users_controller.rb