-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Excessive 404s on subscription metadata (#2985)
- Loading branch information
Showing
8 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
from rest_framework.exceptions import APIException | ||
|
||
|
||
class OrganisationHasNoSubscription(APIException): | ||
class OrganisationHasNoPaidSubscription(APIException): | ||
status_code = 400 | ||
default_detail = "Organisation has no subscription" | ||
|
||
|
||
class SubscriptionNotFound(APIException): | ||
status_code = 404 | ||
default_detail = "Subscription Not found" |
32 changes: 32 additions & 0 deletions
32
api/organisations/migrations/0048_add_default_subscription_to_orphaned_organisations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 3.2.23 on 2023-11-16 16:01 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def create_default_subscription(apps, schema_editor): | ||
Organisation = apps.get_model("organisations", "Organisation") | ||
Subscription = apps.get_model("organisations", "Subscription") | ||
|
||
organisations_without_subscription = Organisation.objects.filter( | ||
subscription__isnull=True | ||
) | ||
|
||
subscriptions_to_create = [] | ||
for organisation in organisations_without_subscription: | ||
subscriptions_to_create.append(Subscription(organisation=organisation)) | ||
|
||
Subscription.objects.bulk_create(subscriptions_to_create) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('organisations', '0047_organisation_force_2fa'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
create_default_subscription, | ||
reverse_code=migrations.RunPython.noop, | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
627a6fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
flagsmith-staging-frontend.vercel.app
staging.flagsmith.com
627a6fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
627a6fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
docs-flagsmith.vercel.app