diff --git a/src/character/templates/character/notes_display.html b/src/character/templates/character/notes_display.html new file mode 100644 index 0000000..2c483af --- /dev/null +++ b/src/character/templates/character/notes_display.html @@ -0,0 +1,10 @@ +

+ + Edit + +

+{{ character.notes|linebreaks }} diff --git a/src/character/templates/character/notes_update.html b/src/character/templates/character/notes_update.html new file mode 100644 index 0000000..401e004 --- /dev/null +++ b/src/character/templates/character/notes_update.html @@ -0,0 +1,13 @@ +
+

+ + Save + +

+ {% csrf_token %} + +
diff --git a/src/character/templates/character/view.html b/src/character/templates/character/view.html index 724c28e..af3da94 100644 --- a/src/character/templates/character/view.html +++ b/src/character/templates/character/view.html @@ -249,7 +249,7 @@
{{ path.display_name }}
{% if path.notes %} -
{{ path.notes }}
+
{{ path.notes }}
{% endif %}

Notes

-
- {{ character.notes|linebreaks }} +
+ {% include "character/notes_display.html" %}
{% endblock %} diff --git a/src/character/urls.py b/src/character/urls.py index 77b4722..277bbca 100644 --- a/src/character/urls.py +++ b/src/character/urls.py @@ -7,4 +7,5 @@ urlpatterns = [ path("/", views.character_view, name="view"), path("/health_change", views.character_health_change, name="health_change"), path("/mana_change", views.character_mana_change, name="mana_change"), + path("/notes_change", views.character_notes_change, name="notes_change"), ] diff --git a/src/character/views.py b/src/character/views.py index e3cbf6d..d6fdeb7 100644 --- a/src/character/views.py +++ b/src/character/views.py @@ -40,6 +40,18 @@ def character_mana_change(request: WSGIRequest, pk: int) -> HttpResponse: return HttpResponse(character.mana_remaining) +@login_required +def character_notes_change(request: WSGIRequest, pk: int) -> HttpResponse: + character = get_object_or_404(Character.objects.only("notes"), pk=pk) + context = {"character": character} + if request.method == "GET": + return render(request, "character/notes_update.html", context) + + character.notes = request.POST.get("notes") + character.save() + return render(request, "character/notes_display.html", context) + + def get_updated_value(max_value, request): value = request.GET.get("value") if value == "ko":