From 881e069ed0c1213a6470225409814cf32249f43e Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 31 Oct 2022 15:22:36 +0100 Subject: [PATCH] Add basic character create view (redirect only) --- src/character/templates/character/character_card.html | 2 +- src/character/templates/character/list.html | 3 +++ src/character/urls.py | 1 + src/character/views.py | 7 ++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/character/templates/character/character_card.html b/src/character/templates/character/character_card.html index 08a9453..85bc82c 100644 --- a/src/character/templates/character/character_card.html +++ b/src/character/templates/character/character_card.html @@ -9,7 +9,7 @@ {{ 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 }}

- + Play diff --git a/src/character/templates/character/list.html b/src/character/templates/character/list.html index f258c2a..61ec7c0 100644 --- a/src/character/templates/character/list.html +++ b/src/character/templates/character/list.html @@ -5,6 +5,9 @@ {% block content %}

Characters

+ + New character +
{% for character in characters %} {% include "character/character_card.html" %} diff --git a/src/character/urls.py b/src/character/urls.py index b67637a..3955347 100644 --- a/src/character/urls.py +++ b/src/character/urls.py @@ -5,6 +5,7 @@ from character import views app_name = "character" urlpatterns = [ path("", views.characters_list, name="list"), + path("create/", views.character_create, name="create"), 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"), diff --git a/src/character/views.py b/src/character/views.py index c85795b..2e1a22e 100644 --- a/src/character/views.py +++ b/src/character/views.py @@ -1,6 +1,6 @@ from django.contrib.auth.decorators import login_required from django.http import HttpResponse -from django.shortcuts import get_object_or_404, render +from django.shortcuts import get_object_or_404, redirect, render from django_htmx.http import trigger_client_event from character.forms import EquipmentForm @@ -17,6 +17,11 @@ def characters_list(request): return render(request, "character/list.html", context) +@login_required +def character_create(request): + return redirect("admin:character_character_add") + + @login_required def character_view(request, pk: int): character = get_object_or_404(