Add basic character create view (redirect only)

This commit is contained in:
Gabriel Augendre 2022-10-31 15:22:36 +01:00
parent 36047f0720
commit 881e069ed0
4 changed files with 11 additions and 2 deletions

View file

@ -9,7 +9,7 @@
{{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg<br>
PV {{ character.health_remaining }}/{{ character.health_max }}, PM {{ character.mana_remaining }}/{{ character.mana_max }}
</p>
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-sm btn-primary">
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-sm btn-success">
<i class="fa-solid fa-user"></i> Play
</a>
</div>

View file

@ -5,6 +5,9 @@
{% block content %}
<h1>Characters</h1>
<a href="{% url "character:create" %}" class="btn btn-primary mb-3">
<i class="fa-solid fa-user-plus"></i> New character
</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" %}

View file

@ -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("<int:pk>/", views.character_view, name="view"),
path("<int:pk>/health_change", views.character_health_change, name="health_change"),
path("<int:pk>/mana_change", views.character_mana_change, name="mana_change"),

View file

@ -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(