def GET(self): form = model_form() templates = get_templates() req = web.ctx.req req.update({ 'form': form, 'templates': templates, 'fields': [], 'relations': [], }) return render.model_edit(**req)
def POST(self): form = model_form() if not form.validates(): templates = get_templates() req = web.ctx.req req.update({ 'form': form, 'templates': templates, 'fields': [], 'relations': [], }) return render.model_edit(**req) save_model(-1, form.d) raise web.seeother('/model/index')
def GET(self, id): templates = get_templates() form = model_form() model = get_model(id) fields = get_fields(id) relations = get_relations(id) form.fill(model) req = web.ctx.req req.update({ 'mid': id, 'form': form, 'templates': templates, 'fields': fields, 'relations': relations, }) return render.model_edit(**req)
def POST(self, id): form = model_form() if not form.validates(): templates = get_templates() fields = get_fields(id) relations = get_relations(id) req = web.ctx.req req.update({ 'mid': id, 'form': form, 'templates': templates, 'fields': fields, 'relations': relations, }) return render.model_edit(**req) save_model(int(id), form.d) raise web.seeother('/model/index')