foreman_users 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +619 -0
- data/README.md +38 -0
- data/Rakefile +47 -0
- data/app/controllers/foreman_users/hosts_controller.rb +11 -0
- data/app/controllers/foreman_users/users_controller.rb +94 -0
- data/app/helpers/concerns/foreman_users/hosts_helper_extensions.rb +13 -0
- data/app/helpers/users_helper.rb +4 -0
- data/app/models/concerns/foreman_users/host_extensions.rb +19 -0
- data/app/models/group.rb +6 -0
- data/app/models/user.rb +67 -0
- data/app/overrides/dashboard/index/sample_override.html.erb.deface +4 -0
- data/app/views/dashboard/_foreman_users_widget.html.erb +2 -0
- data/app/views/foreman_users/hosts/hosts/new_action.html.erb +1 -0
- data/app/views/foreman_users/hosts/new_action.html.erb +1 -0
- data/app/views/foreman_users/layouts/layouts/new_layout.html.erb +0 -0
- data/app/views/foreman_users/layouts/new_layout.html.erb +0 -0
- data/app/views/foreman_users/users/_form.html.erb +94 -0
- data/app/views/foreman_users/users/_list.html.erb +57 -0
- data/app/views/foreman_users/users/_sub.html.erb +19 -0
- data/app/views/foreman_users/users/edit.html.erb +1 -0
- data/app/views/foreman_users/users/index.html.erb +5 -0
- data/app/views/foreman_users/users/new.html.erb +1 -0
- data/app/views/foreman_users/users/show.html.erb +77 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20150918022411_create_syusers.rb +17 -0
- data/db/migrate/20150918050239_create_sygroups.rb +12 -0
- data/db/migrate/20150918055455_add_syuser_id_to_sygroup.rb +5 -0
- data/lib/foreman_users/engine.rb +99 -0
- data/lib/foreman_users/version.rb +3 -0
- data/lib/foreman_users.rb +4 -0
- data/lib/tasks/foreman_users_tasks.rake +49 -0
- data/locale/Makefile +62 -0
- data/locale/en/foreman_users.po +19 -0
- data/locale/foreman_users.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/test/factories/foreman_users_factories.rb +5 -0
- data/test/test_plugin_helper.rb +6 -0
- data/test/unit/foreman_users_test.rb +11 -0
- metadata +134 -0
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ForemanUsers'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
task default: :test
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'rubocop/rake_task'
|
40
|
+
RuboCop::RakeTask.new
|
41
|
+
rescue => _
|
42
|
+
puts 'Rubocop not loaded.'
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default do
|
46
|
+
Rake::Task['rubocop'].execute
|
47
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ForemanUsers
|
2
|
+
# Example: Plugin's HostsController inherits from Foreman's HostsController
|
3
|
+
class HostsController < ::HostsController
|
4
|
+
# change layout if needed
|
5
|
+
# layout 'foreman_users/layouts/new_layout'
|
6
|
+
|
7
|
+
def new_action
|
8
|
+
# automatically renders view/foreman_users/hosts/new_action
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module ForemanUsers
|
2
|
+
class foreman_usersController < ApplicationController
|
3
|
+
# GET /foreman_users
|
4
|
+
# GET /foreman_users.json
|
5
|
+
def index
|
6
|
+
@users = foreman_user.all.paginate(:page => params[:page])
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html # index.html.erb
|
10
|
+
format.json { render json: @users }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /foreman_users/1
|
15
|
+
# GET /foreman_users/1.json
|
16
|
+
def show
|
17
|
+
@user = foreman_user.find(params[:id])
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
format.json { render json: @user }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /foreman_users/new
|
26
|
+
# GET /foreman_users/new.json
|
27
|
+
def new
|
28
|
+
@user = foreman_user.new
|
29
|
+
5.times { @user.sygroups.build}
|
30
|
+
#sygroups = @user.sygroups.new
|
31
|
+
respond_to do |format|
|
32
|
+
format.html # new.html.erb
|
33
|
+
format.json { render json: @user }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /foreman_users/1/edit
|
38
|
+
def edit
|
39
|
+
@user = foreman_user.find(params[:id])
|
40
|
+
sygroup_time = @user.sygroups.size
|
41
|
+
if sygroup_time == 0
|
42
|
+
5.times { @user.sygroups.build}
|
43
|
+
else
|
44
|
+
5.times { @user.sygroups.build}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# POST /foreman_users
|
49
|
+
# POST /foreman_users.json
|
50
|
+
def create
|
51
|
+
@user = foreman_user.new(params[:foreman_user])
|
52
|
+
|
53
|
+
respond_to do |format|
|
54
|
+
if @user.save
|
55
|
+
format.html { redirect_to @user, notice: 'foreman_user was successfully created.' }
|
56
|
+
format.json { render json: @user, status: :created, location: @user }
|
57
|
+
else
|
58
|
+
format.html { render action: "new" }
|
59
|
+
format.json { render json: @user.errors, status: :unprocessable_entity }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# PUT /foreman_users/1
|
65
|
+
# PUT /foreman_users/1.json
|
66
|
+
def update
|
67
|
+
@user = foreman_user.find(params[:id])
|
68
|
+
|
69
|
+
respond_to do |format|
|
70
|
+
if @user.update_attributes(params[:foreman_user])
|
71
|
+
format.html { redirect_to @user, notice: 'foreman_user was successfully updated.' }
|
72
|
+
format.json { head :no_content }
|
73
|
+
else
|
74
|
+
format.html { render action: "edit" }
|
75
|
+
format.json { render json: @user.errors, status: :unprocessable_entity }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# DELETE /foreman_users/1
|
81
|
+
# DELETE /foreman_users/1.json
|
82
|
+
def destroy
|
83
|
+
@user = foreman_user.find(params[:id])
|
84
|
+
@user.destroy
|
85
|
+
@user.destory_dir
|
86
|
+
respond_to do |format|
|
87
|
+
format.html { redirect_to foreman_users_url }
|
88
|
+
format.json { head :no_content }
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ForemanUsers
|
2
|
+
module HostExtensions
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
# execute callbacks
|
7
|
+
end
|
8
|
+
|
9
|
+
# create or overwrite instance methods...
|
10
|
+
def instance_method_name
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
# create or overwrite class methods...
|
15
|
+
def class_method_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/app/models/group.rb
ADDED
data/app/models/user.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
module ForemanUsers
|
2
|
+
class Syuser < ActiveRecord::Base
|
3
|
+
require "fileutils"
|
4
|
+
attr_accessible :title, :body, :name, :ensure , :gid, :groups, :home , :password, :password_max_age, :password_min_age, :shell, :uid, :sygroups_attributes
|
5
|
+
|
6
|
+
|
7
|
+
has_many :groups, :class_name => 'ForemanTasks::Group', :foreign_key => :user_id
|
8
|
+
accepts_nested_attributes_for :groups, reject_if: proc { |attributes| attributes['gid'].blank?| attributes['name'].blank? | attributes['ensure'].blank? } , allow_destroy: true
|
9
|
+
|
10
|
+
after_create :create_dir
|
11
|
+
after_update :create_dir
|
12
|
+
#after_destory :destory_dir
|
13
|
+
def create_dir
|
14
|
+
#目前用 "/home/stdtnt/app/"代替 "/etc/puppet/environments/production/modules/users"
|
15
|
+
#该处需要注意权限问题,当前用户是否具有该目录的操作权限
|
16
|
+
root_dir_name = "/etc/puppet/environments/production/modules/users"
|
17
|
+
self.destory_dir #默认删除该目录,然后重新创建
|
18
|
+
dir_exist_status = File.exist?(root_dir_name) #判断该目录是否存在
|
19
|
+
if !dir_exist_status
|
20
|
+
#创建目录结构
|
21
|
+
Dir::mkdir(root_dir_name)
|
22
|
+
Dir::mkdir(root_dir_name + "/files")
|
23
|
+
Dir::mkdir(root_dir_name + "/manifests")
|
24
|
+
|
25
|
+
#生成files下welcome.conf文件
|
26
|
+
files_welcome_File = File.new(root_dir_name + "/files/welcome.conf", "w+")
|
27
|
+
files_welcome_File.close
|
28
|
+
#生成manifests下init.pp文件
|
29
|
+
main_init_File = File.new(root_dir_name +"/manifests/init.pp", "w+")
|
30
|
+
if main_init_File
|
31
|
+
main_init_File.syswrite(self.create_content)
|
32
|
+
else
|
33
|
+
puts "Unable to open file!"
|
34
|
+
end
|
35
|
+
main_init_File.close
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def destory_dir
|
41
|
+
#目前用 "/home/stdtnt/app/"代替 "/etc/puppet/environments/production/modules/users"
|
42
|
+
#该处需要注意权限问题,当前用户是否具有该目录的操作权限
|
43
|
+
root_dir_name = "/etc/puppet/environments/production/modules/users"
|
44
|
+
#判断该目录是否存在
|
45
|
+
dir_exist_status = File.exist?(root_dir_name )
|
46
|
+
if dir_exist_status
|
47
|
+
#使用fileUtils.rm_r 删除该文件夹及其以下所有内容
|
48
|
+
FileUtils.rm_r root_dir_name
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_content
|
53
|
+
#content = "class users { " + "\n" + "\s\s" + "include baseline::params" + "\n" + "\s\s" + "@user {'$user':" + "\n" + "\s\s\s\s" + "ensure => $user_ensure," + "\n" + "\s\s\s\s" + "home => $user_home," + "\n" + "\s\s" + "}" + "\n" + "}"
|
54
|
+
#
|
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
|
+
|
57
|
+
group_content = "\s\s"
|
58
|
+
if self.sygroups.size > 0
|
59
|
+
self.sygroups.each do |sygroup|
|
60
|
+
group_content += "group {'"+ sygroup.name + "':" + "\n\s\s\s\s" + "ensure => '" + sygroup.ensure + "'," + "\n\s\s\s\s" + "gid => '" + sygroup.gid + "'," + "\n\s\s" +"}" + "\n\s\s"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
rs = user_content + group_content + "\n" + "}"
|
64
|
+
return rs
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Welcome to <b>ForemanUsers</b>
|
@@ -0,0 +1 @@
|
|
1
|
+
Welcome to <b>ForemanUsers</b>
|
File without changes
|
File without changes
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<%= javascript 'users', 'user_edit', 'user_edit_interfaces', 'class_edit', 'compute_resource', 'lookup_keys'%>
|
2
|
+
|
3
|
+
<%= form_for @user, :html => {:data => {:id => @user.try(:id), :submit => 'progress_bar'}} do |f| %>
|
4
|
+
<%= base_errors_for @user %>
|
5
|
+
<div class="row clearfix">
|
6
|
+
<div class="row">
|
7
|
+
<div class="form-group col-md-6">
|
8
|
+
<label>name</label>
|
9
|
+
<%= f.text_field :name, :size => "col-md-6", placeholder: "填写用户名", class: "form-control" %>
|
10
|
+
</div>
|
11
|
+
<div class="form-group col-md-6">
|
12
|
+
<label for="user_ensure">ensure</label> <br />
|
13
|
+
<%= f.select :ensure, [['Please select an ensure', nil], 'present', 'absent', 'role'], placeholder: "ensure", control_label: 'ensure', class: "form-control"%>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="row">
|
18
|
+
<div class="form-group col-md-6">
|
19
|
+
<label>gid</label>
|
20
|
+
<%= f.text_field :gid, :size => "col-md-6", placeholder: "填写gid", class: "form-control" %>
|
21
|
+
</div>
|
22
|
+
<div class="form-group col-md-6">
|
23
|
+
<label>groups</label>
|
24
|
+
<%= f.text_field :groups, :size => "col-md-6", placeholder: "填写组名", class: "form-control" %>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
|
29
|
+
<div class="row">
|
30
|
+
<div class="form-group col-md-6">
|
31
|
+
<label>home</label>
|
32
|
+
<%= f.text_field :home, :size => "col-md-6", placeholder: "填写用户名", class: "form-control"%>
|
33
|
+
</div>
|
34
|
+
<div class="form-group col-md-6">
|
35
|
+
<label>password</label>
|
36
|
+
<%= f.text_field :password, :size => "col-md-6", placeholder: "填写密码" , class: "form-control"%>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
|
41
|
+
<div class="row">
|
42
|
+
<div class="form-group col-md-6">
|
43
|
+
<label>password_max_age</label>
|
44
|
+
<%= f.text_field :password_max_age, :size => "col-md-6", placeholder: "填写用户名" , class: "form-control"%>
|
45
|
+
</div>
|
46
|
+
<div class="form-group col-md-6">
|
47
|
+
<label>password_min_age</label>
|
48
|
+
<%= f.text_field :password_min_age, :size => "col-md-6", placeholder: "填写用户名", class: "form-control"%>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div class="row">
|
53
|
+
<div class="form-group col-md-6">
|
54
|
+
<label>shell</label>
|
55
|
+
<%= f.text_field :shell, :size => "col-md-6", placeholder: "填写shell,例如: /bin/bash" , class: "form-control"%>
|
56
|
+
</div>
|
57
|
+
<div class="form-group col-md-6">
|
58
|
+
<label>uid</label>
|
59
|
+
<%= f.text_field :uid, :size => "col-md-6", placeholder: "填写uid,例如:609", class: "form-control"%>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
<p><span style="color:red">以下为group信息</span>
|
63
|
+
</p>
|
64
|
+
|
65
|
+
<div class="row">
|
66
|
+
<label class=" col-md-4">name</label><label class=" col-md-4">ensure</label><label class=" col-md-4">gid</label>
|
67
|
+
</div>
|
68
|
+
<%= f.fields_for :sygroups do |sygroups_form| %>
|
69
|
+
|
70
|
+
<div class="row">
|
71
|
+
<div class=" form-group col-md-4">
|
72
|
+
<%= sygroups_form.text_field :name, :size => "col-md-4", placeholder: "填写shell,例如: /bin/bash" , class: "form-control"%>
|
73
|
+
</div>
|
74
|
+
<div class=" form-group col-md-4">
|
75
|
+
<%= sygroups_form.text_field :ensure, :size => "col-md-4", placeholder: "填写shell,例如: /bin/bash" , class: "form-control"%>
|
76
|
+
</div>
|
77
|
+
<div class=" form-group col-md-4">
|
78
|
+
<%= sygroups_form.text_field :gid, :size => "col-md-4", placeholder: "填写shell,例如: /bin/bash" , class: "form-control"%>
|
79
|
+
</div>
|
80
|
+
</div>
|
81
|
+
|
82
|
+
|
83
|
+
<% end %>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<div class="actions">
|
90
|
+
<%= f.submit "提交", class: "btn btn-success" %>
|
91
|
+
<%= link_to '返回', users_path, class: "btn btn-primary" %>
|
92
|
+
</div>
|
93
|
+
<% end %>
|
94
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<%= javascript "jquery.cookie" %>
|
2
|
+
<% title header ||= "" %>
|
3
|
+
<table class="table table-bordered table-striped table-condensed" >
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th class=''>name</th>
|
7
|
+
<th class="hidden-xs">ensure</th>
|
8
|
+
<th class="hidden-xs">gid</th>
|
9
|
+
<th class="hidden-tablet hidden-xs">groups</th>
|
10
|
+
<th class="hidden-tablet hidden-xs">home</th>
|
11
|
+
<th class="hidden-tablet hidden-xs">password</th>
|
12
|
+
<th class="hidden-tablet hidden-xs">password_max_age</th>
|
13
|
+
<th class="hidden-tablet hidden-xs">password_min_age</th>
|
14
|
+
<th class="hidden-tablet hidden-xs">shell</th>
|
15
|
+
<th class="hidden-tablet hidden-xs">uid</th>
|
16
|
+
<th>操作</th>
|
17
|
+
</tr>
|
18
|
+
</thead>
|
19
|
+
<tbody>
|
20
|
+
<% users.each do |user| %>
|
21
|
+
<tr>
|
22
|
+
<td class=''><%= user.name %></td>
|
23
|
+
<td class="hidden-xs"><%= user.ensure %></td>
|
24
|
+
<td class="hidden-xs"><%= user.gid %></td>
|
25
|
+
<td class="hidden-tablet hidden-xs"><%= user.groups %></td>
|
26
|
+
<td class="hidden-tablet hidden-xs"><%= user.home %></td>
|
27
|
+
<td class="hidden-tablet hidden-xs"><%= user.password %></td>
|
28
|
+
<td class="hidden-tablet hidden-xs"><%= user.password_max_age %></td>
|
29
|
+
<td class="hidden-tablet hidden-xs"><%= user.password_min_age %></td>
|
30
|
+
<td class="hidden-tablet hidden-xs"><%= user.shell %></td>
|
31
|
+
<td class="hidden-tablet hidden-xs"><%= user.uid %></td>
|
32
|
+
<td>
|
33
|
+
<%= link_to '查看', user %>
|
34
|
+
<%= link_to '编辑', edit_user_path(user) %>
|
35
|
+
<%= link_to '删除', user, method: :delete, data: { confirm: 'Are you sure?' } %>
|
36
|
+
</td>
|
37
|
+
</tr>
|
38
|
+
<% end %>
|
39
|
+
</tbody>
|
40
|
+
</table>
|
41
|
+
<div id="confirmation-modal" class="modal fade">
|
42
|
+
<div class="modal-dialog">
|
43
|
+
<div class="modal-content">
|
44
|
+
<div class="modal-header">
|
45
|
+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
46
|
+
<h4 class="modal-title"><%= _('Please Confirm') %></h4>
|
47
|
+
</div>
|
48
|
+
<div class="modal-body">
|
49
|
+
</div>
|
50
|
+
<div class="modal-footer">
|
51
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _('Cancel') %></button>
|
52
|
+
<button type="button" class="btn btn-primary" onclick="submit_modal_form()"><%= _('Submit') %></button>
|
53
|
+
</div>
|
54
|
+
</div><!-- /.modal-content -->
|
55
|
+
</div><!-- /.modal-dialog -->
|
56
|
+
</div><!-- /.modal -->
|
57
|
+
<%= will_paginate_with_info users, :more => " - "+_("<b class='select_count'>0</b> selected") %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div id="group">
|
2
|
+
<%= f.fields_for :group do |f| %>
|
3
|
+
<div class="row">
|
4
|
+
<div class="col-md-4 column form-group">
|
5
|
+
<%= text_f f, :name, :help_inline => _("填写用户名") %>
|
6
|
+
</div>
|
7
|
+
<div class="col-md-4 column form-group">
|
8
|
+
<%= text_f f, :name, :help_inline => _("填写用户名") %>
|
9
|
+
</div>
|
10
|
+
<div class="col-md-4 column form-group">
|
11
|
+
<%= text_f f, :name, :help_inline => _("填写用户名") %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<%= f.hidden_field :groupable_id, value: object.id %>
|
15
|
+
<%= f.hidden_field :groupable_type, value: object.class.to_s %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<%#= f.link_to_add "新增酒店", :group, :data => { :target => "#group" }, class: "btn btn-primary btn-xs mb1" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,77 @@
|
|
1
|
+
|
2
|
+
<div class="container">
|
3
|
+
<div class="row">
|
4
|
+
<h1 class="clearfix">
|
5
|
+
<%= @user.name %>
|
6
|
+
<%= link_to '返回', user_path, class: "btn btn-primary pull-right mr1" %>
|
7
|
+
<%= link_to '编辑', edit_user_path(@user), class: "btn btn-warning pull-right mr1" %>
|
8
|
+
</h1>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="row col-md-12">
|
12
|
+
<table class="table table-striped table-bordered">
|
13
|
+
<thead></thead>
|
14
|
+
<tbody>
|
15
|
+
<tr>
|
16
|
+
<td><strong>name</strong></td>
|
17
|
+
<td><strong>ensure</strong></td>
|
18
|
+
<td><strong>gid</strong></td>
|
19
|
+
<td><strong>groups</strong></td>
|
20
|
+
</tr>
|
21
|
+
<tr>
|
22
|
+
<td><%= @user.name %></td>
|
23
|
+
<td><%= @user.ensure %></td>
|
24
|
+
<td><%= @user.gid %></td>
|
25
|
+
<td><%= @user.groups %></td>
|
26
|
+
</tr>
|
27
|
+
|
28
|
+
<tr>
|
29
|
+
<td><strong>home</strong></td>
|
30
|
+
<td><strong>password</strong></td>
|
31
|
+
<td><strong>password_max_age</strong></td>
|
32
|
+
<td><strong>password_min_age</strong></td>
|
33
|
+
</tr>
|
34
|
+
<tr>
|
35
|
+
<td><%= @user.home %></td>
|
36
|
+
<td><%= @user.password %></td>
|
37
|
+
<td><%= @user.password_max_age %></td>
|
38
|
+
<td><%= @user.password_min_age %></td>
|
39
|
+
</tr>
|
40
|
+
|
41
|
+
<tr>
|
42
|
+
<td><strong>shell</strong></td>
|
43
|
+
<td><strong>uid</strong></td>
|
44
|
+
<td><strong>created_at</strong></td>
|
45
|
+
<td><strong>updated_at</strong></td>
|
46
|
+
</tr>
|
47
|
+
<tr>
|
48
|
+
<td><%= @user.shell %></td>
|
49
|
+
<td><%= @user.uid %></td>
|
50
|
+
<td><%= @user.created_at %></td>
|
51
|
+
<td><%= @user.updated_at %></td>
|
52
|
+
</tr>
|
53
|
+
</tbody>
|
54
|
+
</table>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div class="row col-md-12">
|
58
|
+
<h2>groupList</h2>
|
59
|
+
<table class="table table-striped table-bordered">
|
60
|
+
<thead>
|
61
|
+
<th>groub_name</th>
|
62
|
+
<th>ensure</th>
|
63
|
+
<th>gid</th>
|
64
|
+
</thead>
|
65
|
+
<tbody>
|
66
|
+
<% @user.sygroups.each do |sygroup|%>
|
67
|
+
<tr class="success">
|
68
|
+
<td><%= sygroup.name %></td>
|
69
|
+
<td><%= sygroup.ensure %></td>
|
70
|
+
<td><%= sygroup.gid %></td>
|
71
|
+
</tr>
|
72
|
+
<% end %>
|
73
|
+
</tbody>
|
74
|
+
</table>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
</div>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
match 'index', to: 'foreman_users/users#index'
|
3
|
+
match 'show', to: 'foreman_users/users#show'
|
4
|
+
match 'new', to: 'foreman_users/users#new'
|
5
|
+
match 'edit', to: 'foreman_users/users#edit'
|
6
|
+
match 'create', to: 'foreman_users/users#create'
|
7
|
+
match 'update', to: 'foreman_users/users#update'
|
8
|
+
match 'destroy', to: 'foreman_users/users#destroy'
|
9
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateSyusers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :syusers do |t|
|
4
|
+
t.string :name #名称
|
5
|
+
t.string :ensure #下拉菜单
|
6
|
+
t.string :gid #输入框
|
7
|
+
t.string :groups #多选
|
8
|
+
t.string :home #输入
|
9
|
+
t.string :password
|
10
|
+
t.string :password_max_age
|
11
|
+
t.string :password_min_age
|
12
|
+
t.string :shell
|
13
|
+
t.string :uid
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|