diff --git a/src/character/forms.py b/src/character/forms.py index e341ee8..227bd96 100644 --- a/src/character/forms.py +++ b/src/character/forms.py @@ -2,7 +2,7 @@ from django import forms from django.core.exceptions import ValidationError from django.db.models import Q -from character.models import Character, Path +from character.models import Character, Path, RacialCapability class EquipmentForm(forms.ModelForm): @@ -45,3 +45,45 @@ class AddPathForm(forms.Form): if len(list(filter(None, values))) != 1: raise ValidationError("Vous devez sélectionner une seule valeur.") return cleaned_data + + +class CharacterCreateForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields[ + "racial_capability" + ].queryset = RacialCapability.objects.select_related("race") + + class Meta: + model = Character + fields = [ + "name", + "race", + "profile", + "private", + "level", + "gender", + "age", + "height", + "weight", + "value_strength", + "value_dexterity", + "value_constitution", + "value_intelligence", + "value_wisdom", + "value_charisma", + "health_max", + "racial_capability", + "weapons", + "armor", + "shield", + "defense_misc", + "initiative_misc", + "equipment", + "money_pp", + "money_po", + "money_pa", + "money_pc", + "damage_reduction", + "notes", + ] diff --git a/src/character/templates/character/character_details.html b/src/character/templates/character/character_details.html index 5b2b099..32cda83 100644 --- a/src/character/templates/character/character_details.html +++ b/src/character/templates/character/character_details.html @@ -17,7 +17,7 @@ {% endif %} {% if character|managed_by:user %}
{% endif %}diff --git a/src/character/templates/character/character_form.html b/src/character/templates/character/character_form.html new file mode 100644 index 0000000..1ed3e65 --- /dev/null +++ b/src/character/templates/character/character_form.html @@ -0,0 +1,12 @@ +{% extends "common/base.html" %} +{% load django_bootstrap5 %} + +{% block title %}Création de personnage{% endblock %} + +{% block content %} +
+{% endblock %} diff --git a/src/character/urls.py b/src/character/urls.py index e22cc7e..8bb8625 100644 --- a/src/character/urls.py +++ b/src/character/urls.py @@ -7,6 +7,7 @@ urlpatterns = [ path("", views.characters_list, name="list"), path("create/", views.character_create, name="create"), path("