hippo-fw 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +0 -3
- data/.nvmrc +1 -2
- data/.ruby-version +1 -1
- data/Rakefile +1 -1
- data/client/hippo/access/login-dialog.jsx +2 -0
- data/client/hippo/boot.jsx +12 -0
- data/client/hippo/components/asset.jsx +5 -1
- data/client/hippo/components/asset.scss +1 -0
- data/client/hippo/components/data-list.jsx +6 -4
- data/client/hippo/components/data-table.jsx +7 -6
- data/client/hippo/components/data-table/header-cell.jsx +2 -0
- data/client/hippo/components/date-time.jsx +12 -2
- data/client/hippo/components/form/api.js +12 -0
- data/client/hippo/components/form/fields.jsx +8 -1
- data/client/hippo/components/form/fields/checkbox-wrapper.jsx +2 -0
- data/client/hippo/components/form/fields/date-wrapper.jsx +2 -0
- data/client/hippo/components/form/fields/form-field.scss +2 -0
- data/client/hippo/components/form/fields/label.jsx +2 -0
- data/client/hippo/components/form/fields/react-tags.scss +170 -0
- data/client/hippo/components/form/fields/select-wrapper.jsx +2 -0
- data/client/hippo/components/form/fields/tags-wrapper.jsx +46 -0
- data/client/hippo/components/form/fields/text-wrapper.jsx +9 -1
- data/client/hippo/components/form/fields/textarea-wrapper.jsx +15 -0
- data/client/hippo/components/form/wrapper.jsx +21 -1
- data/client/hippo/components/help.jsx +21 -0
- data/client/hippo/components/master-detail.jsx +2 -0
- data/client/hippo/components/network-activity-overlay.jsx +3 -1
- data/client/hippo/components/popout-window.jsx +126 -0
- data/client/hippo/components/query-builder.jsx +9 -117
- data/client/hippo/components/query-builder/boolean-picker.jsx +28 -0
- data/client/hippo/components/query-builder/clause-filter.jsx +58 -0
- data/client/hippo/components/query-builder/clause.jsx +98 -0
- data/client/hippo/components/query-builder/date-picker.jsx +23 -0
- data/client/hippo/components/query-builder/query-builder.scss +7 -0
- data/client/hippo/components/record-finder.jsx +2 -0
- data/client/hippo/components/record-finder/query-layer.jsx +5 -1
- data/client/hippo/components/save-button.jsx +7 -1
- data/client/hippo/components/screen.jsx +2 -0
- data/client/hippo/components/text-editor.jsx +4 -5
- data/client/hippo/components/text-editor/display-modes/Button.jsx +5 -2
- data/client/hippo/components/text-editor/display-modes/ToggleEdit.jsx +2 -1
- data/client/hippo/components/text-editor/display-modes/ToggleInsert.jsx +2 -1
- data/client/hippo/components/text-editor/display-modes/ToggleLayout.jsx +2 -1
- data/client/hippo/components/text-editor/display-modes/TogglePreview.jsx +2 -1
- data/client/hippo/components/text-editor/display-modes/ToggleResize.jsx +2 -1
- data/client/hippo/components/text-editor/display-modes/index.js +7 -7
- data/client/hippo/components/text-editor/image-plugin/Component/Display/index.js +4 -2
- data/client/hippo/components/text-editor/image-plugin/Component/Form/index.js +2 -0
- data/client/hippo/components/text-editor/renderer.jsx +2 -0
- data/client/hippo/components/text-editor/text-editor.scss +13 -4
- data/client/hippo/components/time-zone-select.jsx +2 -0
- data/client/hippo/components/tool-tip.jsx +2 -0
- data/client/hippo/extensions/base.js +2 -0
- data/client/hippo/extensions/hippo.js +2 -0
- data/client/hippo/lib/__mocks__/request-assets.js +1 -2
- data/client/hippo/lib/bootstrap.js +2 -0
- data/client/hippo/lib/computed-properties.js +24 -0
- data/client/hippo/lib/date-range.js +13 -2
- data/client/hippo/lib/request-assets.js +3 -2
- data/client/hippo/lib/smooth-scroll.js +2 -0
- data/client/hippo/lib/util.js +1 -2
- data/client/hippo/models/asset.js +2 -0
- data/client/hippo/models/base.js +5 -2
- data/client/hippo/models/collection.js +2 -0
- data/client/hippo/models/config.js +3 -1
- data/client/hippo/models/pub_sub.js +2 -0
- data/client/hippo/models/pub_sub/channel.js +2 -0
- data/client/hippo/models/pub_sub/map.js +2 -0
- data/client/hippo/models/query.js +21 -12
- data/client/hippo/models/query/array-result.js +52 -16
- data/client/hippo/models/query/clause.js +11 -4
- data/client/hippo/models/query/field.js +2 -1
- data/client/hippo/models/query/info.js +7 -1
- data/client/hippo/models/query/operator.js +2 -0
- data/client/hippo/models/query/result.js +2 -0
- data/client/hippo/models/query/types.js +4 -0
- data/client/hippo/models/sync.js +2 -0
- data/client/hippo/models/system-setting.js +1 -15
- data/client/hippo/models/tenant.js +23 -7
- data/client/hippo/react/Root.jsx +2 -0
- data/client/hippo/react/component-not-found.jsx +2 -0
- data/client/hippo/screens/definition.js +2 -0
- data/client/hippo/screens/group.js +2 -0
- data/client/hippo/screens/instance.js +5 -1
- data/client/hippo/screens/system-settings.jsx +19 -5
- data/client/hippo/screens/system-settings/mailer-config.jsx +4 -2
- data/client/hippo/screens/system-settings/system-settings.scss +1 -1
- data/client/hippo/screens/system-settings/tenant.jsx +4 -2
- data/client/hippo/screens/user-management.jsx +2 -0
- data/client/hippo/screens/user-management/edit-form.jsx +2 -0
- data/client/hippo/testing/screens.js +10 -2
- data/client/hippo/user.js +4 -0
- data/client/hippo/workspace/index.jsx +3 -1
- data/client/hippo/workspace/menu-group.jsx +2 -0
- data/client/hippo/workspace/menu-option.jsx +2 -0
- data/client/hippo/workspace/menu.jsx +6 -3
- data/client/hippo/workspace/navbar.jsx +2 -0
- data/client/hippo/workspace/screen.jsx +2 -0
- data/client/hippo/workspace/styles.scss +5 -1
- data/command-reference-files/initial/.eslintrc.js +0 -3
- data/command-reference-files/initial/Gemfile +1 -1
- data/config/routes.rb +3 -1
- data/db/seed.rb +1 -1
- data/hippo-fw.gemspec +2 -2
- data/lib/hippo/api/controller_base.rb +2 -1
- data/lib/hippo/api/handlers/asset.rb +3 -2
- data/lib/hippo/api/handlers/tenant.rb +4 -6
- data/lib/hippo/api/helper_methods.rb +5 -7
- data/lib/hippo/api/route_set.rb +3 -2
- data/lib/hippo/asset.rb +4 -0
- data/lib/hippo/command/console.rb +1 -1
- data/lib/hippo/concerns/asset_uploader.rb +9 -4
- data/lib/hippo/concerns/queries.rb +3 -3
- data/lib/hippo/extension.rb +14 -4
- data/lib/hippo/extension/definition.rb +5 -1
- data/lib/hippo/logger.rb +26 -27
- data/lib/hippo/mailer.rb +19 -7
- data/lib/hippo/system_settings.rb +10 -4
- data/lib/hippo/templates/liquid.rb +1 -0
- data/lib/hippo/templates/liquid/pluralize.rb +16 -0
- data/lib/hippo/tenant.rb +17 -1
- data/lib/hippo/user.rb +10 -9
- data/lib/hippo/version.rb +1 -1
- data/lib/hippo/webpack.rb +22 -2
- data/package-lock.json +5462 -883
- data/package.json +9 -11
- data/spec/client/access/login-dialog.spec.jsx +2 -2
- data/spec/client/components/__snapshots__/query-builder.spec.jsx.snap +1 -1
- data/spec/client/components/__snapshots__/record-finder.spec.jsx.snap +1 -1
- data/spec/client/components/master-detail.spec.jsx +2 -1
- data/spec/client/components/query-builder.spec.jsx +3 -3
- data/spec/client/extension/base.spec.js +2 -0
- data/spec/client/models/base.spec.js +5 -3
- data/spec/client/models/query.spec.js +18 -6
- data/spec/client/models/sync.spec.js +2 -1
- data/spec/client/models/system-setting.spec.js +0 -12
- data/spec/client/screens/user-management.spec.jsx +1 -2
- data/spec/client/test-models.js +10 -0
- data/spec/server/api/tenant_change_spec.rb +1 -2
- data/spec/server/asset_spec.rb +2 -2
- data/templates/js/config-data.js +1 -1
- data/templates/spec/factories/model.rb +1 -1
- data/views/hippo_root_view.erb +1 -3
- metadata +17 -6
- data/client/hippo/components/text-editor/display-modes/SaveState.jsx +0 -17
@@ -45,7 +45,6 @@ module Hippo::API::Handlers
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.asset_getter
|
48
|
-
root = Hippo::Extensions.controlling.root_path.join('public', 'assets')
|
49
48
|
webpack = Hippo::API::Root.webpack
|
50
49
|
if Hippo.env.production?
|
51
50
|
lambda do
|
@@ -61,7 +60,9 @@ module Hippo::API::Handlers
|
|
61
60
|
webpack.wait_until_available
|
62
61
|
file = webpack.file(params['asset'].to_sym, raise_on_not_found: false)
|
63
62
|
if file
|
64
|
-
|
63
|
+
protocol = 'http'
|
64
|
+
protocol += 's' if Hippo::Webpack.using_ssl?
|
65
|
+
redirect "#{protocol}://#{env['SERVER_NAME']}:#{webpack.process.port}/assets/#{file}"
|
65
66
|
else
|
66
67
|
halt 404
|
67
68
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module Hippo::API::Handlers
|
2
2
|
|
3
3
|
class Tenant < Hippo::API::ControllerBase
|
4
|
-
PUBLIC_ATTRS = %w{slug name}
|
5
4
|
|
6
5
|
def show
|
7
|
-
std_api_reply(:retrieve, Hippo::Tenant.current,
|
6
|
+
std_api_reply(:retrieve, Hippo::Tenant.current.bootstrap_data, success: true)
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
|
-
def create
|
9
|
+
def update
|
12
10
|
tenant = Hippo::Tenant.current
|
13
|
-
tenant.assign_attributes(data.slice(*PUBLIC_ATTRS))
|
11
|
+
tenant.assign_attributes(data.slice(*Hippo::Tenant::PUBLIC_ATTRS))
|
14
12
|
success = tenant.save
|
15
13
|
if success && tenant.slug_previously_changed?
|
16
14
|
Hippo::Tenant.system.perform do
|
@@ -18,7 +16,7 @@ module Hippo::API::Handlers
|
|
18
16
|
end
|
19
17
|
end
|
20
18
|
std_api_reply(:update, tenant,
|
21
|
-
only: PUBLIC_ATTRS,
|
19
|
+
only: Hippo::Tenant::PUBLIC_ATTRS,
|
22
20
|
success: success)
|
23
21
|
end
|
24
22
|
end
|
@@ -12,10 +12,6 @@ module Hippo
|
|
12
12
|
}.join("\n")
|
13
13
|
end
|
14
14
|
|
15
|
-
def client_bootstrap_data(mergedWith: {})
|
16
|
-
API.to_json(Extensions.client_bootstrap_data.merge(mergedWith))
|
17
|
-
end
|
18
|
-
|
19
15
|
def csrf_token
|
20
16
|
Rack::Csrf.csrf_token(env)
|
21
17
|
end
|
@@ -25,11 +21,13 @@ module Hippo
|
|
25
21
|
end
|
26
22
|
|
27
23
|
def error_as_json
|
28
|
-
|
24
|
+
error = request.env['sinatra.error']
|
25
|
+
Hippo.logger.warn error.message
|
26
|
+
Hippo.logger.warn error.backtrace.join("\n ")
|
29
27
|
API.to_json(
|
30
28
|
success: false,
|
31
|
-
errors: { exception:
|
32
|
-
message:
|
29
|
+
errors: { exception: error.message },
|
30
|
+
message: error.message
|
33
31
|
)
|
34
32
|
end
|
35
33
|
|
data/lib/hippo/api/route_set.rb
CHANGED
@@ -63,8 +63,9 @@ module Hippo
|
|
63
63
|
|
64
64
|
if options[:cors] && valid_methods.any?
|
65
65
|
cors = options[:cors].is_a?(Hash) ? otions[:cors] : {origins: options[:cors]}
|
66
|
-
|
67
|
-
|
66
|
+
cors_path = "#{prefix}#{path}/?:id?#{format}"
|
67
|
+
Hippo.logger.debug("CORS: #{cors_path} #{valid_methods}")
|
68
|
+
enable_cors cors_path, cors.merge(methods: valid_methods)
|
68
69
|
end
|
69
70
|
|
70
71
|
end
|
data/lib/hippo/asset.rb
CHANGED
@@ -14,6 +14,10 @@ module Hippo
|
|
14
14
|
def path(size)
|
15
15
|
Hippo.config.api_path + Hippo.config.assets_path_prefix + '/' + file_data[size]['id']
|
16
16
|
end
|
17
|
+
|
18
|
+
def url(size = 'original')
|
19
|
+
"https://#{Hippo::Tenant.current.slug}.#{Hippo.config.website_domain}#{path(size)}"
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
end
|
@@ -23,7 +23,7 @@ module Hippo
|
|
23
23
|
FactoryGirl.find_definitions
|
24
24
|
Hippo::API::Cable.configure
|
25
25
|
MultiTenant.current_tenant = Hippo::Tenant.find_by_slug(
|
26
|
-
Hippo.env.development? ? '
|
26
|
+
Hippo.env.development? ? 'dev' : 'system'
|
27
27
|
)
|
28
28
|
ext.on_dev_console
|
29
29
|
Pry::Commands.block_command "tenant", "set current tenant to <slug>" do |slug|
|
@@ -26,11 +26,16 @@ module Hippo::Concerns
|
|
26
26
|
plugin :versions
|
27
27
|
plugin :location_hash
|
28
28
|
|
29
|
+
|
29
30
|
process(:store) do |io, context|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
if io.metadata['mime_type'] && io.metadata['mime_type'].starts_with?('image')
|
32
|
+
size_1000 = resize_to_limit(io.download, 1000, 1000)
|
33
|
+
size_600 = resize_to_limit(size_1000, 600, 600)
|
34
|
+
size_300 = resize_to_limit(size_600, 300, 300)
|
35
|
+
{original: io, large: size_1000, medium: size_600, thumbnail: size_300}
|
36
|
+
else
|
37
|
+
{original: io}
|
38
|
+
end
|
34
39
|
end
|
35
40
|
|
36
41
|
end
|
@@ -8,10 +8,10 @@ module Hippo
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
|
11
|
-
def compose_query_using_detail_view( view: nil, join_to: nil )
|
11
|
+
def compose_query_using_detail_view( view: nil, join_to: nil, join_name: 'details' )
|
12
12
|
join_to ||= self.name.demodulize.tableize.singularize + '_' + primary_key
|
13
|
-
q = joins("join #{view} as
|
14
|
-
.select("
|
13
|
+
q = joins("join #{view} as #{join_name} on #{join_name}.#{join_to} = #{table_name}.#{primary_key}")
|
14
|
+
.select("#{join_name}.*")
|
15
15
|
if current_scope.nil? || current_scope.select_values.exclude?("#{table_name}.*")
|
16
16
|
q = q.select("#{table_name}.*")
|
17
17
|
end
|
data/lib/hippo/extension.rb
CHANGED
@@ -94,8 +94,9 @@ module Hippo
|
|
94
94
|
return nil
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
97
|
+
## Data returned will be included in the JS build;
|
98
|
+
## it should not be Tenant specific
|
99
|
+
def static_bootstrap_data
|
99
100
|
data = {}
|
100
101
|
%w{
|
101
102
|
api_path environment website_domain product_name assets_path_prefix
|
@@ -106,12 +107,22 @@ module Hippo
|
|
106
107
|
controlling_extension: controlling.identifier,
|
107
108
|
)
|
108
109
|
each do | ext |
|
109
|
-
ext_data = ext.
|
110
|
+
ext_data = ext.static_bootstrap_data
|
110
111
|
data[ext.identifier] = ext_data unless ext_data.nil?
|
111
112
|
end
|
113
|
+
data[:screen_ids] = Hippo::Screen.active_ids
|
112
114
|
return data
|
113
115
|
end
|
114
116
|
|
117
|
+
def tenant_bootstrap_data(tenant)
|
118
|
+
data = {}
|
119
|
+
each do | ext |
|
120
|
+
tenant_data = ext.tenant_bootstrap_data(tenant)
|
121
|
+
data[ext.identifier] = tenant_data unless tenant_data.nil?
|
122
|
+
end
|
123
|
+
data
|
124
|
+
end
|
125
|
+
|
115
126
|
def load_controlling_config
|
116
127
|
config_file = self.controlling.root_path.join('config','initialize.rb')
|
117
128
|
if config_file.exist?
|
@@ -129,7 +140,6 @@ module Hippo
|
|
129
140
|
|
130
141
|
end
|
131
142
|
|
132
|
-
|
133
143
|
end
|
134
144
|
|
135
145
|
require_relative 'extension/definition'
|
data/lib/hippo/logger.rb
CHANGED
@@ -3,27 +3,40 @@ require 'logger'
|
|
3
3
|
|
4
4
|
module Hippo
|
5
5
|
|
6
|
-
class MultiDestinationLogger
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
class MultiDestinationLogger < ::Logger
|
7
|
+
class Output
|
8
|
+
def initialize
|
9
|
+
@targets = [STDOUT]
|
10
|
+
@targets.push(
|
11
|
+
File.open("log/#{Hippo.config.environment}.log", "a")
|
12
|
+
) if File.writable?("log")
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def write(*args)
|
16
|
+
@targets.each {|t| t.write(*args)}
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def close
|
20
|
+
@targets.each(&:close)
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
24
|
+
def initialize
|
25
|
+
super Output.new
|
26
|
+
self.formatter = proc do |severity, datetime, progname, msg|
|
27
|
+
sprintf "%5.5s %s\n", severity, msg
|
28
|
+
end
|
29
|
+
if ENV['LOG']
|
30
|
+
self.level = ::Logger.const_get(ENV['LOG'].upcase)
|
31
|
+
else
|
32
|
+
self.level = ::Logger::INFO
|
33
|
+
end
|
34
|
+
end
|
22
35
|
end
|
23
36
|
|
24
37
|
class << self
|
25
38
|
def logger
|
26
|
-
@logger ||=
|
39
|
+
@logger ||= MultiDestinationLogger.new
|
27
40
|
end
|
28
41
|
|
29
42
|
def logger=( logger )
|
@@ -46,19 +59,5 @@ module Hippo
|
|
46
59
|
logger.debug '⚡ '*40
|
47
60
|
end
|
48
61
|
|
49
|
-
private
|
50
|
-
|
51
|
-
def _create_logger
|
52
|
-
logger = ::Logger.new MultiDestinationLogger.new
|
53
|
-
logger.formatter = proc do |severity, datetime, progname, msg|
|
54
|
-
sprintf "%5.5s %s\n", severity, msg
|
55
|
-
end
|
56
|
-
if ENV['LOG']
|
57
|
-
logger.level = ::Logger.const_get(ENV['LOG'].upcase)
|
58
|
-
else
|
59
|
-
logger.level = ::Logger::INFO
|
60
|
-
end
|
61
|
-
logger
|
62
|
-
end
|
63
62
|
end
|
64
63
|
end
|
data/lib/hippo/mailer.rb
CHANGED
@@ -3,29 +3,41 @@ require 'mail'
|
|
3
3
|
module Hippo
|
4
4
|
|
5
5
|
module Mailer
|
6
|
+
|
7
|
+
class TestMailer < Mail::TestMailer
|
8
|
+
def deliver!(mail)
|
9
|
+
retval = super
|
10
|
+
Hippo.logger.info { mail.encoded }
|
11
|
+
retval
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
6
15
|
class << self
|
7
16
|
|
8
17
|
def create
|
9
18
|
config = SystemSettings.for_ext(:smtp)
|
10
|
-
|
19
|
+
delivery_config = delivery_method_config(config)
|
11
20
|
Mail::Message.new do
|
12
21
|
from "\"#{config['from_name']}\" <#{config['from_email']}>"
|
13
|
-
|
22
|
+
if Hippo.env.production?
|
23
|
+
delivery_method :smtp, delivery_config
|
24
|
+
else
|
25
|
+
delivery_method TestMailer, delivery_config
|
26
|
+
end
|
14
27
|
end
|
15
28
|
end
|
16
29
|
|
17
30
|
def delivery_method_config(config)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
config: {
|
31
|
+
Hippo::Tenant.system.perform do
|
32
|
+
config = Hippo.config.secrets.smtp || {}
|
33
|
+
{
|
22
34
|
address: config['address'],
|
23
35
|
user_name: config['user_name'],
|
24
36
|
password: config['password'],
|
25
37
|
enable_starttls_auto: true,
|
26
38
|
port: 587
|
27
39
|
}
|
28
|
-
|
40
|
+
end
|
29
41
|
end
|
30
42
|
|
31
43
|
def from_template(template)
|
@@ -30,15 +30,21 @@ module Hippo
|
|
30
30
|
ExtensionSettings.new(extension_id, settings[extension_id.to_s])
|
31
31
|
end
|
32
32
|
|
33
|
+
def public_json
|
34
|
+
{
|
35
|
+
'logo' => Hippo::SystemSettings.config
|
36
|
+
.as_json(include: ['logo'])
|
37
|
+
.dig('logo', 'file_data')
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
33
41
|
class << self
|
34
42
|
def config
|
35
|
-
|
43
|
+
Tenant.current.system_settings || Tenant.current.create_system_settings
|
36
44
|
end
|
37
45
|
|
38
46
|
def public_json
|
39
|
-
|
40
|
-
'logo' => Hippo::SystemSettings.config.as_json(include: ['logo']).dig('logo', 'file_data')
|
41
|
-
}
|
47
|
+
config.public_json
|
42
48
|
end
|
43
49
|
|
44
50
|
def for_ext(extension_id)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Pluralize
|
2
|
+
|
3
|
+
def pluralize(number, singular, plural = nil)
|
4
|
+
number = number.to_i
|
5
|
+
if number == 1
|
6
|
+
"#{number} #{singular}"
|
7
|
+
elsif plural.nil?
|
8
|
+
"#{number} #{singular}s"
|
9
|
+
else
|
10
|
+
"#{number} #{plural}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
Liquid::Template.register_filter(Pluralize)
|
data/lib/hippo/tenant.rb
CHANGED
@@ -3,6 +3,9 @@ require 'activerecord-multi-tenant'
|
|
3
3
|
module Hippo
|
4
4
|
# Tenant
|
5
5
|
class Tenant < Hippo::Model
|
6
|
+
|
7
|
+
PUBLIC_ATTRS = %w{slug name identifier}
|
8
|
+
|
6
9
|
validates :slug, uniqueness: true
|
7
10
|
validates :name, :presence => { message: 'for company' }
|
8
11
|
validates :email, :presence => true
|
@@ -10,6 +13,9 @@ module Hippo
|
|
10
13
|
has_random_identifier
|
11
14
|
has_many :users, class_name: 'Hippo::User', autosave: true
|
12
15
|
|
16
|
+
belongs_to :system_settings, class_name: 'Hippo::SystemSettings',
|
17
|
+
foreign_key: :id, primary_key: :tenant_id
|
18
|
+
|
13
19
|
before_validation :auto_assign_slug, on: :create
|
14
20
|
|
15
21
|
before_save :downcase_slug
|
@@ -24,8 +30,18 @@ module Hippo
|
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
33
|
+
def bootstrap_data
|
34
|
+
as_json(
|
35
|
+
only: PUBLIC_ATTRS,
|
36
|
+
).merge(
|
37
|
+
bootstrap: system_settings.public_json.merge(
|
38
|
+
Hippo::Extensions.tenant_bootstrap_data(self)
|
39
|
+
)
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
27
43
|
def self.current
|
28
|
-
MultiTenant.current_tenant
|
44
|
+
MultiTenant.current_tenant || system
|
29
45
|
end
|
30
46
|
|
31
47
|
def self.system
|
data/lib/hippo/user.rb
CHANGED
@@ -23,15 +23,16 @@ module Hippo
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def workspace_data
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
user_data = attributes.slice(
|
27
|
+
'id','login','name','email', 'role_names', 'options',
|
28
|
+
'created_at','created_by','updated_at', 'updated_by'
|
29
|
+
)
|
30
|
+
{
|
31
|
+
user: user_data,
|
32
|
+
access: Access.for_user(self),
|
33
|
+
access_token: jwt_token,
|
34
|
+
screen_ids: Hippo::Screen.active_ids,
|
35
|
+
}
|
35
36
|
end
|
36
37
|
|
37
38
|
# @param model [Hippo::Model]
|
data/lib/hippo/version.rb
CHANGED