Improve age management for getting products and make get_product a part of counter model

This commit is contained in:
2024-12-22 12:27:58 +01:00
parent 372470b44b
commit eed434aeb2
4 changed files with 33 additions and 44 deletions

View File

@ -578,14 +578,6 @@ class User(AbstractUser):
return "%s (%s)" % (self.get_full_name(), self.nick_name)
return self.get_full_name()
def get_age(self):
"""Returns the age."""
today = timezone.now()
born = self.date_of_birth
return (
today.year - born.year - ((today.month, today.day) < (born.month, born.day))
)
def get_family(
self,
godfathers_depth: NonNegativeInt = 4,

View File

@ -60,7 +60,7 @@
{% endif %}
{% if user.date_of_birth %}
<div class="user_mini_profile_dob">
{{ user.date_of_birth|date("d/m/Y") }} ({{ user.get_age() }})
{{ user.date_of_birth|date("d/m/Y") }} ({{ user.age }})
</div>
{% endif %}
</div>