def post(self): form = radius_form.radius_add_form([]) if not form.validates(source=self.get_params()): return self.render("base_form.html", form=form) if self.db.query(models.TTRadius.id).filter_by(ip_addr=form.d.ip_addr).count() > 0: return self.render("base_form.html", form=form, msg=u"ip地址已经存在") radius = models.TTRadius() radius.ip_addr = form.d.ip_addr radius.name = form.d.name radius.secret = form.d.secret radius.acct_port = form.d.acct_port radius.auth_port = form.d.auth_port radius.serv_type = form.d.serv_type self.db.add(radius) self.db.commit() self.redirect("/radius", permanent=False)
def get(self): self.render("base_form.html", form=radius_form.radius_add_form())