ocp_registry 0.0.1.alpha → 0.0.5.pre
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/lib/ocp_registry.rb +1 -0
- data/lib/ocp_registry/api_controller.rb +106 -16
- data/lib/ocp_registry/application_manager.rb +185 -23
- data/lib/ocp_registry/cloud_manager/mock/mock.rb +7 -13
- data/lib/ocp_registry/common.rb +3 -1
- data/lib/ocp_registry/config.rb +5 -1
- data/lib/ocp_registry/db/002_create_settings_table.rb +13 -0
- data/lib/ocp_registry/db/003_alter_comments_column_in_applications_table.rb +13 -0
- data/lib/ocp_registry/db/004_add_from_field_for_settings.rb +13 -0
- data/lib/ocp_registry/mail_client.rb +2 -2
- data/lib/ocp_registry/models.rb +2 -1
- data/lib/ocp_registry/models/registry_application.rb +19 -0
- data/lib/ocp_registry/models/registry_setting.rb +7 -0
- data/lib/ocp_registry/version.rb +1 -1
- data/mail_template/approve_admin.erb +3 -2
- data/mail_template/approve_user.erb +3 -4
- data/mail_template/cancel_admin.erb +13 -0
- data/mail_template/cancel_user.erb +13 -0
- data/mail_template/modify.erb +25 -0
- data/mail_template/refuse_admin.erb +4 -3
- data/mail_template/refuse_user.erb +4 -4
- data/mail_template/request_admin.erb +3 -2
- data/mail_template/request_user.erb +3 -3
- data/public/comment_dialog.css +11 -0
- data/public/common.css +34 -71
- data/public/head_message.css +11 -0
- data/public/images/portrait_admin.png +0 -0
- data/public/images/portrait_applicant.png +0 -0
- data/public/{jquery-1.10.2.min.js → jquery/jquery-1.10.2.min.js} +0 -0
- data/public/{jquery-1.10.2.min.map → jquery/jquery-1.10.2.min.map} +0 -0
- data/public/{jquery.json-2.4.min.js → json/jquery.json-2.4.min.js} +0 -0
- data/public/page_specific.css +15 -0
- data/public/post.css +37 -0
- data/public/qTIp/jquery.qtip.min.css +2 -0
- data/public/qTIp/jquery.qtip.min.js +3 -0
- data/public/tenant_opt_dialog.css +3 -0
- data/public/tenant_options.css +18 -0
- data/public/util.js +14 -0
- data/spec/spec_common.rb +25 -0
- data/spec/unit/config_spec.rb +117 -0
- data/views/admin_review.erb +306 -0
- data/views/applicant_review.erb +223 -0
- data/views/apply.erb +84 -133
- data/views/base.erb +56 -6
- data/views/comment_list.erb +12 -0
- data/views/inform_comment_dialog.erb +10 -0
- data/views/post.erb +28 -0
- data/views/reject_comment_dialog.erb +10 -0
- data/views/tenant_options.erb +244 -0
- data/views/view.erb +44 -7
- metadata +35 -8
- data/views/review.erb +0 -141
- data/views/show.erb +0 -96
@@ -119,9 +119,9 @@ module Ocp::Registry
|
|
119
119
|
|
120
120
|
def create_tenant(name, description, enabled = true)
|
121
121
|
tenant = {
|
122
|
-
:name =>
|
123
|
-
:description =>
|
124
|
-
:enabled =>
|
122
|
+
:name => name,
|
123
|
+
:description => description,
|
124
|
+
:enabled => enabled,
|
125
125
|
:id => "1bb0fed1c2df4b5faa19e7700c049e35"
|
126
126
|
}
|
127
127
|
Model.new tenant
|
@@ -133,13 +133,14 @@ module Ocp::Registry
|
|
133
133
|
:enabled => true,
|
134
134
|
:name => name,
|
135
135
|
:tenant_id => tenant_id,
|
136
|
-
:password => password
|
136
|
+
:password => password,
|
137
|
+
:id => "2df4b5faa19c049e351bb0fed1caa19e7700"
|
137
138
|
}
|
138
139
|
Model.new user
|
139
140
|
end
|
140
141
|
|
141
142
|
def get_tenant_by_name(name)
|
142
|
-
|
143
|
+
nil
|
143
144
|
end
|
144
145
|
|
145
146
|
def tenant_add_user_with_role(tenant, user_id, role_id)
|
@@ -147,14 +148,7 @@ module Ocp::Registry
|
|
147
148
|
end
|
148
149
|
|
149
150
|
def find_user_by_name(name)
|
150
|
-
|
151
|
-
:email => "#{name}@email.com",
|
152
|
-
:enabled => true,
|
153
|
-
:name => name,
|
154
|
-
:tenant_id => "1bb0fed1c2df4b5faa19e7700c049e35",
|
155
|
-
:password => "passwordxxxxx"
|
156
|
-
}
|
157
|
-
Model.new user
|
151
|
+
nil
|
158
152
|
end
|
159
153
|
|
160
154
|
NOVA_QUOTA_FIELDS = ["metadata_items",
|
data/lib/ocp_registry/common.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Ocp::Registry::Common
|
2
2
|
|
3
|
+
EMAIL_REGEX = /[a-z0-9_.-]+@[a-z0-9-]+\.[a-z.]+/
|
4
|
+
|
3
5
|
class << self
|
4
6
|
|
5
7
|
def uuid
|
@@ -11,7 +13,7 @@ module Ocp::Registry::Common
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def parse_email(email)
|
14
|
-
return unless email =~
|
16
|
+
return unless email =~ EMAIL_REGEX
|
15
17
|
email =~ /([a-z0-9_.-]+)@([a-z0-9-]+\.[a-z.]+)/
|
16
18
|
{
|
17
19
|
:name => $1 ,
|
data/lib/ocp_registry/config.rb
CHANGED
@@ -51,7 +51,7 @@ module Ocp::Registry
|
|
51
51
|
|
52
52
|
def migrate_db
|
53
53
|
Sequel.extension :migration
|
54
|
-
Sequel::Migrator.apply(@db,File.expand_path('
|
54
|
+
Sequel::Migrator.apply(@db,File.expand_path(File.join(File.dirname(__FILE__), 'db')))
|
55
55
|
end
|
56
56
|
|
57
57
|
def connect_db(db_config)
|
@@ -86,6 +86,10 @@ module Ocp::Registry
|
|
86
86
|
raise ConfigError, "Cloud configuration is missing from config file"
|
87
87
|
end
|
88
88
|
|
89
|
+
if config["cloud"]["login_url"].nil?
|
90
|
+
raise ConfigError, "Cloud Login URL is missing from config file"
|
91
|
+
end
|
92
|
+
|
89
93
|
if config["cloud"]["plugin"].nil?
|
90
94
|
raise ConfigError, "Cloud plugin is missing from config file"
|
91
95
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
Sequel.migration do
|
3
|
+
change do
|
4
|
+
create_table(:registry_settings) do
|
5
|
+
primary_key :id
|
6
|
+
foreign_key :registry_application_id , :registry_applications
|
7
|
+
String :updated_at
|
8
|
+
Integer :version, :default => 0
|
9
|
+
String :comments , :text => true
|
10
|
+
String :settings , :null => false , :text => true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
#migration data
|
4
|
+
self[:registry_settings].insert([:registry_application_id, :settings, :comments, :updated_at],
|
5
|
+
self[:registry_applications].select(:id, :settings, :comments, :updated_at))
|
6
|
+
#drop column
|
7
|
+
alter_table(:registry_applications) do
|
8
|
+
drop_column :comments
|
9
|
+
drop_column :settings
|
10
|
+
rename_column :updated_at, :end_at
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
alter_table(:registry_settings) do
|
4
|
+
add_column :from , String, :null => false, :default => 'USER'
|
5
|
+
end
|
6
|
+
settings = self[:registry_settings].select(:id,:version)
|
7
|
+
admins = []
|
8
|
+
settings.each do |set|
|
9
|
+
admins << set[:id] if (set[:version] & 1) == 1
|
10
|
+
end
|
11
|
+
self[:registry_settings].where(:id => admins).update(:from => 'ADMIN')
|
12
|
+
end
|
13
|
+
end
|
@@ -7,7 +7,7 @@ module Ocp::Registry
|
|
7
7
|
DEFAULT_WORKER = 1
|
8
8
|
DEFAULT_PORT = '25'
|
9
9
|
DEFAULT_HELO = 'ocp.com'
|
10
|
-
TEMPLATES_PATH = 'mail_template'
|
10
|
+
TEMPLATES_PATH = File.join(File.dirname(__FILE__),'../../mail_template')
|
11
11
|
DEFAULT_FROM = 'registry@ocp.com'
|
12
12
|
DEFAULT_TLS = false
|
13
13
|
DEFAULT_ADMIN_EMAIL = 'admin@ocp.com'
|
@@ -54,7 +54,7 @@ module Ocp::Registry
|
|
54
54
|
|
55
55
|
def mail_validated?(mail_info)
|
56
56
|
unless mail_info[:from] && mail_info[:to] && mail_info[:template] && has_template?(mail_info[:template])
|
57
|
-
@logger.
|
57
|
+
@logger.warning "Mail is ignored because less of necessary fields "
|
58
58
|
return false
|
59
59
|
end
|
60
60
|
true
|
data/lib/ocp_registry/models.rb
CHANGED
@@ -6,5 +6,24 @@ module Ocp::Registry::Models
|
|
6
6
|
values[:created_at] = Time.now.utc.to_s
|
7
7
|
values[:state] = 'PENDING'
|
8
8
|
end
|
9
|
+
|
10
|
+
one_to_many :registry_settings, :select => [:id ,:comments, :settings, :updated_at, :from], :order => :version
|
11
|
+
|
12
|
+
def to_hash(opts = {})
|
13
|
+
hash = self.values
|
14
|
+
if false == opts[:lazy_load]
|
15
|
+
settings = []
|
16
|
+
self.registry_settings do |data|
|
17
|
+
limit = opts[:limit]
|
18
|
+
data = data.limit(limit) if limit
|
19
|
+
data.reverse(:version).each do |set|
|
20
|
+
settings << set.to_hash
|
21
|
+
end
|
22
|
+
end
|
23
|
+
hash[:registry_settings] = settings
|
24
|
+
end
|
25
|
+
Ocp::Registry::Common.deep_copy(hash)
|
26
|
+
end
|
27
|
+
|
9
28
|
end
|
10
29
|
end
|
data/lib/ocp_registry/version.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
From: <%= mail[:from]%>
|
2
2
|
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
-
Subject:
|
3
|
+
Subject: APPROVED resource request for project <%= info[:app_info].project %>
|
4
4
|
|
5
5
|
Dear Administrator :
|
6
|
-
|
6
|
+
|
7
|
+
The resource request for project [<%= info[:app_info].project %>] has been [APPROVED] at [<%= info[:app_info].end_at %>].
|
7
8
|
The application id is [<%= info[:app_info].id%>].
|
8
9
|
|
9
10
|
You can review all received applications from <%= info[:applications_link]%>
|
@@ -1,9 +1,10 @@
|
|
1
1
|
From: <%= mail[:from]%>
|
2
2
|
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
-
Subject:
|
3
|
+
Subject: APPROVED resource request for project <%= info[:app_info].project %>
|
4
4
|
|
5
5
|
Dear User from <%= info[:app_info].email %> :
|
6
|
-
|
6
|
+
|
7
|
+
Your resource request for project [<%= info[:app_info].project %>] has been [APPROVED] at [<%= info[:app_info].end_at %>].
|
7
8
|
Your application id is [<%= info[:app_info].id%>].
|
8
9
|
|
9
10
|
Your login info is as below:
|
@@ -14,8 +15,6 @@ Dear User from <%= info[:app_info].email %> :
|
|
14
15
|
|
15
16
|
Please reset your password once your login into system.
|
16
17
|
|
17
|
-
You can browse all your applications from <%= info[:applications_link]%>
|
18
|
-
|
19
18
|
Thanks!
|
20
19
|
OCP registry
|
21
20
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
From: <%= mail[:from]%>
|
2
|
+
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
+
Subject: CANCELED resource request for project <%= info[:app_info].project %>
|
4
|
+
|
5
|
+
Dear Administrator :
|
6
|
+
|
7
|
+
The resource request for project [<%= info[:app_info].project %>] has been [CANCELED] at [<%= info[:app_info].end_at %>].
|
8
|
+
The application id is [<%= info[:app_info].id%>].
|
9
|
+
|
10
|
+
Thanks!
|
11
|
+
OCP registry
|
12
|
+
|
13
|
+
(This email is auto-sent by system, please don't reply this mail)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
From: <%= mail[:from]%>
|
2
|
+
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
+
Subject: CANCELED resource request for project <%= info[:app_info].project %>
|
4
|
+
|
5
|
+
Dear User from <%= info[:app_info].email %> :
|
6
|
+
|
7
|
+
Your resource request for project [<%= info[:app_info].project %>] has been [CANCELED] at [<%= info[:app_info].end_at %>].
|
8
|
+
Your application id is [<%= info[:app_info].id%>].
|
9
|
+
|
10
|
+
Thanks!
|
11
|
+
OCP registry
|
12
|
+
|
13
|
+
(This email is auto-sent by system, please don't reply this mail)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
From: <%= mail[:from]%>
|
2
|
+
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
+
Subject: UPDATED resource request for project <%= info[:app_info].project %> from <%= info[:from] %>
|
4
|
+
|
5
|
+
Dear <%= info[:name] %> :
|
6
|
+
|
7
|
+
The resource request for project [<%= info[:app_info].project %>] has been [UPDATED] by [<%= info[:from]%>] at [<%= info[:time]%>].
|
8
|
+
The application id is [<%= info[:app_info].id%>].
|
9
|
+
|
10
|
+
<% unless info[:change_set].empty?%>
|
11
|
+
The change set is as below :
|
12
|
+
<% info[:change_set].each do |change|%>
|
13
|
+
<%= change[:key]%> : <%= change[:from]%> ==> <%= change[:to]%>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
The comment is :
|
18
|
+
<%= info[:comments] %>
|
19
|
+
|
20
|
+
You can review or apply the settings from <%= info[:application_link]%>
|
21
|
+
|
22
|
+
Thanks!
|
23
|
+
OCP registry
|
24
|
+
|
25
|
+
(This email is auto-sent by system, please don't reply this mail)
|
@@ -1,12 +1,13 @@
|
|
1
1
|
From: <%= mail[:from]%>
|
2
2
|
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
-
Subject:
|
3
|
+
Subject: REFUSED resource request for project <%= info[:app_info].project %>
|
4
4
|
|
5
5
|
Dear Administrator :
|
6
|
-
|
6
|
+
|
7
|
+
The resource request for project [<%= info[:app_info].project %>] has been [REFUSED] at [<%= info[:app_info].end_at %>]].
|
7
8
|
The application id is [<%= info[:app_info].id%>].
|
8
9
|
The comment is :
|
9
|
-
<%= info[:
|
10
|
+
<%= info[:comments] %>
|
10
11
|
|
11
12
|
You can review all received applications from <%= info[:applications_link]%>
|
12
13
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
From: <%= mail[:from]%>
|
2
2
|
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
-
Subject:
|
3
|
+
Subject: REFUSED resource request for project <%= info[:app_info].project %>
|
4
4
|
|
5
5
|
Dear User from <%= info[:app_info].email %> :
|
6
|
-
|
6
|
+
|
7
|
+
Your resource request for project [<%= info[:app_info].project %>] has been [REFUSED] at [<%= info[:app_info].end_at %>]].
|
7
8
|
Your application id is [<%= info[:app_info].id%>].
|
8
9
|
The comment is :
|
9
|
-
<%= info[:
|
10
|
+
<%= info[:comments] %>
|
10
11
|
|
11
12
|
You can browse your application from <%= info[:application_link]%>.
|
12
|
-
You can browse all your applications from <%= info[:applications_link]%>
|
13
13
|
|
14
14
|
Thanks!
|
15
15
|
OCP registry
|
@@ -1,9 +1,10 @@
|
|
1
1
|
From: <%= mail[:from]%>
|
2
2
|
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
-
Subject:
|
3
|
+
Subject: RECEIVED resource request for project <%= info[:app_info].project %>
|
4
4
|
|
5
5
|
Dear Administrator :
|
6
|
-
|
6
|
+
|
7
|
+
A new resource request for project [<%= info[:app_info].project %>] has been [RECEIVED] at [<%= info[:app_info].created_at %>].
|
7
8
|
The application id is [<%= info[:app_info].id%>].
|
8
9
|
You can review the application from <%= info[:application_link]%>.
|
9
10
|
You can also have a quick browse all received applications from <%= info[:applications_link]%>.
|
@@ -1,12 +1,12 @@
|
|
1
1
|
From: <%= mail[:from]%>
|
2
2
|
To: <%= mail[:to].kind_of?(Array)? mail[:to].join(";") : mail[:to]%>
|
3
|
-
Subject:
|
3
|
+
Subject: RECEIVED resource request for project <%= info[:app_info].project %>
|
4
4
|
|
5
5
|
Dear User from <%= info[:app_info].email %> :
|
6
|
-
|
6
|
+
|
7
|
+
Your resource request for project [<%= info[:app_info].project %>] has been [RECEIVED] at [<%= info[:app_info].created_at %>].
|
7
8
|
Your application id is [<%= info[:app_info].id%>].
|
8
9
|
You can browse your application from <%= info[:application_link]%>.
|
9
|
-
You can also have a quick browse all your applications from <%= info[:applications_link]%>.
|
10
10
|
We will process your application as soon as possible.
|
11
11
|
We will send you another email once we completed process your request.
|
12
12
|
|
data/public/common.css
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
.
|
2
|
-
|
3
|
-
-webkit-border-radius: 4px;
|
4
|
-
-moz-border-radius: 4px;
|
5
|
-
border-radius: 4px;
|
6
|
-
|
7
|
-
padding: 10px 10px 10px 10px;
|
1
|
+
.clear-float {
|
2
|
+
clear: both;
|
8
3
|
}
|
9
4
|
|
10
|
-
.
|
11
|
-
|
5
|
+
.hidden {
|
6
|
+
display: none;
|
7
|
+
}
|
8
|
+
|
9
|
+
.to-right {
|
10
|
+
float: right;
|
11
|
+
}
|
12
|
+
|
13
|
+
.to-left {
|
14
|
+
float: left;
|
12
15
|
}
|
13
16
|
|
14
17
|
select, textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
|
@@ -20,85 +23,45 @@ input, textarea, .uneditable-input {
|
|
20
23
|
width: 260px;
|
21
24
|
}
|
22
25
|
|
23
|
-
.
|
24
|
-
|
25
|
-
|
26
|
+
.box {
|
27
|
+
border: 1px solid #ddd;
|
28
|
+
-webkit-border-radius: 4px;
|
29
|
+
-moz-border-radius: 4px;
|
30
|
+
border-radius: 4px;
|
26
31
|
|
27
|
-
|
28
|
-
margin-bottom: 80px;
|
29
|
-
}
|
30
|
-
|
31
|
-
.optDialog .tab-content{
|
32
|
-
margin-left: 5px;
|
33
|
-
margin-right: 5px;
|
34
|
-
}
|
35
|
-
|
36
|
-
.optDialog label {
|
37
|
-
font-weight: bold;
|
32
|
+
padding: 10px 10px 10px 10px;
|
38
33
|
}
|
39
34
|
|
40
|
-
.
|
41
|
-
|
42
|
-
|
43
|
-
float: left;
|
35
|
+
.dialog {
|
36
|
+
width: 600px;
|
37
|
+
margin: auto;
|
44
38
|
}
|
45
39
|
|
46
|
-
.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
40
|
+
.dialog {
|
41
|
+
border: 1px solid #ddd;
|
42
|
+
-webkit-border-radius: 4px;
|
43
|
+
-moz-border-radius: 4px;
|
44
|
+
border-radius: 4px;
|
45
|
+
|
46
|
+
padding: 10px 10px 10px 10px;
|
51
47
|
}
|
52
48
|
|
53
|
-
.
|
49
|
+
.dialog .action {
|
54
50
|
border-top: 1px solid #ddd;
|
55
|
-
padding:
|
51
|
+
padding: 10px 10px 0px 10px;
|
56
52
|
margin-top: 10px;
|
57
53
|
}
|
58
54
|
|
59
|
-
.
|
60
|
-
float: left;
|
61
|
-
}
|
62
|
-
|
63
|
-
.toRight{
|
64
|
-
float: right;
|
65
|
-
}
|
66
|
-
|
67
|
-
.optDialog button{
|
55
|
+
.dialog button {
|
68
56
|
width: 100px;
|
69
57
|
}
|
70
58
|
|
71
|
-
.
|
72
|
-
margin-
|
59
|
+
.dialog .action *.to-left {
|
60
|
+
margin-right: 10px;
|
73
61
|
}
|
74
62
|
|
75
|
-
.
|
63
|
+
.dialog .action *.to-right {
|
76
64
|
margin-left: 10px;
|
77
|
-
display: none;
|
78
|
-
}
|
79
|
-
|
80
|
-
.rejectCommentDialog {
|
81
|
-
width: 400px;
|
82
|
-
}
|
83
|
-
|
84
|
-
.rejectCommentDialog textarea {
|
85
|
-
width: 360px;
|
86
|
-
height: 200px;
|
87
|
-
resize: none;
|
88
|
-
margin-left: 12px;
|
89
|
-
}
|
90
|
-
|
91
|
-
.rejectCommentDialog .rejectCommentAction {
|
92
|
-
border-top: 1px solid #ddd;
|
93
|
-
padding: 15px 10px 5px 10px;
|
94
|
-
margin-top: 10px;
|
95
65
|
}
|
96
66
|
|
97
|
-
.rejectCommentDialog button{
|
98
|
-
width: 100px;
|
99
|
-
}
|
100
|
-
|
101
|
-
.rejectCommentDialog button.toRight {
|
102
|
-
margin-left: 10px;
|
103
|
-
}
|
104
67
|
|