This repository was archived by the owner on Jun 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathhelpers.py
More file actions
193 lines (178 loc) · 6 KB
/
helpers.py
File metadata and controls
193 lines (178 loc) · 6 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
from django.conf import settings
from django.db.models import QuerySet
from shared.django_apps.codecov_auth.models import BillingRate
from shared.django_apps.codecov_auth.tests.factories import PlanFactory, TierFactory
from shared.plan.constants import DEFAULT_FREE_PLAN, PlanName, PlanPrice, TierName
from codecov_auth.models import Owner, Plan
def on_enterprise_plan(owner: Owner) -> bool:
plan = Plan.objects.select_related("tier").get(name=owner.plan)
return settings.IS_ENTERPRISE or (plan.tier.tier_name == TierName.ENTERPRISE.value)
def get_all_admins_for_owners(owners: QuerySet[Owner]):
admin_ids = set()
for owner in owners:
if owner.admins:
admin_ids.update(owner.admins)
# Add the owner's email as well - for user owners, admins is empty.
if owner.email:
admin_ids.add(owner.ownerid)
admins: QuerySet[Owner] = Owner.objects.filter(pk__in=admin_ids)
return admins
def mock_all_plans_and_tiers():
TierFactory(tier_name=TierName.BASIC.value)
trial_tier = TierFactory(tier_name=TierName.TRIAL.value)
PlanFactory(
tier=trial_tier,
name=PlanName.TRIAL_PLAN_NAME.value,
paid_plan=False,
marketing_name="Developer",
benefits=[
"Configurable # of users",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
stripe_id="plan_trial",
)
pro_tier = TierFactory(tier_name=TierName.PRO.value)
PlanFactory(
name=PlanName.CODECOV_PRO_MONTHLY.value,
tier=pro_tier,
marketing_name="Pro",
benefits=[
"Configurable # of users",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
billing_rate=BillingRate.MONTHLY.value,
base_unit_price=PlanPrice.MONTHLY.value,
paid_plan=True,
stripe_id="plan_pro",
)
PlanFactory(
name=PlanName.CODECOV_PRO_YEARLY.value,
tier=pro_tier,
marketing_name="Pro",
benefits=[
"Configurable # of users",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
billing_rate=BillingRate.ANNUALLY.value,
base_unit_price=PlanPrice.YEARLY.value,
paid_plan=True,
stripe_id="plan_pro_yearly",
)
team_tier = TierFactory(tier_name=TierName.TEAM.value)
PlanFactory(
name=PlanName.TEAM_MONTHLY.value,
tier=team_tier,
marketing_name="Team",
benefits=[
"Up to 10 users",
"Unlimited repositories",
"2500 private repo uploads",
"Patch coverage analysis",
],
billing_rate=BillingRate.MONTHLY.value,
base_unit_price=PlanPrice.TEAM_MONTHLY.value,
monthly_uploads_limit=2500,
paid_plan=True,
stripe_id="plan_team_monthly",
)
PlanFactory(
name=PlanName.TEAM_YEARLY.value,
tier=team_tier,
marketing_name="Team",
benefits=[
"Up to 10 users",
"Unlimited repositories",
"2500 private repo uploads",
"Patch coverage analysis",
],
billing_rate=BillingRate.ANNUALLY.value,
base_unit_price=PlanPrice.TEAM_YEARLY.value,
monthly_uploads_limit=2500,
paid_plan=True,
stripe_id="plan_team_yearly",
)
sentry_tier = TierFactory(tier_name=TierName.SENTRY.value)
PlanFactory(
name=PlanName.SENTRY_MONTHLY.value,
tier=sentry_tier,
marketing_name="Sentry Pro",
billing_rate=BillingRate.MONTHLY.value,
base_unit_price=PlanPrice.MONTHLY.value,
paid_plan=True,
benefits=[
"Includes 5 seats",
"$12 per additional seat",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
stripe_id="plan_sentry_monthly",
)
PlanFactory(
name=PlanName.SENTRY_YEARLY.value,
tier=sentry_tier,
marketing_name="Sentry Pro",
billing_rate=BillingRate.ANNUALLY.value,
base_unit_price=PlanPrice.YEARLY.value,
paid_plan=True,
benefits=[
"Includes 5 seats",
"$10 per additional seat",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
stripe_id="plan_sentry_yearly",
)
enterprise_tier = TierFactory(tier_name=TierName.ENTERPRISE.value)
PlanFactory(
name=PlanName.ENTERPRISE_CLOUD_MONTHLY.value,
tier=enterprise_tier,
marketing_name="Enterprise Cloud",
billing_rate=BillingRate.MONTHLY.value,
base_unit_price=PlanPrice.MONTHLY.value,
paid_plan=True,
benefits=[
"Configurable # of users",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
stripe_id="plan_enterprise_cloud_monthly",
)
PlanFactory(
name=PlanName.ENTERPRISE_CLOUD_YEARLY.value,
tier=enterprise_tier,
marketing_name="Enterprise Cloud",
billing_rate=BillingRate.ANNUALLY.value,
base_unit_price=PlanPrice.YEARLY.value,
paid_plan=True,
benefits=[
"Configurable # of users",
"Unlimited public repositories",
"Unlimited private repositories",
"Priority Support",
],
stripe_id="plan_enterprise_cloud_yearly",
)
PlanFactory(
name=DEFAULT_FREE_PLAN,
tier=team_tier,
marketing_name="Developer",
billing_rate=None,
base_unit_price=0,
paid_plan=False,
monthly_uploads_limit=250,
benefits=[
"Up to 1 user",
"Unlimited public repositories",
"Unlimited private repositories",
],
stripe_id="plan_default_free",
)