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

Commit b212b31

Browse files
committed
starting transition, need the other PR merged to do imports and test updates
1 parent ddb4755 commit b212b31

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

api/internal/owner/serializers.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from rest_framework.exceptions import PermissionDenied
99
from shared.plan.constants import (
1010
PAID_PLANS,
11-
SENTRY_PAID_USER_PLAN_REPRESENTATIONS,
1211
TEAM_PLAN_MAX_USERS,
1312
TEAM_PLAN_REPRESENTATIONS,
13+
TierName,
1414
)
1515
from shared.plan.service import PlanService
1616

@@ -131,11 +131,6 @@ def validate_value(self, value: str) -> str:
131131
plan["value"] for plan in plan_service.available_plans(current_owner)
132132
]
133133
if value not in plan_values:
134-
if value in SENTRY_PAID_USER_PLAN_REPRESENTATIONS:
135-
log.warning(
136-
"Non-Sentry user attempted to transition to Sentry plan",
137-
extra=dict(owner_id=current_owner.pk, plan=value),
138-
)
139134
raise serializers.ValidationError(
140135
f"Invalid value for plan: {value}; must be one of {plan_values}"
141136
)
@@ -336,7 +331,9 @@ def update(self, instance: Owner, validated_data: Dict[str, Any]) -> object:
336331
instance, desired_plan
337332
)
338333

339-
if desired_plan["value"] in SENTRY_PAID_USER_PLAN_REPRESENTATIONS:
334+
sentry_plans = Plan.objects.filter(tier=TierName.Sentry.value)
335+
336+
if desired_plan["value"] in sentry_plans:
340337
current_owner = self.context["view"].request.current_owner
341338
send_sentry_webhook(current_owner, instance)
342339

billing/helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
from django.conf import settings
22
from django.db.models import QuerySet
3-
from shared.plan.constants import ENTERPRISE_CLOUD_USER_PLAN_REPRESENTATIONS
3+
from shared.plan.constants import TierName
44

55
from codecov_auth.models import Owner
66

77

88
def on_enterprise_plan(owner: Owner) -> bool:
99
return settings.IS_ENTERPRISE or (
10-
owner.plan in ENTERPRISE_CLOUD_USER_PLAN_REPRESENTATIONS.keys()
10+
owner.plan
11+
in Plan.objects.filter(tier=TierName.ENTERPRISE.value).values_list(
12+
"name", flat=True
13+
)
1114
)
1215

1316

codecov_auth/admin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
InvoiceBilling,
2020
StripeBilling,
2121
)
22-
from shared.plan.constants import USER_PLAN_REPRESENTATIONS
2322
from shared.plan.service import PlanService
2423

2524
from codecov.admin import AdminMixin
@@ -607,7 +606,7 @@ class OwnerAdmin(AdminMixin, admin.ModelAdmin):
607606

608607
def get_form(self, request, obj=None, change=False, **kwargs):
609608
form = super().get_form(request, obj, change, **kwargs)
610-
PLANS_CHOICES = [(x, x) for x in USER_PLAN_REPRESENTATIONS.keys()]
609+
PLANS_CHOICES = [(x, x) for x in Plan.objects.values_list("name", flat=True)]
611610
form.base_fields["plan"].widget = Select(
612611
choices=BLANK_CHOICE_DASH + PLANS_CHOICES
613612
)

upload/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from redis import Redis
1616
from rest_framework.exceptions import NotFound, Throttled, ValidationError
1717
from shared.github import InvalidInstallationError
18-
from shared.plan.constants import USER_PLAN_REPRESENTATIONS
1918
from shared.plan.service import PlanService
2019
from shared.reports.enums import UploadType
2120
from shared.torngit.base import TorngitBaseAdapter
@@ -637,7 +636,10 @@ def validate_upload(
637636
owner = _determine_responsible_owner(repository)
638637

639638
# If author is on per repo billing, check their repo credits
640-
if owner.plan not in USER_PLAN_REPRESENTATIONS and owner.repo_credits <= 0:
639+
if (
640+
owner.plan not in Plan.object.values_list("name", flat=True)
641+
and owner.repo_credits <= 0
642+
):
641643
raise ValidationError(
642644
"Sorry, but this team has no private repository credits left."
643645
)

0 commit comments

Comments
 (0)