def GET(self): form = relation_form() data = web.input() mid = data.mid models = get_active_models() req = web.ctx.req req.update({ 'models': models, 'form': form, 'mid': mid, }) return render.relation_edit(**req)
def POST(self, id): form = relation_form() data = web.input() mid = data.mid if not form.validates(): models = get_active_models() req = web.ctx.req req.update({ 'form': form, 'models': models, 'mid': mid, }) return render.relation_edit(**req) save_relation(int(id), form.d) raise web.seeother('/model/%s/edit' % mid)
def GET(self, id): form = relation_form() relation = get_relation(id) form.fill(relation) data = web.input() models = get_active_models() mid = data.mid model = get_model(mid) req = web.ctx.req req.update({ 'models': models, 'form': form, 'mid': mid, 'mtitle': model.title, }) return render.relation_edit(**req)
def POST(self): form = relation_form() data = web.input() mid = data.mid if not form.validates(): model = get_model(mid) models = get_active_models() req = web.ctx.req req.update({ 'models': models, 'form': form, 'mid': mid, 'mtitle': model.title, }) return render.relation_edit(**req) form_data = form.d form_data.model_id = mid save_relation(-1, form_data) raise web.seeother('/model/%s/edit' % mid)