mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-12-22 22:01:48 +01:00
Allow updating damage reduction
This commit is contained in:
parent
a03cda1771
commit
3a949fe2d7
5 changed files with 50 additions and 12 deletions
|
@ -0,0 +1,17 @@
|
|||
<div class="card" id="damage-reduction">
|
||||
<h5 class="card-header">
|
||||
Réduction de dégâts
|
||||
<a hx-get="{% url "character:damage_reduction_change" pk=character.pk %}"
|
||||
hx-target="#damage-reduction"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||
</a>
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
<p class="card-text">
|
||||
{{ character.damage_reduction|linebreaksbr|default:"Rien ici..." }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,18 @@
|
|||
<form id="damage-reduction">
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Réduction de dégâts
|
||||
<a hx-post="{% url "character:damage_reduction_change" pk=character.pk %}"
|
||||
hx-target="#damage-reduction"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-save"></i> Save
|
||||
</a>
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
{% csrf_token %}
|
||||
<textarea class="form-control" name="damage_reduction" rows="2">{{ character.damage_reduction }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
|
@ -317,7 +317,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="col-md-6 col-lg-4 mb-3">
|
||||
<div class="card">
|
||||
<h5 class="card-header">{{ character.racial_capability.name }}</h5>
|
||||
<div class="card-body">
|
||||
|
@ -325,17 +325,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="card">
|
||||
<h5 class="card-header">Réduction de dégâts</h5>
|
||||
<div class="card-body">
|
||||
<p class="card-text">{{ character.damage_reduction|linebreaksbr|default:"Rien ici..." }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-lg-4 mb-3">
|
||||
{% include "character/damage_reduction_display.html" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="col-md-12 col-lg-4 mb-3">
|
||||
<div class="card">
|
||||
<h5 class="card-header">Équipement</h5>
|
||||
<div class="card-body" id="equipment">
|
||||
|
@ -350,7 +343,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="mt-3">Voies & Capacités</h4>
|
||||
<h4>Voies & Capacités</h4>
|
||||
<div class="row gy-3">
|
||||
{% for path, capabilities in character.get_capabilities_by_path.items %}
|
||||
<div class="col-xl-3 col-md-6">
|
||||
|
|
|
@ -29,4 +29,9 @@ urlpatterns = [
|
|||
views.character_equipment_change,
|
||||
name="equipment_change",
|
||||
),
|
||||
path(
|
||||
"<int:pk>/damage_reduction_change",
|
||||
views.character_damage_reduction_change,
|
||||
name="damage_reduction_change",
|
||||
),
|
||||
]
|
||||
|
|
|
@ -115,6 +115,11 @@ def character_equipment_change(request: WSGIRequest, pk: int) -> HttpResponse:
|
|||
return update_text_field(request, pk, "equipment")
|
||||
|
||||
|
||||
@login_required
|
||||
def character_damage_reduction_change(request: WSGIRequest, pk: int) -> HttpResponse:
|
||||
return update_text_field(request, pk, "damage_reduction")
|
||||
|
||||
|
||||
def update_text_field(request, pk, field):
|
||||
character = get_object_or_404(Character.objects.only(field), pk=pk)
|
||||
context = {"character": character}
|
||||
|
|
Loading…
Reference in a new issue