Skip to content

Commit

Permalink
Remove active users period 1 month default
Browse files Browse the repository at this point in the history
  • Loading branch information
faebebin committed Jul 3, 2023
1 parent a77c97f commit 44a410f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions docker-app/qfieldcloud/subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,14 @@ class UpdateSubscriptionKwargs(TypedDict):
billing_cycle_anchor_at = models.DateTimeField(null=True, blank=True)

# the timestamp when the current billing period started
# NOTE this field remains currently unused.
# NOTE ignored when checking if subscription is 'current' (see `active_since and `active_until`).
# `current_period_since` and `current_period_until` are both either `None` or `datetime`
current_period_since = models.DateTimeField(null=True, blank=True)

# the timestamp when the current billing period ends
# NOTE ignored for subscription validity checks, but used to calculate the activation date when additional packages change
# NOTE ignored when checking if subscription is 'current' (see `active_since and `active_until`),
# but used to calculate the activation date when additional packages change.
# `current_period_since` and `current_period_until` are both either `None` or `datetime`
current_period_until = models.DateTimeField(null=True, blank=True)

# admin only notes, not visible to end users
Expand Down Expand Up @@ -588,14 +591,7 @@ def active_users_period(self):
self.current_period_until,
)

assert (
self.current_period_since == self.current_period_until
), "Both current_period _since and _until must be set."

now = timezone.now()
month_ago = now - timedelta(days=28)

return (month_ago, now)
return None

@property
def active_users(self):
Expand All @@ -610,7 +606,7 @@ def active_users_count(self) -> int:
if not self.account.user.is_organization:
return 1

if not self.current_period_since or not self.current_period_until:
if self.active_users is None:
return 0

return self.active_users.count()
Expand Down

0 comments on commit 44a410f

Please sign in to comment.