def get(self): tpl_name = self.get_argument("tpl_name") if self.db.query(models.TraTemplate).filter_by(tpl_name=tpl_name).count() == 0: return self.render_error(msg=u"模版不存在") form = template_forms.tpl_attr_add_form() form.tpl_name.set_value(tpl_name) self.render("base_form.html",form=form)
def post(self): form = template_forms.tpl_attr_add_form() if not form.validates(source=self.get_params()): return self.render("base_form,html", form=form) tpl_attr = models.TraTemplateAttr() tpl_attr.tpl_name = form.d.tpl_name 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.add(tpl_attr) 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)