Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit d34ea49

Browse files
committed
revert trial status changes, update other instances of plan stuff
1 parent 43131b9 commit d34ea49

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

api/internal/owner/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from shared.plan.constants import (
1010
PAID_PLANS,
1111
TEAM_PLAN_MAX_USERS,
12-
TEAM_PLAN_REPRESENTATIONS,
1312
TierName,
1413
)
1514
from shared.plan.service import PlanService
@@ -173,7 +172,8 @@ def validate(self, plan: Dict[str, Any]) -> Dict[str, Any]:
173172
"Quantity or plan for paid plan must be different from the existing one"
174173
)
175174
if (
176-
plan["value"] in TEAM_PLAN_REPRESENTATIONS
175+
plan["value"]
176+
in Plan.objects.filter(tier=TierName.TEAM.value, is_active=True)
177177
and plan["quantity"] > TEAM_PLAN_MAX_USERS
178178
):
179179
raise serializers.ValidationError(

codecov_auth/management/commands/set_trial_status_values.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
from typing import Any
33

44
from django.core.management.base import BaseCommand, CommandParser
5-
from django.db.models import Q, Subquery
5+
from django.db.models import Q
66
from shared.plan.constants import (
77
FREE_PLAN_REPRESENTATIONS,
88
PLANS_THAT_CAN_TRIAL,
9-
TierName,
9+
PR_AUTHOR_PAID_USER_PLAN_REPRESENTATIONS,
10+
SENTRY_PAID_USER_PLAN_REPRESENTATIONS,
11+
PlanName,
1012
TrialStatus,
1113
)
1214

@@ -30,12 +32,10 @@ def handle(self, *args: Any, **options: Any) -> None:
3032
stripe_customer_id=None,
3133
).update(trial_status=TrialStatus.NOT_STARTED.value)
3234

33-
sentry_plans = Plan.objects.filter(tier=TierName.SENTRY.value)
34-
pro_plans = Plan.objects.filter(tier=TierName.PRO.value, paid_plan=True)
3535
# ONGOING
3636
if trial_status_type == "all" or trial_status_type == "ongoing":
3737
Owner.objects.filter(
38-
plan__in=Subquery(sentry_plans.values_list("name", flat=True)),
38+
plan__in=SENTRY_PAID_USER_PLAN_REPRESENTATIONS,
3939
trial_end_date__gt=datetime.now(),
4040
).update(trial_status=TrialStatus.ONGOING.value)
4141

@@ -44,22 +44,22 @@ def handle(self, *args: Any, **options: Any) -> None:
4444
Owner.objects.filter(
4545
# Currently paying sentry customer with trial_end_date
4646
Q(
47-
plan__in=Subquery(sentry_plans.values_list("name", flat=True)),
47+
plan__in=SENTRY_PAID_USER_PLAN_REPRESENTATIONS,
4848
stripe_customer_id__isnull=False,
4949
stripe_subscription_id__isnull=False,
5050
trial_end_date__lte=datetime.now(),
5151
)
5252
# Currently paying sentry customer without trial_end_date
5353
| Q(
54-
plan__in=Subquery(sentry_plans.values_list("name", flat=True)),
54+
plan__in=SENTRY_PAID_USER_PLAN_REPRESENTATIONS,
5555
stripe_customer_id__isnull=False,
5656
stripe_subscription_id__isnull=False,
5757
trial_start_date__isnull=True,
5858
trial_end_date__isnull=True,
5959
)
6060
# Previously paid but now back to basic with trial start/end dates
6161
| Q(
62-
plan="users-basic",
62+
plan=PlanName.BASIC_PLAN_NAME.value,
6363
stripe_customer_id__isnull=False,
6464
trial_start_date__isnull=False,
6565
trial_end_date__isnull=False,
@@ -73,20 +73,20 @@ def handle(self, *args: Any, **options: Any) -> None:
7373
~Q(plan__in=PLANS_THAT_CAN_TRIAL)
7474
# Previously paid but now back to basic without trial start/end dates
7575
| Q(
76-
plan="users-basic",
76+
plan=PlanName.BASIC_PLAN_NAME.value,
7777
stripe_customer_id__isnull=False,
7878
trial_start_date__isnull=True,
7979
trial_end_date__isnull=True,
8080
)
8181
# Currently paying customer that isn't a sentry plan (they would be expired)
8282
| Q(
83-
~Q(plan__in=Subquery(sentry_plans.values_list("name", flat=True))),
83+
~Q(plan__in=SENTRY_PAID_USER_PLAN_REPRESENTATIONS),
8484
stripe_subscription_id__isnull=False,
8585
stripe_customer_id__isnull=False,
8686
)
8787
# Invoiced customers without stripe info
8888
| Q(
89-
Q(plan__in=Subquery(pro_plans.values_list("name", flat=True))),
89+
Q(plan__in=PR_AUTHOR_PAID_USER_PLAN_REPRESENTATIONS),
9090
stripe_subscription_id__isnull=True,
9191
stripe_customer_id__isnull=True,
9292
)

graphql_api/types/owner/owner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ariadne import ObjectType
99
from django.conf import settings
1010
from graphql import GraphQLResolveInfo
11-
from shared.plan.constants import FREE_PLAN_REPRESENTATIONS, PlanData, PlanName
11+
from shared.plan.constants import PlanData, PlanName
1212
from shared.plan.service import PlanService
1313

1414
import services.activation as activation
@@ -112,7 +112,7 @@ def resolve_plan(owner: Owner, info: GraphQLResolveInfo) -> PlanService:
112112
@require_part_of_org
113113
def resolve_plan_representation(owner: Owner, info: GraphQLResolveInfo) -> PlanData:
114114
info.context["plan_service"] = PlanService(current_org=owner)
115-
free_plan = FREE_PLAN_REPRESENTATIONS[PlanName.BASIC_PLAN_NAME.value]
115+
free_plan = Plan.objects.get(name=PlanName.BASIC_PLAN_NAME.value)
116116
return free_plan.convert_to_DTO()
117117

118118

services/billing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from dateutil.relativedelta import relativedelta
88
from django.conf import settings
99
from shared.plan.constants import (
10-
FREE_PLAN_REPRESENTATIONS,
1110
PAID_PLANS,
1211
TEAM_PLANS,
1312
PlanBillingRate,
@@ -736,7 +735,9 @@ def update_plan(self, owner, desired_plan):
736735
on current state, might create a stripe checkout session and return
737736
the checkout session's ID, which is a string. Otherwise returns None.
738737
"""
739-
if desired_plan["value"] in FREE_PLAN_REPRESENTATIONS:
738+
if desired_plan["value"] in Plan.objects.filter(paid_plan=False).values_list(
739+
"name", flat=True
740+
):
740741
if owner.stripe_subscription_id is not None:
741742
self.payment_service.delete_subscription(owner)
742743
else:

0 commit comments

Comments
 (0)