import pytz from storm.locals import * from warp.runtime import expose class Person(Storm): __storm_table__ = "person" id = Int(primary=True) name = Unicode() birthdate = DateTime(tzinfo=pytz.UTC) note = Unicode() rating = Int() alive = Bool() expose(Person)
class CrudPerson(CrudModel): model = Person listColumns = ("id", "name", "birthdate", "rating") crudColumns = ("name", "birthdate", "note", "rating", "alive") listAttrs = { 'id': {'width': 50, 'align': 'center'}, 'name': {'width': 200}, 'birthdate': {'width': 150, 'align': 'center'}, 'rating': {'width': 50, 'align': 'center'}, } def render_list_name(self, request): return link( self.obj.name, getNode("people"), "view", [self.obj.id]) def render_proxy_note(self, request): return colproxy.AreaProxy(self.obj, "note") def name(self, request): return self.obj.name expose(Person, CrudPerson) renderer = render.CrudRenderer(Person)
from warp.runtime import expose from models import Widget def linkAsParent(request): return link("Widgets", getNode("widgets"), "index") class CrudWidget(CrudModel): listColumns = ("id", "name") crudColumns = ("name", "created", "description", "image", "is_available") listAttrs = {"id": {"width": 50, "align": "center"}, "name": {"width": 200}} def render_list_name(self, request): return link(self.name(request), getNode("widgets"), "view", [self.obj.id]) def name(self, request): return self.obj.name def parentCrumb(self, request): return getNode("widgets") expose(Widget, CrudWidget) renderer = render.CrudRenderer(Widget)