def GET(self): form = user_form() groups = get_groups() req = web.ctx.req req.update({ 'form': form, 'groups': groups, 'user_groups': [], }) return render.user_edit(**req)
def GET(self, id): form = user_form() user = get_user_byid(id) form.fill(user) groups = get_groups() user_groups = user.groups req = web.ctx.req req.update({ 'uid': user.id, 'form': form, 'groups': groups, 'user_groups': user_groups, }) return render.user_edit(**req)
def POST(self): form = user_form() if not form.validates(): groups = get_groups() req = web.ctx.req req.update({ 'form': form, 'groups': groups, 'user_groups': [], }) return render.user_edit(**req) data = web.input(groups=[]) form_data = form.d form_data.gids = data.groups save_user(-1, form_data) raise web.seeother('/user/index')