2024-01-30 01:25:02 -08:00
|
|
|
from pyramid.response import Response
|
|
|
|
|
from pyramid.view import view_config
|
2024-03-26 00:53:21 -07:00
|
|
|
|
|
|
|
|
from ttfrog.attribute_map import AttributeMap
|
2024-01-30 01:25:02 -08:00
|
|
|
from ttfrog.db.manager import db
|
|
|
|
|
from ttfrog.db.schema import Ancestry
|
2024-03-26 00:53:21 -07:00
|
|
|
|
2024-02-08 23:04:28 -08:00
|
|
|
|
|
|
|
|
def response_from(controller):
|
2024-03-26 00:53:21 -07:00
|
|
|
return controller.response() or AttributeMap.from_dict({"c": controller.template_context()})
|
2024-01-30 01:25:02 -08:00
|
|
|
|
|
|
|
|
|
2024-03-26 00:53:21 -07:00
|
|
|
@view_config(route_name="index")
|
2024-01-30 01:25:02 -08:00
|
|
|
def index(request):
|
|
|
|
|
ancestries = [a.name for a in db.session.query(Ancestry).all()]
|
2024-03-26 00:53:21 -07:00
|
|
|
return Response(",".join(ancestries))
|
2024-01-31 22:39:54 -08:00
|
|
|
|
|
|
|
|
|
2024-03-26 00:53:21 -07:00
|
|
|
@view_config(route_name="sheet", renderer="character_sheet.html")
|
2024-01-31 22:39:54 -08:00
|
|
|
def sheet(request):
|
2024-02-08 23:04:28 -08:00
|
|
|
return response_from(request.context)
|
2024-02-16 01:19:25 -08:00
|
|
|
|
2024-03-26 00:53:21 -07:00
|
|
|
|
|
|
|
|
@view_config(route_name="data", renderer="json")
|
2024-02-16 01:19:25 -08:00
|
|
|
def data(request):
|
|
|
|
|
return response_from(request.context)
|