diff --git a/src/character/models/character.py b/src/character/models/character.py index 3db3de2..8113318 100644 --- a/src/character/models/character.py +++ b/src/character/models/character.py @@ -179,3 +179,11 @@ class Character(models.Model): @property def mana_remaining(self) -> int: return self.mana_max - self.mana_consumed + + @property + def height_m(self) -> float: + return round(self.height / 100, 2) + + @property + def imc(self) -> float: + return self.weight / (self.height_m**2) diff --git a/src/character/templates/character/view.html b/src/character/templates/character/view.html index 2ac1a50..5289428 100644 --- a/src/character/templates/character/view.html +++ b/src/character/templates/character/view.html @@ -4,5 +4,14 @@ {% block content %}

{{ character.name }}

-

Edit

+

+ Edit +

+

+ Joueur : {{ character.player.get_full_name|default:character.player.username }} +

+

+ {{ character.race.name }} {{ character.profile.name }} niv. {{ character.level }}
+ {{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg (IMC: {{ character.imc }}) +

{% endblock %} diff --git a/src/character/views.py b/src/character/views.py index 4449c6b..9b6e641 100644 --- a/src/character/views.py +++ b/src/character/views.py @@ -8,6 +8,6 @@ from character.models import Character @login_required def character_view(request: WSGIRequest, pk: int) -> HttpResponse: - character = get_object_or_404(Character, pk=pk) + character = get_object_or_404(Character.objects.select_related("player"), pk=pk) context = {"character": character} return render(request, "character/view.html", context)