mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-04 22:03:56 +01:00
Refactor template snippets
This commit is contained in:
parent
cb787b7ed5
commit
a8f7d04bdf
15 changed files with 55 additions and 18 deletions
|
@ -10,7 +10,7 @@
|
|||
</a>
|
||||
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4">
|
||||
{% for character in characters %}
|
||||
{% include "character/character_card.html" %}
|
||||
{% include "character/snippets/characters_list/character_card.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
{% endif %}
|
||||
<div class="accordion capabilities">
|
||||
{% for capability in capabilities %}
|
||||
{% include "character/capability.html" %}
|
||||
{% include "character/snippets/character_details/capability.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
|
@ -20,7 +20,7 @@
|
|||
</form>
|
||||
<div class="row mt-2 gy-3">
|
||||
{% for path, capabilities in character.get_capabilities_by_path.items %}
|
||||
{% include "character/path.html" %}
|
||||
{% include "character/snippets/character_details/path.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
|
@ -21,7 +21,7 @@
|
|||
{{ 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|floatformat }})
|
||||
</p>
|
||||
{% include "character/states.html" %}
|
||||
{% include "character/snippets/character_details/states.html" %}
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-6 col-lg-6 col-xl">
|
||||
<table id="fight-table" class="table table-hover table-sm">
|
||||
|
@ -443,13 +443,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-4 mb-3">
|
||||
{% include "character/damage_reduction_display.html" %}
|
||||
{% include "character/snippets/character_details/damage_reduction_display.html" %}
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-4 mb-3">
|
||||
{% include "character/equipment_display.html" %}
|
||||
{% include "character/snippets/character_details/equipment_display.html" %}
|
||||
</div>
|
||||
</div>
|
||||
<h2>Voies & Capacités</h2>
|
||||
{% include "character/paths_and_capabilities.html" %}
|
||||
{% include "character/notes_display.html" %}
|
||||
{% include "character/snippets/character_details/paths_and_capabilities.html" %}
|
||||
{% include "character/snippets/character_details/notes_display.html" %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -54,7 +54,11 @@ def add_path(request, pk: int):
|
|||
context["add_path_form"] = AddPathForm(character)
|
||||
else:
|
||||
context["add_path_form"] = form
|
||||
return render(request, "character/paths_and_capabilities.html", context)
|
||||
return render(
|
||||
request,
|
||||
"character/snippets/character_details/paths_and_capabilities.html",
|
||||
context,
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -212,14 +216,26 @@ def character_equipment_change(request, pk: int):
|
|||
)
|
||||
context = {"character": character}
|
||||
if request.method == "GET":
|
||||
return render(request, f"character/{field}_update.html", context)
|
||||
return render(
|
||||
request,
|
||||
f"character/snippets/character_details/{field}_update.html",
|
||||
context,
|
||||
)
|
||||
form = EquipmentForm(request.POST, instance=character)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return render(request, f"character/{field}_display.html", context)
|
||||
return render(
|
||||
request,
|
||||
f"character/snippets/character_details/{field}_display.html",
|
||||
context,
|
||||
)
|
||||
else:
|
||||
context["errors"] = form.errors
|
||||
return render(request, f"character/{field}_update.html", context)
|
||||
return render(
|
||||
request,
|
||||
f"character/snippets/character_details/{field}_update.html",
|
||||
context,
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -233,10 +249,16 @@ def update_text_field(request, pk, field):
|
|||
)
|
||||
context = {"character": character}
|
||||
if request.method == "GET":
|
||||
return render(request, f"character/{field}_update.html", context)
|
||||
return render(
|
||||
request,
|
||||
f"character/snippets/character_details/{field}_update.html",
|
||||
context,
|
||||
)
|
||||
setattr(character, field, request.POST.get(field))
|
||||
character.save(update_fields=[field])
|
||||
return render(request, f"character/{field}_display.html", context)
|
||||
return render(
|
||||
request, f"character/snippets/character_details/{field}_display.html", context
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -251,7 +273,11 @@ def add_next_in_path(request, character_pk: int, path_pk: int):
|
|||
"character": character,
|
||||
"add_path_form": AddPathForm(character),
|
||||
}
|
||||
return render(request, "character/paths_and_capabilities.html", context)
|
||||
return render(
|
||||
request,
|
||||
"character/snippets/character_details/paths_and_capabilities.html",
|
||||
context,
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -268,7 +294,11 @@ def remove_last_in_path(request, character_pk: int, path_pk: int):
|
|||
"character": character,
|
||||
"add_path_form": AddPathForm(character),
|
||||
}
|
||||
return render(request, "character/paths_and_capabilities.html", context)
|
||||
return render(
|
||||
request,
|
||||
"character/snippets/character_details/paths_and_capabilities.html",
|
||||
context,
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -279,7 +309,9 @@ def remove_state(request, pk: int, state_pk: int):
|
|||
state = get_object_or_404(HarmfulState, pk=state_pk)
|
||||
character.states.remove(state)
|
||||
context = {"character": character, "all_states": HarmfulState.objects.all()}
|
||||
response = render(request, "character/states.html", context)
|
||||
response = render(
|
||||
request, "character/snippets/character_details/states.html", context
|
||||
)
|
||||
return trigger_client_event(response, "refresh_tooltips", {})
|
||||
|
||||
|
||||
|
@ -291,5 +323,7 @@ def add_state(request, pk: int, state_pk: int):
|
|||
state = get_object_or_404(HarmfulState, pk=state_pk)
|
||||
character.states.add(state)
|
||||
context = {"character": character, "all_states": HarmfulState.objects.all()}
|
||||
response = render(request, "character/states.html", context)
|
||||
response = render(
|
||||
request, "character/snippets/character_details/states.html", context
|
||||
)
|
||||
return trigger_client_event(response, "refresh_tooltips", {})
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="{% url "character:list" %}">Mes perso</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="{% url "character:list" %}">Mes groupes</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav">
|
||||
{% if user.is_authenticated %}
|
||||
|
|
Loading…
Reference in a new issue