2010-03-04 08:33:26 +00:00
|
|
|
class Panel::UsersController < ApplicationController
|
|
|
|
|
|
|
|
layout "panel"
|
|
|
|
before_filter :authenticate_user!
|
|
|
|
|
|
|
|
def index
|
2011-04-13 10:19:51 +00:00
|
|
|
@users = User.all.entries
|
2010-03-04 08:33:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@user = User.new
|
2011-02-01 02:46:26 +00:00
|
|
|
@user_role_models = UserRoleModel.all.entries
|
2011-04-13 10:19:51 +00:00
|
|
|
session[:last_page] = get_go_back || panel_users_url
|
2010-03-04 08:33:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@user = User.new(params[:user])
|
|
|
|
if @user.save
|
|
|
|
redirect_to :action => :index
|
|
|
|
else
|
|
|
|
render :action => :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@user = User.find(params[:id])
|
2011-02-01 02:46:26 +00:00
|
|
|
@user_role_models = UserRoleModel.all.entries
|
2011-04-13 10:19:51 +00:00
|
|
|
session[:last_page] = get_go_back || panel_users_url
|
2010-03-04 08:33:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@user = User.find(params[:id])
|
2011-04-13 10:19:51 +00:00
|
|
|
|
|
|
|
# Update changes to the avatar
|
|
|
|
@user.remove_avatar! if params[:file]
|
|
|
|
@user.avatar = params[:file] if params[:file]
|
|
|
|
|
2010-03-04 08:33:26 +00:00
|
|
|
if @user.update_attributes(params[:user])
|
|
|
|
redirect_to :action => :index
|
|
|
|
else
|
2011-02-01 02:46:26 +00:00
|
|
|
@user_role_models = UserRoleModel.all.entries
|
2010-03-04 08:33:26 +00:00
|
|
|
render :action => :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
@user.destroy
|
|
|
|
|
|
|
|
redirect_to :action => :index
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|