Exemple #1
0
    def post(self):
        form = bas_forms.bas_add_form()
        if not form.validates(source=self.get_params()):
            return self.render("base_form.html", form=form)

        if not any([form.d.ip_addr, form.d.dns_name]):
            return self.render("base_form.html",
                               form=form,
                               msg=u"ip地址或域名至少填写一项")

        if self.db.query(
                models.TrBas.id).filter_by(ip_addr=form.d.ip_addr).count() > 0:
            return self.render("base_form.html", form=form, msg=u"接入设备地址已经存在")

        bas = models.TrBas()
        bas.ip_addr = form.d.ip_addr
        bas.dns_name = form.d.dns_name
        bas.bas_name = form.d.bas_name
        bas.time_type = form.d.time_type
        bas.vendor_id = form.d.vendor_id
        bas.bas_secret = form.d.bas_secret
        bas.coa_port = form.d.coa_port
        self.db.add(bas)

        self.add_oplog(u'新增接入设备信息:%s' % bas.ip_addr)

        self.db.commit()
        self.redirect("/admin/bas", permanent=False)
Exemple #2
0
    def post(self):
        form = bas_forms.bas_add_form()
        if not form.validates(source=self.get_params()):
            return self.render("base_form.html", form=form)

        if not any([form.d.ip_addr,form.d.dns_name]):
            return self.render("base_form.html", form=form, msg=u"ip地址或域名至少填写一项")

        if self.db.query(models.TrBas.id).filter_by(ip_addr=form.d.ip_addr).count() > 0:
            return self.render("base_form.html", form=form, msg=u"接入设备地址已经存在")

        bas = models.TrBas()
        bas.ip_addr = form.d.ip_addr
        bas.dns_name = form.d.dns_name
        bas.bas_name = form.d.bas_name
        bas.time_type = form.d.time_type
        bas.vendor_id = form.d.vendor_id
        bas.bas_secret = form.d.bas_secret
        bas.coa_port = form.d.coa_port
        self.db.add(bas)

        self.add_oplog(u'新增接入设备信息:%s' % bas.ip_addr)

        self.db.commit()
        self.redirect("/admin/bas",permanent=False)
Exemple #3
0
 def test_add_bas(self):
     form = bas_forms.bas_add_form()
     assert form.validates(source=dict(
         ip_addr="192.168.31.153",
         bas_name="stdbas",
         bas_secret="secret",
         vendor_id='0',
         coa_port='3799',
         time_type='0'
     ))
     req = self.admin_login()
     r = req.post(self.sub_path("/admin/bas/add"),form.d)
     assert r.status_code == 200
Exemple #4
0
 def get(self):
     form = bas_forms.bas_add_form()
     self.render("base_form.html", form=form)
Exemple #5
0
 def get(self):
     form = bas_forms.bas_add_form()
     self.render("base_form.html", form=form)