From 3a949fe2d7384cd28ef52103fcedb5a3f6a49053 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 30 Oct 2022 23:44:02 +0100 Subject: [PATCH] Allow updating damage reduction --- .../character/damage_reduction_display.html | 17 +++++++++++++++++ .../character/damage_reduction_update.html | 18 ++++++++++++++++++ src/character/templates/character/view.html | 17 +++++------------ src/character/urls.py | 5 +++++ src/character/views.py | 5 +++++ 5 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 src/character/templates/character/damage_reduction_display.html create mode 100644 src/character/templates/character/damage_reduction_update.html diff --git a/src/character/templates/character/damage_reduction_display.html b/src/character/templates/character/damage_reduction_display.html new file mode 100644 index 0000000..cf7f93e --- /dev/null +++ b/src/character/templates/character/damage_reduction_display.html @@ -0,0 +1,17 @@ +
+
+ Réduction de dégâts + + Edit + +
+
+

+ {{ character.damage_reduction|linebreaksbr|default:"Rien ici..." }} +

+
+
diff --git a/src/character/templates/character/damage_reduction_update.html b/src/character/templates/character/damage_reduction_update.html new file mode 100644 index 0000000..c276fdd --- /dev/null +++ b/src/character/templates/character/damage_reduction_update.html @@ -0,0 +1,18 @@ +
+
+
+ Réduction de dégâts + + Save + +
+
+ {% csrf_token %} + +
+
+
diff --git a/src/character/templates/character/view.html b/src/character/templates/character/view.html index 712983d..2adb167 100644 --- a/src/character/templates/character/view.html +++ b/src/character/templates/character/view.html @@ -317,7 +317,7 @@
-
+
{{ character.racial_capability.name }}
@@ -325,17 +325,10 @@
-
-
-
Réduction de dégâts
-
-

{{ character.damage_reduction|linebreaksbr|default:"Rien ici..." }}

-
-
+
+ {% include "character/damage_reduction_display.html" %}
-
-
-
+
Équipement
@@ -350,7 +343,7 @@
-

Voies & Capacités

+

Voies & Capacités

{% for path, capabilities in character.get_capabilities_by_path.items %}
diff --git a/src/character/urls.py b/src/character/urls.py index d36c2b8..ea150bd 100644 --- a/src/character/urls.py +++ b/src/character/urls.py @@ -29,4 +29,9 @@ urlpatterns = [ views.character_equipment_change, name="equipment_change", ), + path( + "/damage_reduction_change", + views.character_damage_reduction_change, + name="damage_reduction_change", + ), ] diff --git a/src/character/views.py b/src/character/views.py index 69c330d..a46ff12 100644 --- a/src/character/views.py +++ b/src/character/views.py @@ -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}