Class: Gluttonberg::Admin::Settings::UsersController

Inherits:
BaseController show all
Defined in:
app/controllers/gluttonberg/admin/settings/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 24

def create
  @user = User.new
  set_role
  @user.assign_attributes(params[:user])

  if @user.save
    flash[:notice] = "Account registered!"
    redirect_to admin_users_path
  else
    prepare_authorizations
    render :action => :new
  end
end

#deleteObject



58
59
60
61
62
63
64
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 58

def delete
  display_delete_confirmation(
    :title      => "Delete “#{@user.email}” user?",
    :url        => admin_user_path(@user),
    :return_url => admin_users_path
  )
end

#destroyObject



66
67
68
69
70
71
72
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 66

def destroy
  generic_destroy(@user, {
    :name => "user",
    :success_path => admin_users_path,
    :failure_path => admin_users_path
  })
end

#editObject



38
39
40
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 38

def edit
  prepare_authorizations
end

#indexObject



11
12
13
14
15
16
17
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 11

def index
  unless current_user.super_admin? || current_user.admin?
    redirect_to :action => "edit" , :id => current_user.id
  end
  @users = User.search_users(params[:query], current_user, get_order)
  @users = @users.paginate(:page => params[:page] , :per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items") )
end

#newObject



19
20
21
22
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 19

def new
  @user = User.new
  prepare_authorizations
end

#updateObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/gluttonberg/admin/settings/users_controller.rb', line 42

def update
  set_role
  if @user.update_attributes(params[:user])
    flash[:notice] = "Account updated!"
    if current_user.super_admin? || current_user.admin?
      redirect_to  admin_users_path
    else
      redirect_to  :action => :edit
    end
  else
    prepare_authorizations
    flash[:notice] = "Failed to save account changes!"
    render :action => :edit
  end
end