def post(self, *args, **kwargs): form = template_forms.tpl_attr_update_form() if not form.validates(source=self.get_params()): return self.render("base_form,html", form=form) tpl_attr = self.db.query(models.TraTemplateAttr).get(form.d.id) tpl_attr.attr_name = form.d.attr_name tpl_attr.attr_value = form.d.attr_value tpl_attr.attr_desc = form.d.attr_desc self.db.commit() tpl_id = self.db.query(models.TraTemplate.id).filter_by(tpl_name=form.d.tpl_name).scalar() self.redirect("/template/detail?tpl_id=%s" % tpl_id)
def get(self): attr_id = self.get_argument("attr_id") attr = self.db.query(models.TraTemplateAttr).get(attr_id) form = template_forms.tpl_attr_update_form() form.fill(attr) self.render("base_form.html", form=form)