Merge pull request #477 from imperosol/eboutic

Refonte de la boutique en ligne
This commit is contained in:
thomas girod
2022-10-31 16:28:56 +01:00
committed by GitHub
23 changed files with 1514 additions and 761 deletions

View File

@ -325,6 +325,13 @@ class User(AbstractBaseUser):
)
return s.exists()
@cached_property
def account_balance(self):
if hasattr(self, "customer"):
return self.customer.amount
else:
return 0
_club_memberships = {}
_group_names = {}
_group_ids = {}
@ -459,6 +466,20 @@ class User(AbstractBaseUser):
def is_banned_counter(self):
return self.is_in_group(settings.SITH_GROUP_BANNED_COUNTER_ID)
@cached_property
def age(self) -> int:
"""
Return the age this user has the day the method is called.
"""
today = timezone.now()
age = today.year - self.date_of_birth.year
# remove a year if this year's birthday is yet to come
age -= (today.month, today.day) < (
self.date_of_birth.month,
self.date_of_birth.day,
)
return age
def save(self, *args, **kwargs):
create = False
with transaction.atomic():