bullet_train 1.0.81 → 1.0.83
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/account/controllers/base.rb +9 -0
- data/app/helpers/base_helper.rb +5 -1
- data/app/models/concerns/memberships/base.rb +5 -0
- data/app/models/concerns/records/base.rb +8 -0
- data/app/models/concerns/teams/base.rb +19 -0
- data/config/locales/en/billing/products.en.yml +17 -0
- data/lib/bullet_train/version.rb +1 -1
- data/lib/bullet_train.rb +6 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2119a17f5ed1aace492642ab674c8fb67cadefd29100aee3809e590813da3bb
|
4
|
+
data.tar.gz: '0679c15de2ec6260be9beab3c1261fbef4892cacd961d285f813229aac5b1616'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807684f8b6d5a99a6d35a78d0e50cbeb8a0ef40d06b1e56c1c653a6851ea0289e50c75f2a1e75a1500f6799f3fcd91a603fffaa64ea12324068a851290e67186
|
7
|
+
data.tar.gz: 964b44f5ddaa872e26e8cefcf0dd6f9a11d19fc7d3b435e10e7a14d6f62c420a60945dde1eb0c9c588f049cd64423e93c82c52e2b207c01c2cfbe7d58c5b125b
|
@@ -5,6 +5,10 @@ module Account::Controllers::Base
|
|
5
5
|
include LoadsAndAuthorizesResource
|
6
6
|
include Fields::ControllerSupport
|
7
7
|
|
8
|
+
if billing_enabled?
|
9
|
+
include Billing::ControllerSupport
|
10
|
+
end
|
11
|
+
|
8
12
|
before_action :set_last_seen_at, if: proc {
|
9
13
|
user_signed_in? && (current_user.last_seen_at.nil? || current_user.last_seen_at < 1.minute.ago)
|
10
14
|
}
|
@@ -106,6 +110,11 @@ module Account::Controllers::Base
|
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
113
|
+
# TODO Maybe in this context we should check whether `Billing::ControllerSupport` is included instead of just defined?
|
114
|
+
if defined?(Billing::ControllerSupport)
|
115
|
+
enforce_billing_requirements
|
116
|
+
# See `app/controllers/concerns/billing_support.rb` for details.
|
117
|
+
end
|
109
118
|
end
|
110
119
|
|
111
120
|
true
|
data/app/helpers/base_helper.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module BaseHelper
|
2
2
|
# TODO This is for the billing package to override, but I feel like there has got to be a better way to do this.
|
3
3
|
def hide_team_resource_menus?
|
4
|
-
|
4
|
+
if billing_enabled?
|
5
|
+
current_team.needs_billing_subscription?
|
6
|
+
else
|
7
|
+
false
|
8
|
+
end
|
5
9
|
end
|
6
10
|
end
|
@@ -29,6 +29,11 @@ module Memberships::Base
|
|
29
29
|
scope :current_and_invited, -> { includes(:invitation).where("user_id IS NOT NULL OR invitations.id IS NOT NULL").references(:invitation) }
|
30
30
|
scope :current, -> { where("user_id IS NOT NULL") }
|
31
31
|
scope :tombstones, -> { includes(:invitation).where("user_id IS NULL AND invitations.id IS NULL").references(:invitation) }
|
32
|
+
|
33
|
+
# TODO Probably we can provide a way for gem packages to define these kinds of extensions.
|
34
|
+
if billing_enabled?
|
35
|
+
scope :billable, -> { current }
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
def name
|
@@ -28,6 +28,14 @@ module Records::Base
|
|
28
28
|
scope :newest_updated, -> { order("updated_at DESC") }
|
29
29
|
scope :oldest_updated, -> { order("updated_at ASC") }
|
30
30
|
|
31
|
+
# TODO Probably we can provide a way for gem packages to define these kinds of extensions.
|
32
|
+
if billing_enabled?
|
33
|
+
# By default, any model in a collection is considered active for billing purposes.
|
34
|
+
# This can be overloaded in the child model class to specify more specific criteria for billing.
|
35
|
+
# See `app/models/concerns/memberships/base.rb` for an example.
|
36
|
+
scope :billable, -> { order("TRUE") }
|
37
|
+
end
|
38
|
+
|
31
39
|
# Microscope adds useful scopes targeting ActiveRecord `boolean`, `date` and `datetime` attributes.
|
32
40
|
# https://github.com/mirego/microscope
|
33
41
|
acts_as_microscope
|
@@ -18,6 +18,17 @@ module Teams::Base
|
|
18
18
|
# integrations
|
19
19
|
has_many :integrations_stripe_installations, class_name: "Integrations::StripeInstallation", dependent: :destroy if stripe_enabled?
|
20
20
|
|
21
|
+
# TODO Probably we can provide a way for gem packages to define these kinds of extensions.
|
22
|
+
if billing_enabled?
|
23
|
+
# subscriptions
|
24
|
+
has_many :billing_subscriptions, class_name: "Billing::Subscription", dependent: :destroy, foreign_key: :team_id
|
25
|
+
|
26
|
+
# TODO We need a way for `bullet_train-billing-stripe` to define these.
|
27
|
+
if defined?(Billing::Stripe::Subscription)
|
28
|
+
has_many :billing_stripe_subscriptions, class_name: "Billing::Stripe::Subscription", dependent: :destroy, foreign_key: :team_id
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
21
32
|
# validations
|
22
33
|
validates :name, presence: true
|
23
34
|
validates :time_zone, inclusion: {in: ActiveSupport::TimeZone.all.map(&:name)}, allow_nil: true
|
@@ -48,4 +59,12 @@ module Teams::Base
|
|
48
59
|
# generic functions need to function for a team model as well, so we do this.
|
49
60
|
self
|
50
61
|
end
|
62
|
+
|
63
|
+
# TODO Probably we can provide a way for gem packages to define these kinds of extensions.
|
64
|
+
if billing_enabled?
|
65
|
+
def needs_billing_subscription?
|
66
|
+
return false if freemium_enabled?
|
67
|
+
billing_subscriptions.active.empty?
|
68
|
+
end
|
69
|
+
end
|
51
70
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
en:
|
2
|
+
billing/products:
|
3
|
+
free:
|
4
|
+
name: Free
|
5
|
+
basic:
|
6
|
+
name: Basic
|
7
|
+
description: This is an example plan that includes a free trial when paid for monthly.
|
8
|
+
features:
|
9
|
+
- Demonstrates pricing per team member.
|
10
|
+
- Allows creation of up to fifty "Creative Concepts".
|
11
|
+
- Soft enforcement that limit.
|
12
|
+
pro:
|
13
|
+
name: Pro
|
14
|
+
description: An improved example plan that demonstrates different features.
|
15
|
+
features:
|
16
|
+
- Demonstrates a fixed price for up to ten team members.
|
17
|
+
- Allows creation of an unlimited number of "Creative Concepts".
|
data/lib/bullet_train/version.rb
CHANGED
data/lib/bullet_train.rb
CHANGED
@@ -61,7 +61,12 @@ def inbound_email_enabled?
|
|
61
61
|
ENV["INBOUND_EMAIL_DOMAIN"].present?
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def billing_enabled?
|
65
|
+
defined?(BulletTrain::Billing)
|
66
|
+
end
|
67
|
+
|
68
|
+
# TODO This should be in an initializer or something.
|
69
|
+
def billing_subscription_creation_disabled?
|
65
70
|
false
|
66
71
|
end
|
67
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.83
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -556,6 +556,7 @@ files:
|
|
556
556
|
- config/initializers/concerns/inflections_base.rb
|
557
557
|
- config/initializers/concerns/turbo_failure_app.rb
|
558
558
|
- config/locales/en/base.yml
|
559
|
+
- config/locales/en/billing/products.en.yml
|
559
560
|
- config/locales/en/devise.en.yml
|
560
561
|
- config/locales/en/doorkeeper.en.yml
|
561
562
|
- config/locales/en/invitations.en.yml
|