tabletop-frog/ttfrog/webserver/controllers/character_sheet.py
2024-01-31 22:39:54 -08:00

21 lines
623 B
Python

import logging
from ttfrog.webserver.controllers import BaseController
from ttfrog.db.manager import db
from ttfrog.db.schema import Character
class CharacterSheet(BaseController):
model = Character
def configure(self):
self.attrs['all_characters'] = db.query(Character).all()
slug = self.request.matchdict.get('slug', None)
if slug:
try:
self.record = db.query(Character).filter(Character.slug == slug)[0]
except IndexError:
logging.warning(f"Could not load record with slug {slug}")
else:
self.load_from_id()