Class: Bolt::UsersController

Inherits:
BoltController show all
Defined in:
app/controllers/bolt/users_controller.rb

Instance Method Summary collapse

Methods inherited from BoltController

#blank

Methods included from ConfigHelper

#bolt_config_dashboard_url, #bolt_config_email_from_address, #bolt_config_hostname, #bolt_config_javascript_includes, #bolt_config_logo, #bolt_config_stylesheet_includes, #bolt_config_website_name

Methods included from BoltHelper

#bolt_check_box, #bolt_check_box_group, #bolt_collection_select, #bolt_date_select, #bolt_datetime_select, #bolt_file_field, #bolt_generate_page_title, #bolt_get_access_level_array, #bolt_get_access_level_text, #bolt_get_full_version_string, #bolt_get_short_version_string, #bolt_get_version_info, #bolt_hidden_field, #bolt_password_field, #bolt_radio_button, #bolt_radio_button_group, #bolt_select, #bolt_show_icon, #bolt_show_row_icon, #bolt_table_cell_link, #bolt_table_cell_no_link, #bolt_text_area, #bolt_text_area_big, #bolt_text_field, #bolt_time_select, #bolt_time_zone_select

Instance Method Details

#createObject

POST /bolt/users POST /bolt/users.json



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/bolt/users_controller.rb', line 46

def create
  @bolt_user = Bolt::User.new(params[:bolt_user])
  
  respond_to do |format|
    if @bolt_user.save
	  flash[:success] = 'User was successfully created.'
      format.html { redirect_to :action=>'index'}
      format.json { render :json => @bolt_users, :status => "created", :location => @bolt_user }
    else
	  @groups = Group.all	
      format.html { render :action => "new" }
      format.json { render :json => @bolt_user.errors, :status => :unprocessable_entity}
    end
  end
end

#destroyObject

DELETE /bolt/users/1 DELETE /bolt/users/1.json



81
82
83
84
85
86
87
88
89
# File 'app/controllers/bolt/users_controller.rb', line 81

def destroy
  @bolt_user = Bolt::User.find(params[:id])
  @bolt_user.destroy

  respond_to do |format|
    format.html { redirect_to bolt_users_url }
    format.json { head :no_content }
  end
end

#destroy_multipleObject



91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/controllers/bolt/users_controller.rb', line 91

def destroy_multiple
  ids= params[:id]
  idarr=ids.split(',')
  idarr.each do |del|
    @bolt_user = User.find(del)
    @bolt_user.destroy
  end
  respond_to do |format|
    format.html { redirect_to :back  }
   # format.json { head :ok }
  end
end

#editObject

GET /bolt/users/1/edit



39
40
41
42
# File 'app/controllers/bolt/users_controller.rb', line 39

def edit
  @bolt_user = Bolt::User.find(params[:id])
  
end

#indexObject

GET /bolt/users GET /bolt/users.json



5
6
7
8
9
10
11
12
13
# File 'app/controllers/bolt/users_controller.rb', line 5

def index
  sortcolumn=(params[:sort]==nil)? 'name' : params[:sort]  
  @bolt_users = Bolt::User.find(:all, :order => sortcolumn)
 
  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @bolt_users }
  end
end

#newObject

GET /bolt/users/new GET /bolt/users/new.json



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/bolt/users_controller.rb', line 21

def new
  @bolt_user = Bolt::User.new
  
  @groups = Group.all
  
  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @bolt_users }
  end
end

#showObject



32
33
34
35
36
# File 'app/controllers/bolt/users_controller.rb', line 32

def show 
  @bolt_user = Bolt::User.find(params[:id])
  @u_groups = @bolt_user.groups.collect{|g| g.id}
  @groups = Group.all      
end

#updateObject

PUT /bolt/users/1 PUT /bolt/users/1.json



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/bolt/users_controller.rb', line 64

def update
  @bolt_user = Bolt::User.find(params[:id])

  respond_to do |format|
    if @bolt_user.update_attributes(params[:bolt_user])
 flash[:success] = 'User was successfully updated.'
      format.html { redirect_to :action=>'index' }
      format.json { head :no_content }
    else
      format.html { render :action => "show" }
      format.json { render :json => @bolt_user.errors, :status => :unprocessable_entity }
    end
  end
end