Skip to content

Commit

Permalink
Merge pull request #963 from opengisch/QF-3925-default-subscription
Browse files Browse the repository at this point in the history
Set initial created subscription plan status to ACTIVE_PAID
  • Loading branch information
suricactus authored Jun 20, 2024
2 parents 61288ce + ae50051 commit db5ae13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ def add_packages_to_accounts(apps, schema_editor):
package.save()


def set_existing_plans_to_active_status(apps, schema_editor):
Plan = apps.get_model("subscription", "Plan")

Plan.objects.update(
initial_subscription_status="active_paid",
)


class Migration(migrations.Migration):
dependencies = [
("subscription", "0003_auto_20221028_1901"),
Expand Down Expand Up @@ -346,6 +354,10 @@ class Migration(migrations.Migration):
max_length=100,
),
),
migrations.RunPython(
set_existing_plans_to_active_status,
migrations.RunPython.noop,
),
migrations.AddField(
model_name="plan",
name="is_metered",
Expand Down
2 changes: 2 additions & 0 deletions docker-app/qfieldcloud/subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ def get_or_create_default(cls) -> "Plan":
is_default=True,
is_public=False,
user_type=User.Type.PERSON,
initial_subscription_status=SubscriptionStatus.ACTIVE_PAID,
)
cls.objects.create(
code="default_org",
display_name="default organization (autocreated)",
is_default=True,
is_public=False,
user_type=User.Type.ORGANIZATION,
initial_subscription_status=SubscriptionStatus.ACTIVE_PAID,
)
result = cls.objects.order_by("-is_default").first()
return cast(Plan, result)
Expand Down

0 comments on commit db5ae13

Please sign in to comment.