mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-26 08:28:04 +01:00
Add more info to character view
This commit is contained in:
parent
fe5a5c53f6
commit
07d9e4b660
3 changed files with 19 additions and 2 deletions
|
@ -179,3 +179,11 @@ class Character(models.Model):
|
||||||
@property
|
@property
|
||||||
def mana_remaining(self) -> int:
|
def mana_remaining(self) -> int:
|
||||||
return self.mana_max - self.mana_consumed
|
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)
|
||||||
|
|
|
@ -4,5 +4,14 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ character.name }}</h1>
|
<h1>{{ character.name }}</h1>
|
||||||
<p><a href="{% url "admin:character_character_change" object_id=character.pk %}">Edit</a></p>
|
<p>
|
||||||
|
<a href="{% url "admin:character_character_change" object_id=character.pk %}">Edit</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Joueur : {{ character.player.get_full_name|default:character.player.username }}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{{ character.race.name }} {{ character.profile.name }} niv. {{ character.level }}<br>
|
||||||
|
{{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg (IMC: {{ character.imc }})
|
||||||
|
</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -8,6 +8,6 @@ from character.models import Character
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def character_view(request: WSGIRequest, pk: int) -> HttpResponse:
|
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}
|
context = {"character": character}
|
||||||
return render(request, "character/view.html", context)
|
return render(request, "character/view.html", context)
|
||||||
|
|
Loading…
Reference in a new issue