foreman_users 0.0.18.3 → 0.0.18.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/foreman_users/users_controller.rb +6 -8
- data/app/models/foreman_users/group.rb +4 -6
- data/app/models/foreman_users/user.rb +3 -5
- data/app/views/foreman_users/users/_form.html.erb +1 -1
- data/app/views/foreman_users/users/show.html.erb +1 -1
- data/lib/foreman_users/version.rb +1 -1
- metadata +1 -1
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
class UsersController < ApplicationController
|
1
|
+
class ForemanUsers::UsersController < ApplicationController
|
3
2
|
# GET /foreman_users
|
4
3
|
# GET /foreman_users.json
|
5
4
|
def index
|
@@ -26,7 +25,7 @@ module ForemanUsers
|
|
26
25
|
# GET /foreman_users/new.json
|
27
26
|
def new
|
28
27
|
@foreman_users_user = ForemanUsers::User.new
|
29
|
-
5.times { @foreman_users_user.
|
28
|
+
5.times { @foreman_users_user.foreman_users_groups.build}
|
30
29
|
respond_to do |format|
|
31
30
|
format.html # new.html.erb
|
32
31
|
format.json { render json: @foreman_users_user }
|
@@ -36,11 +35,11 @@ module ForemanUsers
|
|
36
35
|
# GET /foreman_users/1/edit
|
37
36
|
def edit
|
38
37
|
@foreman_users_user = ForemanUsers::User.find(params[:id])
|
39
|
-
group_time = @foreman_users_user.
|
38
|
+
group_time = @foreman_users_user.foreman_users_groups.size
|
40
39
|
if group_time == 0
|
41
|
-
5.times { @foreman_users_user.
|
40
|
+
5.times { @foreman_users_user.foreman_users_groups.build}
|
42
41
|
else
|
43
|
-
5.times { @foreman_users_user.
|
42
|
+
5.times { @foreman_users_user.foreman_users_groups.build}
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -89,5 +88,4 @@ module ForemanUsers
|
|
89
88
|
|
90
89
|
|
91
90
|
end
|
92
|
-
end
|
93
|
-
end
|
91
|
+
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
6
|
-
end
|
1
|
+
class ForemanUsers::Group < ActiveRecord::Base
|
2
|
+
attr_accessible :groupname, :ensure, :gid, :groupable_type, :groupable_id, :user_id
|
3
|
+
belongs_to :user, class_name: "ForemanUsers::User"
|
4
|
+
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require "fileutils"
|
2
|
-
|
3
|
-
class User < ActiveRecord::Base
|
2
|
+
class ForemanUsers::User < ActiveRecord::Base
|
4
3
|
|
5
4
|
attr_accessible :title, :body, :username, :ensure , :gid, :groups, :home , :password, :password_max_age, :password_min_age, :shell, :uid, :groups_attributes
|
6
5
|
|
7
6
|
|
8
|
-
has_many :
|
7
|
+
has_many :foreman_users_groups, :class_name => 'ForemanUsers::ForemanUsers::Group', :foreign_key => :user_id
|
9
8
|
accepts_nested_attributes_for :groups, reject_if: proc { |attributes| attributes['gid'].blank?| attributes['name'].blank? | attributes['ensure'].blank? } , allow_destroy: true
|
10
9
|
|
11
10
|
after_create :create_dir
|
@@ -64,5 +63,4 @@ module ForemanUsers
|
|
64
63
|
rs = user_content + group_content + "\n" + "}"
|
65
64
|
return rs
|
66
65
|
end
|
67
|
-
end
|
68
|
-
end
|
66
|
+
end
|
@@ -65,7 +65,7 @@
|
|
65
65
|
<div class="row">
|
66
66
|
<label class=" col-md-4">name</label><label class=" col-md-4">ensure</label><label class=" col-md-4">gid</label>
|
67
67
|
</div>
|
68
|
-
<%= f.fields_for :
|
68
|
+
<%= f.fields_for :foreman_users_groups do |groups_form| %>
|
69
69
|
|
70
70
|
<div class="row">
|
71
71
|
<div class=" form-group col-md-4">
|