2022-10-31 00:06:20 +01:00
|
|
|
from django import forms
|
|
|
|
|
2022-10-31 23:23:28 +01:00
|
|
|
from character.models import Character, Path
|
2022-10-31 00:06:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
class EquipmentForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Character
|
|
|
|
fields = ["equipment", "money_pp", "money_po", "money_pa", "money_pc"]
|
2022-10-31 23:23:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
class AddPathForm(forms.Form):
|
|
|
|
path = forms.ModelChoiceField(Path.objects.none())
|
|
|
|
|
|
|
|
def __init__(self, character: Character, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
paths = {cap.path_id for cap in character.capabilities.all()}
|
|
|
|
self.fields["path"].queryset = Path.objects.exclude(pk__in=paths).order_by(
|
|
|
|
"profile__name", "race__name"
|
|
|
|
)
|
|
|
|
self.fields["path"].widget.attrs["class"] = "form-select"
|