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