tabletop-frog/ttfrog/webserver/controllers/character_sheet.py

38 lines
1.1 KiB
Python
Raw Normal View History

2024-02-08 01:14:35 -08:00
from ttfrog.webserver.controllers.base import BaseController
from ttfrog.webserver.forms import DeferredSelectField, DeferredSelectMultipleField
from ttfrog.db.schema import Character, Ancestry, CharacterClass, STATS
from wtforms_alchemy import ModelForm
2024-02-08 01:14:35 -08:00
from wtforms.fields import SubmitField, SelectMultipleField
from wtforms.widgets import Select
2024-02-04 11:40:30 -08:00
class CharacterForm(ModelForm):
class Meta:
model = Character
exclude = ['slug']
2024-02-04 15:22:54 -08:00
save = SubmitField()
delete = SubmitField()
2024-02-08 01:14:35 -08:00
ancestry = DeferredSelectField('Ancestry', model=Ancestry, validate_choice=True, widget=Select())
character_class = DeferredSelectMultipleField(
'CharacterClass',
model=CharacterClass,
validate_choice=True,
# option_widget=Select(multiple=True)
)
saving_throws = SelectMultipleField('Saving Throws', validate_choice=True, choices=STATS)
2024-01-28 14:31:50 -08:00
2024-01-31 22:39:54 -08:00
class CharacterSheet(BaseController):
2024-02-04 11:40:30 -08:00
model = CharacterForm.Meta.model
model_form = CharacterForm
2024-02-08 01:14:35 -08:00
@property
def resources(self):
return super().resources + [
{'type': 'script', 'uri': 'js/character_sheet.js'},
]