/
20170727000001_setting_proxy.rb
113 lines (110 loc) · 2.65 KB
/
20170727000001_setting_proxy.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class SettingProxy < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
Setting.create_if_not_exists(
title: 'Proxy Settings',
name: 'proxy',
area: 'System::Network',
description: 'Address of the proxy server for http and https resources.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy',
tag: 'input',
placeholder: 'proxy.example.com:3128',
},
],
},
state: '',
preferences: {
online_service_disable: true,
controller: 'SettingsAreaProxy',
prio: 1,
permission: ['admin.system'],
},
frontend: false
)
Setting.create_if_not_exists(
title: 'Proxy User',
name: 'proxy_username',
area: 'System::Network',
description: 'Username for proxy connection.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy_username',
tag: 'input',
},
],
},
state: '',
preferences: {
disabled: true,
online_service_disable: true,
prio: 2,
permission: ['admin.system'],
},
frontend: false
)
# fix typo
setting = Setting.find_by(name: 'proxy_password')
if setting
setting.options[:form][0][:name] = 'proxy_password'
setting.save!
else
Setting.create_if_not_exists(
title: 'Proxy Password',
name: 'proxy_password',
area: 'System::Network',
description: 'Password for proxy connection.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy_password',
tag: 'input',
},
],
},
state: '',
preferences: {
disabled: true,
online_service_disable: true,
prio: 3,
permission: ['admin.system'],
},
frontend: false
)
end
Setting.create_if_not_exists(
title: 'No Proxy',
name: 'proxy_no',
area: 'System::Network',
description: 'No proxy for the following hosts.',
options: {
form: [
{
display: '',
null: false,
name: 'proxy_no',
tag: 'input',
},
],
},
state: 'localhost,127.0.0.0,::1',
preferences: {
disabled: true,
online_service_disable: true,
prio: 4,
permission: ['admin.system'],
},
frontend: false
)
end
end