From 9033c8453c303cd6a360b9a753ff940e93e5b2c2 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 6 Nov 2022 14:42:29 +0100 Subject: [PATCH] Display states on character card --- .idea/charasheet.iml | 3 +++ .../templates/character/character_details.html | 4 ---- .../snippets/characters_list/character_card.html | 14 +++++++++++++- src/character/views.py | 3 ++- .../static/character => common/static}/style.css | 0 src/common/templates/common/base.html | 1 + src/party/views.py | 7 +++++-- 7 files changed, 24 insertions(+), 8 deletions(-) rename src/{character/static/character => common/static}/style.css (100%) diff --git a/.idea/charasheet.iml b/.idea/charasheet.iml index b15df4a..41056d5 100644 --- a/.idea/charasheet.iml +++ b/.idea/charasheet.iml @@ -15,6 +15,9 @@ + + + diff --git a/src/character/templates/character/character_details.html b/src/character/templates/character/character_details.html index 208dadf..681e209 100644 --- a/src/character/templates/character/character_details.html +++ b/src/character/templates/character/character_details.html @@ -5,10 +5,6 @@ {% block title %}{{ character.name }}{% endblock %} -{% block head_end %} - -{% endblock %} - {% block content %}

{{ character.name }}

diff --git a/src/character/templates/character/snippets/characters_list/character_card.html b/src/character/templates/character/snippets/characters_list/character_card.html index 5f5e8cc..00dc287 100644 --- a/src/character/templates/character/snippets/characters_list/character_card.html +++ b/src/character/templates/character/snippets/characters_list/character_card.html @@ -7,7 +7,19 @@

{{ character.race.name }} {{ character.profile.name }} niv. {{ character.level }}
{{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg
- PV {{ character.health_remaining }}/{{ character.health_max }}, PM {{ character.mana_remaining }}/{{ character.mana_max }} + PV {{ character.health_remaining }}/{{ character.health_max }}, PM {{ character.mana_remaining }}/{{ character.mana_max }}
+ {% with character.states.all as character_states %} + {% for state in all_states %} + {{ state.name }} + {% endfor %} + {% endwith %}

{% if character.player == user %}
diff --git a/src/character/views.py b/src/character/views.py index 27f3fdf..6ba56b8 100644 --- a/src/character/views.py +++ b/src/character/views.py @@ -13,7 +13,8 @@ def characters_list(request): context = { "characters": Character.objects.owned_by(request.user).select_related( "race", "profile" - ) + ), + "all_states": HarmfulState.objects.all(), } return render(request, "character/characters_list.html", context) diff --git a/src/character/static/character/style.css b/src/common/static/style.css similarity index 100% rename from src/character/static/character/style.css rename to src/common/static/style.css diff --git a/src/common/templates/common/base.html b/src/common/templates/common/base.html index fab751a..ae33b43 100644 --- a/src/common/templates/common/base.html +++ b/src/common/templates/common/base.html @@ -16,6 +16,7 @@ touch-action: manipulation; } + {% block head_end %} {% endblock %} diff --git a/src/party/views.py b/src/party/views.py index 5f05e2e..f0854ec 100644 --- a/src/party/views.py +++ b/src/party/views.py @@ -2,7 +2,7 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required from django.shortcuts import get_object_or_404, redirect, render -from character.models import Character +from character.models import Character, HarmfulState from party.forms import PartyForm from party.models import Party @@ -35,7 +35,10 @@ def party_create(request): @login_required def party_details(request, pk): party = get_object_or_404(Party.objects.related_to(request.user), pk=pk) - context = {"party": party} + context = { + "party": party, + "all_states": HarmfulState.objects.all(), + } return render(request, "party/party_details.html", context)