mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
Fix the test for ventes in the set_active function. This function could be greatly improved if the duraction could not be null.
This commit is contained in:
parent
8c06bd4fca
commit
23698a1653
1 changed files with 8 additions and 4 deletions
|
@ -931,10 +931,14 @@ class User(
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if self.state == self.STATE_NOT_YET_ACTIVE:
|
if self.state == self.STATE_NOT_YET_ACTIVE:
|
||||||
if self.facture_set.filter(valid=True).filter(
|
# Look for ventes with non 0 and non null subscription duration in the invoices set
|
||||||
~(Q(vente__duration_membership__isnull=True) | Q(vente__duration_membership=0)))\
|
not_null = self.facture_set.filter(valid=True).exclude(Q(vente__duration_membership__isnull=True)).exists()
|
||||||
.filter(~(Q(vente__duration_days_membership__isnull=True) | Q(vente__duration_days_membership=0))
|
not_zero = self.facture_set.filter(valid=True).exclude(Q(vente__duration_membership=0)).exists()
|
||||||
).exists() or OptionalUser.get_cached_value("all_users_active"):
|
days_not_null = self.facture_set.filter(valid=True).exclude(Q(vente__duration_days_membership__isnull=True)).exists()
|
||||||
|
days_not_zero = self.facture_set.filter(valid=True).exclude(Q(vente__duration_days_membership=0)).exists()
|
||||||
|
# if any vente is found, activate the user
|
||||||
|
if(not_null or not_zero or days_not_null or days_not_zero \
|
||||||
|
or OptionalUser.get_cached_value("all_users_active")):
|
||||||
self.state = self.STATE_ACTIVE
|
self.state = self.STATE_ACTIVE
|
||||||
self.save()
|
self.save()
|
||||||
if self.state == self.STATE_ARCHIVE or self.state == self.STATE_FULL_ARCHIVE:
|
if self.state == self.STATE_ARCHIVE or self.state == self.STATE_FULL_ARCHIVE:
|
||||||
|
|
Loading…
Reference in a new issue