kaui 2.0.4 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +8 -23
- data/Rakefile +4 -2
- data/app/assets/config/kaui_manifest.js +45 -0
- data/app/assets/javascripts/jquery.spin.js +76 -0
- data/app/assets/javascripts/kaui/kaui.js +76 -0
- data/app/assets/javascripts/kaui_application.js +25 -0
- data/app/assets/javascripts/spin.js +76 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.scss +240 -0
- data/app/assets/stylesheets/kaui/{account.less → account.scss} +13 -1
- data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
- data/app/assets/stylesheets/kaui/{common.less → common.scss} +19 -17
- data/app/assets/stylesheets/kaui/{datatable.less → datatable.scss} +6 -3
- data/app/assets/stylesheets/kaui/{header.less → header.scss} +16 -12
- data/app/assets/stylesheets/kaui/{home.less → home.scss} +7 -4
- data/app/assets/stylesheets/kaui/{invoice.less → invoice.scss} +7 -3
- data/app/assets/stylesheets/kaui/kaui.scss +265 -0
- data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +3 -0
- data/app/assets/stylesheets/kaui/{overdue.less → overdue.scss} +3 -1
- data/app/assets/stylesheets/kaui/{payment.less → payment.scss} +3 -0
- data/app/assets/stylesheets/kaui/{subscription.less → subscription.scss} +4 -1
- data/app/assets/stylesheets/kaui/{tags.less → tags.scss} +9 -5
- data/app/assets/stylesheets/kaui/timeline.scss +7 -0
- data/app/assets/stylesheets/kaui/tooltip.scss +15 -0
- data/app/controllers/kaui/account_children_controller.rb +25 -28
- data/app/controllers/kaui/account_custom_fields_controller.rb +16 -15
- data/app/controllers/kaui/account_emails_controller.rb +28 -25
- data/app/controllers/kaui/account_tags_controller.rb +37 -34
- data/app/controllers/kaui/account_timelines_controller.rb +38 -33
- data/app/controllers/kaui/accounts_controller.rb +269 -255
- data/app/controllers/kaui/admin_allowed_users_controller.rb +105 -99
- data/app/controllers/kaui/admin_controller.rb +32 -31
- data/app/controllers/kaui/admin_tenants_controller.rb +434 -388
- data/app/controllers/kaui/audit_logs_controller.rb +87 -84
- data/app/controllers/kaui/bundle_tags_controller.rb +24 -20
- data/app/controllers/kaui/bundles_controller.rb +96 -82
- data/app/controllers/kaui/chargebacks_controller.rb +36 -33
- data/app/controllers/kaui/charges_controller.rb +23 -20
- data/app/controllers/kaui/credits_controller.rb +28 -25
- data/app/controllers/kaui/custom_fields_controller.rb +172 -38
- data/app/controllers/kaui/engine_controller.rb +2 -1
- data/app/controllers/kaui/engine_controller_util.rb +134 -114
- data/app/controllers/kaui/home_controller.rb +230 -217
- data/app/controllers/kaui/invoice_items_controller.rb +43 -39
- data/app/controllers/kaui/invoice_tags_controller.rb +32 -0
- data/app/controllers/kaui/invoices_controller.rb +134 -88
- data/app/controllers/kaui/login_proxy_controller.rb +2 -1
- data/app/controllers/kaui/payment_methods_controller.rb +103 -90
- data/app/controllers/kaui/payments_controller.rb +95 -92
- data/app/controllers/kaui/queues_controller.rb +47 -14
- data/app/controllers/kaui/refunds_controller.rb +36 -33
- data/app/controllers/kaui/registrations_controller.rb +7 -7
- data/app/controllers/kaui/role_definitions_controller.rb +17 -14
- data/app/controllers/kaui/sessions_controller.rb +7 -4
- data/app/controllers/kaui/subscriptions_controller.rb +197 -187
- data/app/controllers/kaui/tag_definitions_controller.rb +28 -27
- data/app/controllers/kaui/tags_controller.rb +25 -22
- data/app/controllers/kaui/tenants_controller.rb +30 -28
- data/app/controllers/kaui/transactions_controller.rb +43 -38
- data/app/helpers/kaui/account_helper.rb +22 -12
- data/app/helpers/kaui/application_helper.rb +8 -3
- data/app/helpers/kaui/date_helper.rb +3 -2
- data/app/helpers/kaui/home_helper.rb +2 -0
- data/app/helpers/kaui/locale_helper.rb +7 -6
- data/app/helpers/kaui/money_helper.rb +2 -1
- data/app/helpers/kaui/object_helper.rb +11 -10
- data/app/helpers/kaui/payment_helper.rb +7 -6
- data/app/helpers/kaui/payment_method_helper.rb +3 -2
- data/app/helpers/kaui/permissions_helper.rb +9 -9
- data/app/helpers/kaui/plugin_helper.rb +25 -23
- data/app/helpers/kaui/subscription_helper.rb +27 -29
- data/app/helpers/kaui/us_states_helper.rb +7 -6
- data/app/helpers/kaui/uuid_helper.rb +8 -5
- data/app/models/kaui/ability.rb +19 -12
- data/app/models/kaui/account.rb +45 -28
- data/app/models/kaui/account_email.rb +23 -20
- data/app/models/kaui/account_timeline.rb +5 -1
- data/app/models/kaui/admin.rb +65 -64
- data/app/models/kaui/admin_tenant.rb +81 -82
- data/app/models/kaui/allowed_user.rb +13 -9
- data/app/models/kaui/allowed_user_tenant.rb +4 -2
- data/app/models/kaui/application_record.rb +2 -0
- data/app/models/kaui/audit_log.rb +6 -3
- data/app/models/kaui/base.rb +13 -7
- data/app/models/kaui/bundle.rb +41 -24
- data/app/models/kaui/catalog.rb +118 -113
- data/app/models/kaui/chargeback.rb +5 -1
- data/app/models/kaui/credit.rb +4 -1
- data/app/models/kaui/custom_field.rb +9 -6
- data/app/models/kaui/invoice.rb +25 -22
- data/app/models/kaui/invoice_item.rb +9 -6
- data/app/models/kaui/invoice_payment.rb +49 -54
- data/app/models/kaui/killbill_authenticatable.rb +14 -8
- data/app/models/kaui/killbill_registerable.rb +7 -0
- data/app/models/kaui/overdue.rb +64 -65
- data/app/models/kaui/payment.rb +22 -19
- data/app/models/kaui/payment_method.rb +48 -39
- data/app/models/kaui/payment_state.rb +41 -38
- data/app/models/kaui/rails_methods.rb +9 -9
- data/app/models/kaui/refund.rb +7 -1
- data/app/models/kaui/role_definition.rb +5 -1
- data/app/models/kaui/simple_plan.rb +5 -3
- data/app/models/kaui/subscription.rb +10 -7
- data/app/models/kaui/tag.rb +25 -22
- data/app/models/kaui/tag_definition.rb +50 -45
- data/app/models/kaui/tenant.rb +6 -5
- data/app/models/kaui/transaction.rb +43 -31
- data/app/models/kaui/user.rb +10 -16
- data/app/models/kaui/user_role.rb +8 -5
- data/app/views/kaui/accounts/_billing_info.html.erb +5 -1
- data/app/views/kaui/accounts/_form.html.erb +2 -2
- data/app/views/kaui/accounts/_payment_methods.html.erb +3 -0
- data/app/views/kaui/accounts/index.html.erb +9 -4
- data/app/views/kaui/admin_allowed_users/_form.html.erb +3 -3
- data/app/views/kaui/admin_tenants/_form_catalog_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_template.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +13 -3
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -5
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_plan_currency.html.erb +1 -1
- data/app/views/kaui/bundles/_bundle_details.html.erb +12 -0
- data/app/views/kaui/bundles/index.html.erb +3 -14
- data/app/views/kaui/bundles/transfer.html.erb +13 -5
- data/app/views/kaui/invoice_tags/_form.html.erb +33 -0
- data/app/views/kaui/invoice_tags/_form_bar.html.erb +21 -0
- data/app/views/kaui/invoice_tags/edit.html.erb +10 -0
- data/app/views/kaui/invoices/_invoice_table.html.erb +29 -8
- data/app/views/kaui/invoices/index.html.erb +6 -4
- data/app/views/kaui/invoices/show.html.erb +10 -1
- data/app/views/kaui/layouts/kaui_flash.html.erb +32 -1
- data/app/views/kaui/layouts/kaui_header.html.erb +19 -2
- data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +13 -4
- data/app/views/kaui/payments/_payment_table.html.erb +21 -11
- data/app/views/kaui/payments/index.html.erb +12 -10
- data/app/views/kaui/queues/index.html.erb +1 -1
- data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -4
- data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
- data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
- data/app/views/kaui/tag_definitions/index.html.erb +2 -2
- data/app/views/kaui/tags/index.html.erb +1 -0
- data/config/initializers/bootstrap_datepicker_rails.rb +3 -0
- data/config/initializers/devise.rb +8 -6
- data/config/initializers/js_routes.rb +9 -0
- data/config/initializers/kilbill_client_init.rb +13 -0
- data/config/initializers/killbill_authenticatable.rb +71 -21
- data/config/initializers/killbill_registerable.rb +5 -3
- data/config/initializers/time_formats.rb +6 -4
- data/config/locales/en.yml +78 -1
- data/config/routes.rb +40 -32
- data/db/migrate/20130812155313_devise_create_kaui_users.rb +10 -8
- data/db/migrate/20150109214021_create_kaui_tenants.rb +10 -8
- data/db/migrate/20150112232813_create_kaui_allowed_users.rb +10 -8
- data/lib/generators/kaui/install/install_generator.rb +23 -20
- data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -1
- data/lib/kaui/engine.rb +17 -5
- data/lib/kaui/installer/installer.rb +27 -26
- data/lib/kaui/version.rb +3 -1
- data/lib/kaui.rb +74 -30
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +145 -440
- data/app/assets/javascripts/application.js +0 -17
- data/app/assets/javascripts/kaui/bootstrap-tweaks.js +0 -172
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -44
- data/app/assets/stylesheets/kaui/kaui.less +0 -21
- data/app/assets/stylesheets/kaui/timeline.less +0 -4
- data/config/initializers/asset.rb +0 -1
- data/config/initializers/kilbill-client-init.rb +0 -9
- data/db/schema.rb +0 -15
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -9
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -38
- data/test/dummy/bin/update +0 -29
- data/test/dummy/bin/yarn +0 -11
- data/test/dummy/config/application.rb +0 -18
- data/test/dummy/config/boot.rb +0 -3
- data/test/dummy/config/database.yml +0 -27
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -58
- data/test/dummy/config/environments/production.rb +0 -91
- data/test/dummy/config/environments/test.rb +0 -49
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
- data/test/dummy/config/initializers/assets.rb +0 -14
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/killbill_client.rb +0 -1
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -33
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/config/secrets.yml +0 -32
- data/test/dummy/config/symmetric-encryption.yml +0 -135
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/schema.rb +0 -52
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/fixtures/SpyCarAdvanced.xml +0 -824
- data/test/fixtures/catalog-v1.xml +0 -73
- data/test/fixtures/catalog_translation_fr-v1.properties +0 -1
- data/test/fixtures/invoice_template-v1.html +0 -100
- data/test/fixtures/invoice_translation_fr-v1.properties +0 -23
- data/test/fixtures/overdue-v1.xml +0 -49
- data/test/fixtures/stripe.yml +0 -2
- data/test/functional/kaui/account_children_controller_test.rb +0 -32
- data/test/functional/kaui/account_custom_fields_controller_test.rb +0 -29
- data/test/functional/kaui/account_emails_controller_test.rb +0 -55
- data/test/functional/kaui/account_tags_controller_test.rb +0 -48
- data/test/functional/kaui/account_timelines_controller_test.rb +0 -20
- data/test/functional/kaui/accounts_controller_test.rb +0 -297
- data/test/functional/kaui/admin_allowed_users_controller_test.rb +0 -234
- data/test/functional/kaui/admin_controller_test.rb +0 -45
- data/test/functional/kaui/admin_tenants_controller_test.rb +0 -352
- data/test/functional/kaui/audit_logs_controller_test.rb +0 -71
- data/test/functional/kaui/bundle_tags_controller_test.rb +0 -23
- data/test/functional/kaui/bundles_controller_test.rb +0 -130
- data/test/functional/kaui/chargebacks_controller_test.rb +0 -42
- data/test/functional/kaui/charges_controller_test.rb +0 -60
- data/test/functional/kaui/credits_controller_test.rb +0 -54
- data/test/functional/kaui/custom_fields_controller_test.rb +0 -52
- data/test/functional/kaui/functional_test_helper.rb +0 -13
- data/test/functional/kaui/functional_test_helper_nosetup.rb +0 -120
- data/test/functional/kaui/home_controller_test.rb +0 -407
- data/test/functional/kaui/invoice_items_controller_test.rb +0 -82
- data/test/functional/kaui/invoices_controller_test.rb +0 -88
- data/test/functional/kaui/login_proxy_controller_test.rb +0 -12
- data/test/functional/kaui/payment_methods_controller_test.rb +0 -52
- data/test/functional/kaui/payments_controller_test.rb +0 -59
- data/test/functional/kaui/queues_controller_test.rb +0 -17
- data/test/functional/kaui/refunds_controller_test.rb +0 -63
- data/test/functional/kaui/registrations_controller_test.rb +0 -49
- data/test/functional/kaui/role_definitions_controller_test.rb +0 -47
- data/test/functional/kaui/subscriptions_controller_test.rb +0 -194
- data/test/functional/kaui/tag_definitions_controller_test.rb +0 -29
- data/test/functional/kaui/tags_controller_test.rb +0 -21
- data/test/functional/kaui/tenants_controller_test.rb +0 -60
- data/test/functional/kaui/transactions_controller_test.rb +0 -90
- data/test/integration/kaui/date_helper_integration_test.rb +0 -16
- data/test/integration/kaui/integration_test_helper.rb +0 -32
- data/test/integration/kaui/navigation_test.rb +0 -43
- data/test/killbill_test_helper.rb +0 -217
- data/test/test_helper.rb +0 -22
- data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/payment_method_helper_test.rb +0 -17
- data/test/unit/helpers/kaui/tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/uuid_helper_test.rb +0 -16
- data/test/unit/kaui/account_email_test.rb +0 -19
- data/test/unit/kaui/account_test.rb +0 -14
- data/test/unit/kaui/admin_tenant_test.rb +0 -132
- data/test/unit/kaui/allowed_user_test.rb +0 -34
- data/test/unit/kaui/base_test.rb +0 -23
- data/test/unit/kaui/date_helper_test.rb +0 -26
- data/test/unit/kaui/invoice_item_test.rb +0 -11
- data/test/unit/kaui/invoice_payment_test.rb +0 -42
- data/test/unit/kaui/invoice_test.rb +0 -20
- data/test/unit/kaui/money_helper_test.rb +0 -16
- data/test/unit/kaui/payment_test.rb +0 -42
- data/test/unit/kaui/tag_definition_test.rb +0 -11
- data/test/unit/kaui/tenant_test.rb +0 -19
- /data/app/assets/stylesheets/{application.css → kaui_application.css} +0 -0
@@ -1,44 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'devise/strategies/authenticatable'
|
4
|
+
require 'jwt'
|
2
5
|
|
3
6
|
module Devise
|
4
7
|
module Strategies
|
8
|
+
module KillbillHelpers
|
9
|
+
def kb_authenticate!(kb_username, creds)
|
10
|
+
# Find the associated user object (see find_for_killbill_authentication in app/models/kaui/killbill_authenticatable.rb)
|
11
|
+
resource = mapping.to.find_for_killbill_authentication(kb_username)
|
12
|
+
|
13
|
+
# Validate the credentials (see valid_killbill_password? in app/models/kaui/killbill_authenticatable.rb)
|
14
|
+
return unless validate(resource) { resource.valid_killbill_password?(creds) }
|
15
|
+
|
16
|
+
# Create the user if needed
|
17
|
+
resource.after_killbill_authentication
|
18
|
+
# Tell warden to halt the strategy and set the user in the appropriate scope
|
19
|
+
success!(resource)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
5
23
|
class KillbillAuthenticatable < Authenticatable
|
6
|
-
|
24
|
+
include KillbillHelpers
|
25
|
+
|
26
|
+
# Invoked by Warden::Strategies::Base#_run! to execute the strategy
|
27
|
+
def authenticate!
|
28
|
+
return false unless valid_password?
|
29
|
+
|
30
|
+
user = params[:user] || {}
|
31
|
+
kb_authenticate!(user[:kb_username], { username: user[:kb_username], password: password })
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Warden strategy to authenticate an user through a JWT token in the `Authorization` request header
|
36
|
+
class KillbillJWTAuthenticatable < Authenticatable
|
37
|
+
# Must match the Kill Bill configuration (e.g. org.killbill.security.auth0.usernameClaim)
|
38
|
+
mattr_accessor :username_claim
|
39
|
+
self.username_claim = 'sub'
|
40
|
+
|
41
|
+
include KillbillHelpers
|
42
|
+
|
43
|
+
# Invoked by Warden::Strategies::Base#_run! to execute the strategy
|
7
44
|
def authenticate!
|
45
|
+
payload, = ::JWT.decode(token, nil, false)
|
46
|
+
kb_username = payload[username_claim].presence
|
47
|
+
return false unless kb_username
|
48
|
+
|
49
|
+
kb_authenticate!(kb_username, { bearer: token })
|
50
|
+
end
|
51
|
+
|
52
|
+
def valid?
|
53
|
+
!token.nil?
|
54
|
+
end
|
8
55
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# Tell warden to halt the strategy and set the user in the appropriate scope
|
21
|
-
success!(resource)
|
56
|
+
private
|
57
|
+
|
58
|
+
def token
|
59
|
+
@token ||= begin
|
60
|
+
auth = env['HTTP_AUTHORIZATION']
|
61
|
+
if auth
|
62
|
+
method, token = auth.split
|
63
|
+
method == 'Bearer' ? token : nil
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
22
67
|
end
|
23
|
-
rescue Errno::ECONNREFUSED => _
|
24
|
-
return fail(:killbill_not_available)
|
25
68
|
end
|
26
69
|
end
|
27
70
|
end
|
28
71
|
end
|
29
72
|
|
30
73
|
Warden::Strategies.add(:killbill_authenticatable, Devise::Strategies::KillbillAuthenticatable)
|
74
|
+
Warden::Strategies.add(:killbill_jwt, Devise::Strategies::KillbillJWTAuthenticatable)
|
31
75
|
|
32
76
|
Warden::Manager.after_set_user do |user, auth, opts|
|
33
77
|
unless user.authenticated_with_killbill?
|
34
78
|
scope = opts[:scope]
|
35
79
|
auth.logout(scope)
|
36
|
-
throw(:warden, :
|
80
|
+
throw(:warden, scope: scope, reason: 'Kill Bill session expired')
|
37
81
|
end
|
38
82
|
end
|
39
83
|
|
40
84
|
Devise.add_module(:killbill_authenticatable,
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
85
|
+
strategy: true,
|
86
|
+
route: :session,
|
87
|
+
controller: :sessions,
|
88
|
+
model: 'kaui/killbill_authenticatable')
|
89
|
+
|
90
|
+
Devise::Strategies::KillbillJWTAuthenticatable.username_claim = if defined?(JRUBY_VERSION)
|
91
|
+
java.lang.System.getProperty('kaui.jwt.username_claim', ENV['KAUI_USERNAME_CLAIM'] || 'sub')
|
92
|
+
else
|
93
|
+
ENV['KAUI_USERNAME_CLAIM'] || 'sub'
|
94
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Devise.add_module(:killbill_registerable,
|
2
|
-
:
|
3
|
-
:
|
4
|
-
:
|
4
|
+
route: :registration,
|
5
|
+
controller: :registrations,
|
6
|
+
model: 'kaui/killbill_registerable')
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Time::DATE_FORMATS[:
|
4
|
-
Date::DATE_FORMATS[:
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Time::DATE_FORMATS[:pretty] = '%b %d %Y at %H:%M'
|
4
|
+
Date::DATE_FORMATS[:pretty] = '%b %d %Y at %H:%M'
|
5
|
+
Time::DATE_FORMATS[:date_only] = '%Y-%m-%d'
|
6
|
+
Date::DATE_FORMATS[:date_only] = '%Y-%m-%d'
|
data/config/locales/en.yml
CHANGED
@@ -1,3 +1,80 @@
|
|
1
1
|
en:
|
2
2
|
account: "Account"
|
3
|
-
|
3
|
+
new_account: "New Account"
|
4
|
+
transfer: "Transfer"
|
5
|
+
comment: "Comment"
|
6
|
+
change: "Change"
|
7
|
+
unknown_bcd: "Unknown bill cycle day"
|
8
|
+
payment_method_id: "Payment Method ID:"
|
9
|
+
external_key_with_colon: "External Key:"
|
10
|
+
external_id_with_colon: "External ID:"
|
11
|
+
name_with_colon: "Name:"
|
12
|
+
custom_field_created_success: "Custom field was successfully created"
|
13
|
+
custom_field_uuid_exist_in_account_db: "UUID do exist in ACCOUNT object database."
|
14
|
+
custom_field_uuid_exist_in_bundle_db: "UUID do exist in BUNDLE object database."
|
15
|
+
custom_field_uuid_exist_in_subscription_db: "UUID do exist in SUBSCRIPTION object database."
|
16
|
+
custom_field_uuid_exist_in_invoice_db: "UUID do exist in INVOICE object database."
|
17
|
+
custom_field_uuid_exist_in_payment_db: "UUID do exist in PAYMENT object database."
|
18
|
+
custom_field_uuid_exist_in_invoice_payment_db: "UUID do exist in INVOICE PAYMENT object database."
|
19
|
+
custom_field_uuid_do_not_exist_in_db: "UUID do not exist in object database."
|
20
|
+
custom_field_uuid_exist_in_invoice_item_db: "UUID do exist in INVOICE ITEMS object database."
|
21
|
+
immediate: "Immediate"
|
22
|
+
start_of_term: "Start of term"
|
23
|
+
end_of_term: "End of term"
|
24
|
+
billing_policy: "Billing Policy"
|
25
|
+
new_account_id_or_external_key: "New account id or external key"
|
26
|
+
object_invalid_dont_exist: "Object type INVALID or object id do not exist."
|
27
|
+
date: "Date"
|
28
|
+
type: "Type"
|
29
|
+
amount: "Amount"
|
30
|
+
processed_amount: "Processed Amount"
|
31
|
+
transaction_external_key: "Transaction external key"
|
32
|
+
first_id: "First id"
|
33
|
+
second_id: "Second id"
|
34
|
+
gateway_code: "Gateway code"
|
35
|
+
gateway_message: "Gateway message"
|
36
|
+
status: "Status"
|
37
|
+
payments: "Payments"
|
38
|
+
number: "Number"
|
39
|
+
auth_amount: "Auth amount"
|
40
|
+
capture_amount: "Capture amount"
|
41
|
+
refund_amount: "Refund amount"
|
42
|
+
last_transaction_status: "Last transaction status"
|
43
|
+
external_key: "External key"
|
44
|
+
loading_data_from_server: "Loading data from server"
|
45
|
+
requested_amount_colon: "Requested amount: "
|
46
|
+
|
47
|
+
flashes:
|
48
|
+
notices:
|
49
|
+
clock_updated_successfully: "Clock was successfully updated to %{new_date}"
|
50
|
+
clock_reset_successfully: 'Clock was successfully reset'
|
51
|
+
overdue_uploaded_successfully: 'Overdue config was successfully uploaded'
|
52
|
+
overdue_added_successfully: 'Overdue config was successfully added'
|
53
|
+
invoice_template_uploaded_successfully: 'Invoice template was successfully uploaded'
|
54
|
+
invoice_translation_uploaded_successfully: 'Invoice translation was successfully uploaded'
|
55
|
+
catalog_translation_uploaded_successfully: 'Catalog translation was successfully uploaded'
|
56
|
+
catalog_uploaded_successfully: 'Catalog was successfully uploaded'
|
57
|
+
|
58
|
+
errors:
|
59
|
+
messages:
|
60
|
+
invalid_object_type: "Invalid Object Type: %{error}"
|
61
|
+
invalid_phone: "Invalid phone number!"
|
62
|
+
invalid_bill_cycle_day_local: "Incorrect day of the billing cycle. It should be in the range from 1 to 31."
|
63
|
+
invalid_xml: "Invalid XML: %{error}"
|
64
|
+
invalid_min_date: "Invalid min date format"
|
65
|
+
invalid_max_date: "Invalid max date format"
|
66
|
+
views:
|
67
|
+
subscriptions:
|
68
|
+
requested_date_for_billing_notice: <ul>
|
69
|
+
<li>When <span class="label label-default">Use requested date for billing?</span> is checked, then entitlement date and billing date are going to be equal to the requested date.</li>
|
70
|
+
<li>When <strong>not</strong> checked, then the entitlement date will be set with requested date, and billing date will be derived from the catalog policy.</li>
|
71
|
+
</ul>
|
72
|
+
catalogs:
|
73
|
+
show:
|
74
|
+
plan_table:
|
75
|
+
plan_id: "Plan Id"
|
76
|
+
product: "Product"
|
77
|
+
category: "Category"
|
78
|
+
billing_period: "Billing Period"
|
79
|
+
trial: "Trial"
|
80
|
+
final_phase_duration: "Final Phase Duration"
|
data/config/routes.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionDispatch
|
2
4
|
module Routing
|
3
5
|
class Mapper
|
@@ -14,13 +16,12 @@ module ActionDispatch
|
|
14
16
|
end
|
15
17
|
|
16
18
|
Kaui::Engine.routes.draw do
|
17
|
-
|
18
19
|
devise_for :users,
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
20
|
+
class_name: 'Kaui::User',
|
21
|
+
module: :devise,
|
22
|
+
controllers: { sessions: 'kaui/sessions', registrations: 'kaui/registrations' }
|
22
23
|
|
23
|
-
root :
|
24
|
+
root to: 'home#index', as: 'kaui'
|
24
25
|
|
25
26
|
scope '/accounts' do
|
26
27
|
match '/pagination' => 'accounts#pagination', :via => :get, :as => 'accounts_pagination'
|
@@ -46,6 +47,10 @@ Kaui::Engine.routes.draw do
|
|
46
47
|
match '/edit' => 'bundle_tags#edit', :via => :get, :as => 'edit_bundle_tags'
|
47
48
|
match '/edit' => 'bundle_tags#update', :via => :post, :as => 'update_bundle_tags'
|
48
49
|
end
|
50
|
+
scope '/invoice_tags' do
|
51
|
+
match '/edit' => 'invoice_tags#edit', :via => :get, :as => 'edit_invoice_tags'
|
52
|
+
match '/edit' => 'invoice_tags#update', :via => :post, :as => 'update_invoice_tags'
|
53
|
+
end
|
49
54
|
scope '/timeline' do
|
50
55
|
match '/' => 'account_timelines#show', :via => :get, :as => 'account_timeline'
|
51
56
|
end
|
@@ -61,7 +66,7 @@ Kaui::Engine.routes.draw do
|
|
61
66
|
end
|
62
67
|
end
|
63
68
|
end
|
64
|
-
resources :accounts, :
|
69
|
+
resources :accounts, only: %i[index new create edit update show destroy], param: :account_id do
|
65
70
|
member do
|
66
71
|
put :set_default_payment_method
|
67
72
|
delete :delete_payment_method
|
@@ -70,44 +75,46 @@ Kaui::Engine.routes.draw do
|
|
70
75
|
end
|
71
76
|
|
72
77
|
# The id is the email itself
|
73
|
-
resources :account_emails, :
|
74
|
-
resources :bundles, :
|
75
|
-
resources :charges, :
|
76
|
-
resources :chargebacks, :
|
77
|
-
resources :credits, :
|
78
|
-
resources :invoices, :
|
79
|
-
resources :invoice_items, :
|
80
|
-
resources :payments, :
|
81
|
-
resources :refunds, :
|
82
|
-
resources :transactions, :
|
83
|
-
resources :queues, :
|
84
|
-
resources :audit_logs, :
|
78
|
+
resources :account_emails, only: %i[new create destroy], constraints: { id: /[\w+\-;@.]+/ }, path: 'emails'
|
79
|
+
resources :bundles, only: [:index]
|
80
|
+
resources :charges, only: %i[new create]
|
81
|
+
resources :chargebacks, only: %i[new create]
|
82
|
+
resources :credits, only: %i[new create]
|
83
|
+
resources :invoices, only: %i[index show]
|
84
|
+
resources :invoice_items, only: [:edit]
|
85
|
+
resources :payments, only: %i[index show new create]
|
86
|
+
resources :refunds, only: %i[new create]
|
87
|
+
resources :transactions, only: %i[new create]
|
88
|
+
resources :queues, only: [:index]
|
89
|
+
resources :audit_logs, only: [:index]
|
85
90
|
end
|
86
91
|
|
87
92
|
scope '/payment_methods' do
|
88
93
|
match '/validate_external_key' => 'payment_methods#validate_external_key', :via => :get, :as => 'payment_methods_validate_external_key'
|
94
|
+
match '/refresh' => 'payment_methods#refresh', :via => :post, :as => 'refresh_payment_methods'
|
89
95
|
end
|
90
|
-
resources :payment_methods, :
|
96
|
+
resources :payment_methods, only: %i[new create show destroy]
|
91
97
|
|
92
98
|
scope '/invoices' do
|
93
99
|
match '/pagination' => 'invoices#pagination', :via => :get, :as => 'invoices_pagination'
|
94
100
|
match '/:id/show_html' => 'invoices#show_html', :via => :get, :as => 'show_html_invoice'
|
95
101
|
match '/:id' => 'invoices#restful_show', :via => :get, :as => 'invoice'
|
96
102
|
match '/commit' => 'invoices#commit_invoice', :via => :post, :as => 'commit_invoice'
|
103
|
+
match '/void' => 'invoices#void_invoice', :via => :delete, :as => 'void_invoice'
|
97
104
|
end
|
98
|
-
resources :invoices, :
|
105
|
+
resources :invoices, only: [:index]
|
99
106
|
|
100
107
|
scope '/invoice_items' do
|
101
108
|
match '/:id/tags' => 'invoice_items#update_tags', :via => :post, :as => 'update_invoice_items_tags'
|
102
109
|
end
|
103
|
-
resources :invoice_items, :
|
110
|
+
resources :invoice_items, only: %i[update destroy]
|
104
111
|
|
105
112
|
scope '/payments' do
|
106
113
|
match '/pagination' => 'payments#pagination', :via => :get, :as => 'payments_pagination'
|
107
114
|
match '/:id' => 'payments#restful_show', :via => :get, :as => 'payment'
|
108
115
|
match '/:id/cancel_scheduled_payment' => 'payments#cancel_scheduled_payment', :via => :delete, :as => 'payment_cancel_scheduled_payment'
|
109
116
|
end
|
110
|
-
resources :payments, :
|
117
|
+
resources :payments, only: [:index]
|
111
118
|
|
112
119
|
scope '/transactions' do
|
113
120
|
match '/:id' => 'transactions#restful_show', :via => :get, :as => 'transaction'
|
@@ -115,10 +122,10 @@ Kaui::Engine.routes.draw do
|
|
115
122
|
end
|
116
123
|
|
117
124
|
scope '/bundles' do
|
118
|
-
put '/:id/do_pause_resume', :
|
119
|
-
get '/:id/pause_resume', :
|
120
|
-
put '/:id/do_transfer', :
|
121
|
-
get '/:id/transfer', :
|
125
|
+
put '/:id/do_pause_resume', to: 'bundles#do_pause_resume', as: 'do_pause_resume_bundle'
|
126
|
+
get '/:id/pause_resume', to: 'bundles#pause_resume', as: 'pause_resume_bundle'
|
127
|
+
put '/:id/do_transfer', to: 'bundles#do_transfer', as: 'do_transfer_bundle'
|
128
|
+
get '/:id/transfer', to: 'bundles#transfer', as: 'transfer_bundle'
|
122
129
|
match '/:id' => 'bundles#restful_show', :via => :get, :as => 'bundle'
|
123
130
|
end
|
124
131
|
|
@@ -130,19 +137,20 @@ Kaui::Engine.routes.draw do
|
|
130
137
|
match '/validate_external_key' => 'subscriptions#validate_external_key', :via => :get, :as => 'subscriptions_validate_external_key'
|
131
138
|
match '/validate_bundle_external_key' => 'subscriptions#validate_bundle_external_key', :via => :get, :as => 'subscriptions_validate_bundle_external_key'
|
132
139
|
end
|
133
|
-
resources :subscriptions, :
|
140
|
+
resources :subscriptions, only: %i[new create show edit update destroy]
|
134
141
|
|
135
142
|
scope '/tags' do
|
136
143
|
match '/pagination' => 'tags#pagination', :via => :get, :as => 'tags_pagination'
|
137
144
|
end
|
138
|
-
resources :tags, :
|
145
|
+
resources :tags, only: [:index]
|
139
146
|
|
140
|
-
resources :tag_definitions, :
|
147
|
+
resources :tag_definitions, only: %i[index new create destroy]
|
141
148
|
|
142
149
|
scope '/custom_fields' do
|
143
150
|
match '/pagination' => 'custom_fields#pagination', :via => :get, :as => 'custom_fields_pagination'
|
151
|
+
match '/check_object_exist' => 'custom_fields#check_object_exist', :via => :get, :as => 'custom_fields_check_object_exist'
|
144
152
|
end
|
145
|
-
resources :custom_fields, :
|
153
|
+
resources :custom_fields, only: %i[index new create check_object_exist]
|
146
154
|
|
147
155
|
scope '/tenants' do
|
148
156
|
match '/' => 'tenants#index', :via => :get, :as => 'tenants'
|
@@ -189,12 +197,12 @@ Kaui::Engine.routes.draw do
|
|
189
197
|
match '/switch' => 'admin_tenants#switch_tenant', :via => :get, :as => 'switch_tenant'
|
190
198
|
match '/:id/download_catalog' => 'admin_tenants#download_catalog_xml', :via => :get, :as => 'download_catalog_xml'
|
191
199
|
end
|
192
|
-
resources :admin_tenants, :
|
200
|
+
resources :admin_tenants, only: %i[index new create show]
|
193
201
|
|
194
202
|
resources :admin_allowed_users
|
195
203
|
scope '/admin_allowed_users' do
|
196
204
|
match '/add_tenant' => 'admin_allowed_users#add_tenant', :via => :post, :as => 'add_tenant'
|
197
205
|
end
|
198
206
|
|
199
|
-
resources :role_definitions, :
|
207
|
+
resources :role_definitions, only: %i[new create]
|
200
208
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class DeviseCreateKauiUsers < ActiveRecord::Migration[5.0]
|
2
4
|
def change
|
3
|
-
|
4
|
-
create_table(:kaui_users) do |t|
|
5
|
-
# From Kill Bill
|
6
|
-
t.string :kb_username, :null => false
|
7
|
-
t.string :kb_session_id, :null => true
|
8
|
-
t.timestamps
|
9
|
-
end
|
5
|
+
return if table_exists?(:kaui_users)
|
10
6
|
|
11
|
-
|
7
|
+
create_table(:kaui_users) do |t|
|
8
|
+
# From Kill Bill
|
9
|
+
t.string :kb_username, null: false
|
10
|
+
t.string :kb_session_id, null: true
|
11
|
+
t.timestamps
|
12
12
|
end
|
13
|
+
|
14
|
+
add_index :kaui_users, [:kb_username], unique: true
|
13
15
|
end
|
14
16
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class CreateKauiTenants < ActiveRecord::Migration[5.0]
|
2
4
|
def change
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
return if table_exists?(:kaui_tenants)
|
6
|
+
|
7
|
+
create_table :kaui_tenants do |t|
|
8
|
+
t.string :name
|
9
|
+
t.string :kb_tenant_id
|
10
|
+
t.string :api_key
|
11
|
+
t.string :encrypted_api_secret
|
9
12
|
|
10
|
-
|
11
|
-
end
|
13
|
+
t.timestamps
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class CreateKauiAllowedUsers < ActiveRecord::Migration[5.0]
|
2
4
|
def change
|
3
5
|
unless table_exists?(:kaui_allowed_users)
|
@@ -7,17 +9,17 @@ class CreateKauiAllowedUsers < ActiveRecord::Migration[5.0]
|
|
7
9
|
t.timestamps
|
8
10
|
end
|
9
11
|
|
10
|
-
add_index :kaui_allowed_users, [:kb_username], :
|
12
|
+
add_index :kaui_allowed_users, [:kb_username], unique: true
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
create_table :kaui_allowed_user_tenants do |t|
|
15
|
-
t.belongs_to :kaui_allowed_user
|
16
|
-
t.belongs_to :kaui_tenant
|
17
|
-
t.timestamps null: false
|
18
|
-
end
|
15
|
+
return if table_exists?(:kaui_allowed_user_tenants)
|
19
16
|
|
20
|
-
|
17
|
+
create_table :kaui_allowed_user_tenants do |t|
|
18
|
+
t.belongs_to :kaui_allowed_user
|
19
|
+
t.belongs_to :kaui_tenant
|
20
|
+
t.timestamps null: false
|
21
21
|
end
|
22
|
+
|
23
|
+
add_index :kaui_allowed_user_tenants, %i[kaui_allowed_user_id kaui_tenant_id], unique: true, name: 'kaui_allowed_user_tenants_uniq'
|
22
24
|
end
|
23
25
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators'
|
2
4
|
require 'kaui/version'
|
3
5
|
|
4
6
|
module Kaui
|
5
7
|
class InstallGenerator < Rails::Generators::Base
|
6
|
-
class_option :lib_name, :
|
8
|
+
class_option :lib_name, type: :string, default: 'kaui'
|
7
9
|
|
8
10
|
def self.source_paths
|
9
|
-
paths =
|
11
|
+
paths = superclass.source_paths
|
10
12
|
paths << File.expand_path('../templates', "../../#{__FILE__}")
|
11
13
|
paths << File.expand_path('../templates', "../#{__FILE__}")
|
12
|
-
paths << File.expand_path('
|
14
|
+
paths << File.expand_path('templates', __dir__)
|
13
15
|
paths.flatten
|
14
16
|
end
|
15
17
|
|
@@ -18,7 +20,7 @@ module Kaui
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def config_kaui_yml
|
21
|
-
create_file
|
23
|
+
create_file 'config/kaui.yml' do
|
22
24
|
settings = { 'version' => Kaui::VERSION }
|
23
25
|
|
24
26
|
settings.to_yaml
|
@@ -26,43 +28,44 @@ module Kaui
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def additional_tweaks
|
29
|
-
return unless File.
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
return unless File.exist? 'public/robots.txt'
|
32
|
+
|
33
|
+
append_file 'public/robots.txt', <<~ROBOTS
|
34
|
+
User-agent: *
|
35
|
+
Disallow: /kaui
|
33
36
|
ROBOTS
|
34
37
|
end
|
35
38
|
|
36
39
|
def setup_assets
|
37
40
|
@lib_name = 'kaui'
|
38
|
-
%w
|
41
|
+
%w[javascripts stylesheets images].each do |path|
|
39
42
|
empty_directory "app/assets/#{path}/kaui"
|
40
43
|
end
|
41
44
|
|
42
|
-
template
|
43
|
-
template
|
45
|
+
template 'app/assets/javascripts/kaui/all.js'
|
46
|
+
template 'app/assets/stylesheets/kaui/all.css'
|
44
47
|
end
|
45
48
|
|
46
49
|
def update_routes
|
47
|
-
insert_into_file File.join('config', 'routes.rb'), :
|
48
|
-
%
|
50
|
+
insert_into_file File.join('config', 'routes.rb'), after: "Application.routes.draw do\n" do
|
51
|
+
%(
|
49
52
|
# This line mounts Kaui's routes at the root of your application.
|
50
53
|
# If you're mounting this engine into an existing application, change it to e.g.
|
51
54
|
# mount Kaui::Engine, :at => '/kaui', :as => "kaui_engine"
|
52
55
|
#
|
53
56
|
# Don't modify the :as => "kaui_engine" option though.
|
54
57
|
mount Kaui::Engine, :at => '/', :as => "kaui_engine"
|
55
|
-
|
58
|
+
)
|
56
59
|
end
|
57
60
|
end
|
58
61
|
|
59
62
|
def complete
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
return if options[:quiet]
|
64
|
+
|
65
|
+
puts '*' * 50
|
66
|
+
puts "Kaui has been installed successfully. You're all ready to go!"
|
67
|
+
puts ' '
|
68
|
+
puts 'Enjoy!'
|
66
69
|
end
|
67
70
|
end
|
68
71
|
end
|
data/lib/kaui/engine.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Dependencies
|
2
4
|
#
|
3
5
|
# Sigh. Rails autoloads the gems specified in the Gemfile and nothing else.
|
4
6
|
# We need to explicitly require all of our dependencies listed in kaui.gemspec
|
5
7
|
#
|
6
8
|
# See also https://github.com/carlhuda/bundler/issues/49
|
9
|
+
|
7
10
|
require 'js-routes'
|
8
11
|
require 'jquery-rails'
|
9
12
|
require 'jquery-ui-rails'
|
10
13
|
require 'jquery-datatables-rails'
|
11
|
-
require 'font-awesome-
|
12
|
-
require '
|
14
|
+
require 'font-awesome-sass'
|
15
|
+
require 'bootstrap-sass'
|
13
16
|
require 'bootstrap-datepicker-rails'
|
14
|
-
require 'less-rails'
|
15
17
|
require 'json'
|
16
18
|
require 'money-rails'
|
17
19
|
require 'killbill_client'
|
@@ -21,13 +23,23 @@ require 'cancan'
|
|
21
23
|
require 'country_select'
|
22
24
|
require 'concurrent'
|
23
25
|
require 'mustache-js-rails'
|
26
|
+
require 'nokogiri'
|
27
|
+
require 'time'
|
28
|
+
require 'd3-rails'
|
29
|
+
require 'spinjs-rails'
|
30
|
+
require 'popper_js'
|
24
31
|
|
25
32
|
module Kaui
|
26
33
|
class Engine < ::Rails::Engine
|
27
34
|
isolate_namespace Kaui
|
35
|
+
config.autoload_once_paths = %W[
|
36
|
+
#{root}/app/controllers
|
37
|
+
#{root}/app/helpers
|
38
|
+
#{root}/app/models
|
39
|
+
]
|
28
40
|
|
29
|
-
initializer 'kaui_engine.action_controller' do |
|
30
|
-
ActiveSupport.on_load :
|
41
|
+
initializer 'kaui_engine.action_controller', before: :load_config_initializers do |_app|
|
42
|
+
ActiveSupport.on_load :action_controller_base do
|
31
43
|
helper Kaui::Engine.helpers
|
32
44
|
end
|
33
45
|
|