mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
Merge pull request #477 from imperosol/eboutic
Refonte de la boutique en ligne
This commit is contained in:
@ -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():
|
||||
|
Reference in New Issue
Block a user