foreman_users 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/foreman_users/users_controller.rb +5 -6
- data/app/helpers/users_helper.rb +1 -1
- data/app/models/group.rb +1 -1
- data/app/models/user.rb +5 -5
- data/app/views/foreman_users/users/_form.html.erb +4 -4
- data/app/views/foreman_users/users/show.html.erb +4 -4
- data/lib/foreman_users/version.rb +1 -1
- metadata +1 -1
@@ -26,8 +26,7 @@ module ForemanUsers
|
|
26
26
|
# GET /foreman_users/new.json
|
27
27
|
def new
|
28
28
|
@user = foreman_user.new
|
29
|
-
5.times { @user.
|
30
|
-
#sygroups = @user.sygroups.new
|
29
|
+
5.times { @user.groups.build}
|
31
30
|
respond_to do |format|
|
32
31
|
format.html # new.html.erb
|
33
32
|
format.json { render json: @user }
|
@@ -37,11 +36,11 @@ module ForemanUsers
|
|
37
36
|
# GET /foreman_users/1/edit
|
38
37
|
def edit
|
39
38
|
@user = foreman_user.find(params[:id])
|
40
|
-
|
41
|
-
if
|
42
|
-
5.times { @user.
|
39
|
+
group_time = @user.groups.size
|
40
|
+
if group_time == 0
|
41
|
+
5.times { @user.groups.build}
|
43
42
|
else
|
44
|
-
5.times { @user.
|
43
|
+
5.times { @user.groups.build}
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
data/app/helpers/users_helper.rb
CHANGED
data/app/models/group.rb
CHANGED
data/app/models/user.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ForemanUsers
|
2
|
-
class
|
2
|
+
class User < ActiveRecord::Base
|
3
3
|
require "fileutils"
|
4
|
-
attr_accessible :title, :body, :name, :ensure , :gid, :groups, :home , :password, :password_max_age, :password_min_age, :shell, :uid, :
|
4
|
+
attr_accessible :title, :body, :name, :ensure , :gid, :groups, :home , :password, :password_max_age, :password_min_age, :shell, :uid, :groups_attributes
|
5
5
|
|
6
6
|
|
7
7
|
has_many :groups, :class_name => 'ForemanTasks::Group', :foreign_key => :user_id
|
@@ -55,9 +55,9 @@ module ForemanUsers
|
|
55
55
|
user_content = "class users {" + "\n" + "\s\s" + "user { '" + self.name + "':" + "\n\s\s\s\s" + "ensure => '" + self.ensure + "'," + "\n\s\s\s\s" + "gid => '" + self.gid + "'," + "\n\s\s\s\s" + "groups => [" + self.groups + "]," + "\n\s\s\s\s" + "home => '" + self.home + "'," + "\n\s\s\s\s" + "password => '" + self.password + "'," + "\n\s\s\s\s" + "password_max_age => '" + self.password_max_age + "'," + "\n\s\s\s\s" + "password_min_age => '" + self.password_min_age + "'," + "\n\s\s\s\s" + "shell => '" + self.shell + "'," + "\n\s\s\s\s" + "uid => '" + self.uid + "'," + "\n\s\s" +"}" + "\n"
|
56
56
|
|
57
57
|
group_content = "\s\s"
|
58
|
-
if self.
|
59
|
-
self.
|
60
|
-
group_content += "group {'"+
|
58
|
+
if self.groups.size > 0
|
59
|
+
self.groups.each do |group|
|
60
|
+
group_content += "group {'"+ group.name + "':" + "\n\s\s\s\s" + "ensure => '" + group.ensure + "'," + "\n\s\s\s\s" + "gid => '" + group.gid + "'," + "\n\s\s" +"}" + "\n\s\s"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
rs = user_content + group_content + "\n" + "}"
|
@@ -65,17 +65,17 @@
|
|
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 :groups do |groups_form| %>
|
69
69
|
|
70
70
|
<div class="row">
|
71
71
|
<div class=" form-group col-md-4">
|
72
|
-
<%=
|
72
|
+
<%= groups_form.text_field :name, :size => "col-md-4", placeholder: "填写shell,例如: /bin/bash" , class: "form-control"%>
|
73
73
|
</div>
|
74
74
|
<div class=" form-group col-md-4">
|
75
|
-
<%=
|
75
|
+
<%= groups_form.text_field :ensure, :size => "col-md-4", placeholder: "填写shell,例如: /bin/bash" , class: "form-control"%>
|
76
76
|
</div>
|
77
77
|
<div class=" form-group col-md-4">
|
78
|
-
<%=
|
78
|
+
<%= groups_form.text_field :gid, :size => "col-md-4", placeholder: "填写shell,例如: /bin/bash" , class: "form-control"%>
|
79
79
|
</div>
|
80
80
|
</div>
|
81
81
|
|
@@ -63,11 +63,11 @@
|
|
63
63
|
<th>gid</th>
|
64
64
|
</thead>
|
65
65
|
<tbody>
|
66
|
-
<% @user.
|
66
|
+
<% @user.groups.each do |group|%>
|
67
67
|
<tr class="success">
|
68
|
-
<td><%=
|
69
|
-
<td><%=
|
70
|
-
<td><%=
|
68
|
+
<td><%= group.name %></td>
|
69
|
+
<td><%= group.ensure %></td>
|
70
|
+
<td><%= group.gid %></td>
|
71
71
|
</tr>
|
72
72
|
<% end %>
|
73
73
|
</tbody>
|