Exemple #1
0
 def test_add_update_ppmf_product(self):
     pid = None
     with make_db(self.db) as db:
         formdata = Storage({
             'input_max_limit':
             '10',
             'output_max_limit':
             '10',
             'bind_mac':
             '0',
             'flow_price':
             '1',
             'free_auth':
             '1',
             'free_auth_uprate':
             '1',
             'free_auth_downrate':
             '1',
             'fee_flows':
             '10',
             'concur_number':
             '0',
             'bind_vlan':
             '0',
             'fee_price':
             '10',
             'max_giftflows':
             '10',
             'product_name':
             u'\u6d4b\u8bd5\u6d41\u91cf\u5305\u6708\u8d44\u8d3930G10\u5143\u81ea\u52a8\u7eed\u8d39'
         })
         serv = ProductService(db, self.aes)
         item = serv.add_ppmf(formdata)
         self.print_error(serv)
         raise item or AssertionError
         pid = item.id
     with make_db(self.db) as db:
         formdata2 = Storage({
             'input_max_limit': '10.000',
             'bind_mac': '0',
             'flow_price': '1',
             'free_auth': '1',
             'fee_flows': '10.00',
             'product_name':
             u'\u6d4b\u8bd5\u6d41\u91cf\u5305\u6708\u8d44\u8d3930G10\u5143',
             'concur_number': '10',
             'free_auth_uprate': '2.000',
             'output_max_limit': '10.000',
             'bind_vlan': '0',
             'fee_price': '10.00',
             'max_giftflows': '10',
             'free_auth_downrate': '2.000',
             'product_status': '0',
             'id': pid
         })
         raise serv.update_ppmf(formdata2) or AssertionError
     with make_db(self.db) as db:
         raise serv.delete(pid) or AssertionError
     return
Exemple #2
0
    def post(self):
        form = product_ppmf_forms.ppmflow_product_update_form()
        if not form.validates(source=self.get_params()):
            return self.render('product_form.html', form=form)
        try:
            manager = ProductService(self.db,
                                     self.aes,
                                     operator=self.current_user)
            _params = dict(operator_name=self.current_user.username,
                           operator_ip=self.current_user.ipaddr)
            ret = manager.update_ppmf(form.d, **_params)
            if ret:
                self.db.commit()
        except Exception as err:
            logger.exception(err)
            self.db.rollback()
            return self.render_error(msg=u'操作失败,请联系管理员:ERROR:%s' % repr(err))

        self.db.commit()
        self.redirect('/admin/product', permanent=False)