Skip to content

Commit

Permalink
Revert "Revert "Merge pull request #620 from opengisch/subscription-a…
Browse files Browse the repository at this point in the history
…ctive-current""

This reverts commit b47bd3b.
  • Loading branch information
faebebin committed Jun 1, 2023
1 parent 90484c2 commit 535f503
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions docker-app/qfieldcloud/subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,10 @@ class Package(models.Model):


class SubscriptionQuerySet(models.QuerySet):
def active(self):
"""Returns the subscriptions which are relevant to the current moment.
WARNING the name `active` is super misleading, should be `current`. Some of the subscriptions in the queryset might not be active, but cancelled or drafted.
TODO rename to `current`
def current(self):
"""
Returns the subscriptions which are relevant to the current moment.
NOTE Some of the subscriptions in the queryset might not be active, but cancelled or drafted.
"""
now = timezone.now()
qs = self.filter(
Expand Down Expand Up @@ -693,7 +692,7 @@ def get_or_create_current_subscription(cls, account: UserAccount) -> "Subscripti
TODO Python 3.11 the actual return type is Self
"""
try:
subscription = cls.objects.active().get(account_id=account.pk)
subscription = cls.objects.current().get(account_id=account.pk)
except cls.DoesNotExist:
subscription = cls.create_default_plan_subscription(account)

Expand Down Expand Up @@ -740,7 +739,7 @@ def update_subscription(
subscription.active_since is None
and kwargs.get("active_since") is not None
):
cls.objects.active().filter(account=subscription.account,).exclude(
cls.objects.current().filter(account=subscription.account,).exclude(
pk=subscription.pk,
).update(
status=Subscription.Status.INACTIVE_CANCELLED,
Expand Down

0 comments on commit 535f503

Please sign in to comment.