adding character sheets

This commit is contained in:
evilchili
2024-01-28 14:31:50 -08:00
parent 17da4a73ee
commit 64451ddf8b
10 changed files with 84 additions and 10 deletions
+3
View File
@@ -0,0 +1,3 @@
from .root import RootController
__ALL__ = [RootController]
@@ -0,0 +1,29 @@
from tg import expose
from tg import TGController
from ttfrog.db import db
from ttfrog.db.schema import Character
from ttfrog.webserver.widgets import CharacterSheet
class CharacterSheetController(TGController):
@expose()
def _lookup(self, *parts):
return FormController(parts[0]), parts[1:]
class FormController:
def __init__(self, slug: str):
self.character = dict()
if slug:
self.load(slug)
def load(self, slug: str) -> None:
self.character = db.query(Character).filter(Character.columns.slug == slug)[0]._mapping
@expose('character_sheet.html')
def _default(self, *args, **kwargs):
if kwargs:
db.update(Character, **kwargs)
self.load(self.character['slug'])
return dict(page='sheet', form=CharacterSheet, character=self.character)
+18
View File
@@ -0,0 +1,18 @@
from tg import expose
from tg import TGController
from tg import tmpl_context
from ttfrog.db import db
from ttfrog.webserver.controllers.character_sheet import CharacterSheetController
class RootController(TGController):
sheet = CharacterSheetController()
def _before(self, *args, **kwargs):
tmpl_context.project_name = 'TableTop Frog'
@expose('index.html')
def index(self):
ancestries = [row._mapping for row in db.query(db.ancestry).all()]
return dict(page='index', content=str(ancestries))