refonte de la boutique en ligne

This commit is contained in:
Thomas Girod
2022-09-25 21:29:42 +02:00
parent b3a48ca5af
commit 8b09ba2924
23 changed files with 1520 additions and 771 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():