Exemplo n.º 1
0
def pool_update_form(nodes=[]):
    return btforms.Form(btforms.Hidden('id', description=u'编号'),
                        btforms.Textbox('pool_name',
                                        rules.is_alphanum2(1, 64),
                                        description=u'地址池名称',
                                        required='required',
                                        **input_style),
                        btforms.Textbox('start_ip',
                                        rules.is_ip,
                                        description=u'开始地址',
                                        required='required',
                                        **input_style),
                        btforms.Textbox('end_ip',
                                        rules.is_ip,
                                        description=u'结束地址',
                                        required='required',
                                        **input_style),
                        btforms.Textbox('next_pool',
                                        rules.is_alphanum2(1, 64),
                                        description=u'下一个地址池',
                                        **input_style),
                        btforms.Button('submit',
                                       type='submit',
                                       html=u'<b>更新</b>',
                                       **button_style),
                        title=u'修改地址池',
                        htopic='addrpool',
                        action='/admin/addrpool/update')
Exemplo n.º 2
0
def pool_add_form():
    return btforms.Form(btforms.Textbox('pool_name',
                                        rules.is_alphanum2(1, 64),
                                        description=u'地址池名称',
                                        required='required',
                                        **input_style),
                        btforms.Textbox('start_ip',
                                        rules.is_ip,
                                        description=u'开始地址',
                                        required='required',
                                        **input_style),
                        btforms.Textbox('end_ip',
                                        rules.is_ip,
                                        description=u'结束地址',
                                        required='required',
                                        **input_style),
                        btforms.Textbox('next_pool',
                                        rules.is_alphanum2(1, 64),
                                        description=u'下一个地址池',
                                        **input_style),
                        btforms.Button('submit',
                                       type='submit',
                                       html=u'<b>提交</b>',
                                       **button_style),
                        title=u'创建地址池',
                        htopic='addrpool',
                        action='/admin/addrpool/add')
Exemplo n.º 3
0
 def post(self):
     try:
         openid = self.session.get('mps_openid',
                                   os.environ.get('DEV_OPEN_ID'))
         if not openid:
             return self.render('error.html', msg=u'会话过期')
         customer = self.db.query(
             models.TrCustomer).filter_by(wechat_oid=openid).first()
         if not customer:
             return self.render('error.html', msg=u'未绑定微信')
         oldpass = self.get_argument('oldpass', '')
         newpass = self.get_argument('newpass', '')
         newpass1 = self.get_argument('newpass1', '')
         if not oldpass:
             return self.render('error.html', msg=u'旧密码不能为空')
         if not rules.is_alphanum2(6, 16).valid(newpass):
             return self.render('error.html',
                                msg=u'新密码校验错误,必须是6-16为的英文字符数字')
         if newpass != newpass1:
             return self.render('error.html', msg=u'确认密码不正确')
         account = self.db.query(models.TrAccount).filter_by(
             customer_id=customer.customer_id).first()
         if not account:
             return self.render('error.html', msg=u'用户名不存在')
         if account.status not in (0, 1):
             return self.render('error.html', msg=u'用户账号不在正常状态,有疑问请联系客服')
         if self.aes.decrypt(account.password) != oldpass:
             return self.render('error.html', msg=u'用户旧密码不正确')
         account.password = self.aes.encrypt(newpass.encode('utf-8'))
         self.db.commit()
         self.render('success.html', msg=u'修改密码成功')
     except Exception as err:
         logger.exception(err, trace='wechat')
         self.render('error.html', msg=u'修改密码失败,请联系客服 %s' % repr(err))
Exemplo n.º 4
0
def domain_add_vform():
    return btforms.Form(btforms.Dropdown('tpl_name',
                                         wlan_tpls.items(),
                                         rules.not_null,
                                         description=u'Hotspot 模版',
                                         required='required',
                                         **input_style),
                        btforms.Textbox('domain_code',
                                        rules.is_alphanum2(2, 16),
                                        description=u'认证域编码',
                                        required='required',
                                        **input_style),
                        btforms.Textbox('domain_desc',
                                        rules.not_null,
                                        description=u'域描述',
                                        required='required',
                                        **input_style),
                        btforms.Button('submit',
                                       type='submit',
                                       html=u'<b>提交</b>',
                                       **button_style),
                        title=u'增加无线认证域',
                        action='/admin/wlan/domain/add')
Exemplo n.º 5
0
def bas_update_form(nodes = []):
    return btforms.Form(btforms.Hidden('id', description=u'编号'), btforms.Textbox('ip_addr', rules.is_ip, description=u'接入设备地址', **input_style), btforms.Textbox('bas_name', rules.len_of(2, 64), description=u'接入设备名称', required='required', **input_style), btforms.Textbox('nas_id', rules.len_of(4, 32), description=u'接入设备标识', help=u'动态IP专用', **input_style), btforms.Textbox('bas_secret', rules.is_alphanum2(4, 32), description=u'共享秘钥', required='required', **input_style), btforms.Dropdown('vendor_id', description=u'接入设备类型', args=bastype.items(), required='required', **input_style), btforms.Dropdown('portal_vendor', description=u'portal协议', args=portaltype.items(), required='required', **input_style), btforms.Textbox('ac_port', rules.is_number, description=u'无线控制器端口', default=2000, **input_style), btforms.Textbox('coa_port', rules.is_number, description=u'授权端口', default=3799, required='required', **input_style), btforms.Dropdown('time_type', description=u'时间类型', args=timetype.items(), required='required', **input_style), btforms.Dropdown('nodes', description=u'绑定区域(多选)', args=nodes, required='required', multiple='multiple', size=6, **input_style), btforms.Button('submit', type='submit', html=u'<b>更新</b>', **button_style), attrs=dict(mselect=['nodes']), title=u'修改接入设备', htopic='bas', action='/admin/bas/update')
Exemplo n.º 6
0
def vcard_batch_form():
    return btforms.Form(btforms.Dropdown('card_type', description=u'卡类型', args=cardtype.items(), required='required', **input_style), btforms.Dropdown('card_pwdtype', description=u'卡密码类型', args=pwdtype.items(), required='required', **input_style), btforms.Textbox('product_tag', rules.is_alphanum2(0, 32), description=u'资费标签(资费卡)', **input_style), btforms.Textbox('expire_date', rules.is_date, description=u'过期时间', required='required', **input_style), btforms.Textbox('credit', rules.is_number, description=u'储值余额(余额卡|元)', default=0, **input_style), btforms.Textbox('flowlen', rules.is_number, description=u'储值流量(余额卡|G)', default=0, **input_style), btforms.Textbox('timelen', rules.is_number, description=u'储值时长(时长卡|小时)', default=0, **input_style), btforms.Textbox('fee_price', rules.is_number, description=u'零售价(元)', default=0, required='required', **input_style), btforms.Textbox('num', rules.is_number, description=u'发行数量(最大100)', default=10, required='required', **input_style), btforms.Button('submit', type='submit', html=u'<b>提交</b>', **button_style), title=u'发行充值卡', action='/admin/vcard/batchadd')
Exemplo n.º 7
0
 def post(self, pid):
     try:
         openid = self.session.get('mps_openid',
                                   os.environ.get('DEV_OPEN_ID'))
         realname = self.get_argument('realname', '').strip()
         node_id = self.get_argument('node_id', '').strip()
         mobile = self.get_argument('mobile', '').strip()
         address = self.get_argument('address', '').strip()
         idcard = self.get_argument('idcard', '').strip()
         username = self.get_argument('username', '').strip()
         password = self.get_argument('password', '').strip()
         months = int(self.get_argument('months', '1'))
         days = int(self.get_argument('days', '1'))
         wechat_bind = int(self.get_argument('wechat_bind', '0'))
         product = self.db.query(models.TrProduct).filter_by(id=pid).first()
         if not product:
             return self.render('error.html', msg=u'资费不存在')
         if not realname:
             return self.render('wxorder_form.html',
                                product=product,
                                msg=u'姓名不能为空',
                                **self.get_params())
         if not rules.is_alphanum2(6, 16).valid(utils.safestr(username)):
             return self.render('wxorder_form.html',
                                product=product,
                                msg=u'用户名校验错误,必须是长度为6-16位的英文字符数字',
                                **self.get_params())
         if not rules.is_alphanum2(6, 16).valid(password):
             return self.render('wxorder_form.html',
                                product=product,
                                msg=u'密码校验错误,必须是6-16为的英文字符数字',
                                **self.get_params())
         if wechat_bind == 1 and self.db.query(models.TrCustomer).filter_by(
                 wechat_oid=openid).count() > 0:
             return self.render('wxorder_form.html',
                                product=product,
                                msg=u'微信账号已绑定',
                                **self.get_params())
         fee_value, expire_date = self.calc_fee(product.id,
                                                months=months,
                                                charge_fee=utils.fen2yuan(
                                                    product.fee_price))
         order_id = tools.gen_num_id(16)
         formdata = Storage({'order_attach': 'neworder'})
         formdata['wxpay_body'] = u'套餐订购:%s' % product.product_name
         formdata['openid'] = openid
         formdata['order_id'] = order_id
         formdata['node_id'] = node_id
         formdata['area_id'] = ''
         formdata['realname'] = realname
         formdata['idcard'] = idcard
         formdata['mobile'] = mobile
         formdata['address'] = address
         formdata['account_number'] = username
         formdata['password'] = password
         formdata['ip_address'] = ''
         formdata['product_id'] = product.id
         formdata['agency_id'] = ''
         formdata['charge_code'] = ''
         formdata['months'] = months
         formdata['days'] = days
         formdata['giftdays'] = 0
         formdata['giftflows'] = 0
         formdata['fee_value'] = fee_value
         formdata['expire_date'] = expire_date
         formdata['status'] = 1
         formdata['builder_name'] = ''
         formdata['customer_desc'] = u'客户微信自助开户'
         formdata['billing_type'] = 1
         formdata['accept_source'] = 'wechat'
         if wechat_bind == 1:
             formdata['wechat_oid'] = openid
         self.paycache.set(order_wxpaycaache_key(order_id), formdata, 28800)
         self.redirect('/mps/wxorder/pay/%s' % order_id)
     except Exception as err:
         logger.exception(err, trace='wechat')
         self.render('error.html', msg=u'套餐订购失败,请联系客服 %s' % repr(err))
Exemplo n.º 8
0
def customer_batch_open_form(nodes=[], products=[]):
    form = btforms.Form(title=u'用户批量开户', action='/admin/customer/batchopen')
    items = form.inputs = []
    items.append(
        btforms.Dropdown('node_id',
                         description=u'区域*',
                         args=nodes,
                         required='required',
                         **input_style))
    items.append(
        btforms.Dropdown('area_id',
                         description=u'社区*',
                         args=[],
                         required='required',
                         **input_style))
    items.append(
        btforms.Dropdown('product_id',
                         args=products,
                         description=u'资费*',
                         required='required',
                         **input_style))
    items.append(
        btforms.Dropdown('pwd_type',
                         args=pwd_types.items(),
                         description=u'密码类型',
                         **input_style))
    items.append(
        btforms.Textbox('password', description=u'认证密码*', **input_style))
    items.append(
        btforms.Textbox('opennum',
                        rules.is_number,
                        description=u'数量(最大1000)*',
                        required='required',
                        **input_style))
    items.append(
        btforms.Textbox('user_prefix',
                        rules.is_alphanum2(1, 10),
                        description=u'账号前缀*',
                        required='required',
                        **input_style))
    items.append(
        btforms.Textbox('suffix_len',
                        rules.is_number,
                        description=u'序号长度*',
                        required='required',
                        **input_style))
    items.append(
        btforms.Textbox('start_num',
                        rules.is_number,
                        description=u'开始序号*',
                        required='required',
                        **input_style))
    items.append(
        btforms.Textbox('expire_date',
                        rules.is_date,
                        description=u'过期日期*',
                        readonly='readonly',
                        **input_style))
    items.append(
        btforms.Hidden('billing_type',
                       args=billing_types.items(),
                       description=u'计费开始时间',
                       **input_style))
    items.append(
        btforms.Button('submit',
                       type='submit',
                       html=u'<b>提交</b>',
                       **button_style))
    return form
Exemplo n.º 9
0
def product_add_form(policy=0, charges=[], pools=[]):
    _policy = int(policy)
    form = btforms.Form(title=u'创建资费', action='/admin/product/add')
    form.inputs = []
    additem = form.inputs.append
    additem(
        btforms.Textbox('product_id',
                        rules.is_alphanum2(4, 32),
                        description=u'资费编码',
                        required='required',
                        **input_style))
    additem(
        btforms.Textbox('product_name',
                        rules.len_of(4, 64),
                        description=u'资费名称',
                        required='required',
                        **input_style))
    additem(
        btforms.Dropdown('ispub',
                         args=boolean.items(),
                         description=u'是否发布到自助订购套餐',
                         **input_style))
    additem(btforms.Hidden('product_policy', value=policy, description=u''))
    if _policy == PPMonth:
        form.desc = u'预付费包月:以每月单价为基础,用户可自由订购多月,到期即停止服务。'
        additem(
            btforms.Textbox('fee_price',
                            rules.is_rmb,
                            description=u'每月单价(元)',
                            required='required',
                            **input_style))
        additem(btforms.Hidden('fee_flows', value=0, description=u'买断流量(G)'))
        additem(btforms.Hidden('fee_times', value=0, description=u'买断时长(小时)'))
        additem(btforms.Hidden('fee_months', value=0, description=u'买断授权月数'))
        additem(btforms.Hidden('fee_days', value=0, description=u'买断授权天数'))
    elif _policy == APMonth:
        form.desc = u'后付费包月:以每月单价为基础,先使用,下个月初期生成使用账单'
        additem(
            btforms.Textbox('fee_price',
                            rules.is_rmb,
                            description=u'每月单价(元)',
                            required='required',
                            **input_style))
        additem(btforms.Hidden('fee_flows', value=0, description=u'买断流量(G)'))
        additem(btforms.Hidden('fee_times', value=0, description=u'买断时长(小时)'))
        additem(btforms.Hidden('fee_months', value=0, description=u'买断授权月数'))
        additem(btforms.Hidden('fee_days', value=0, description=u'买断授权天数'))
    elif _policy == BOMonth:
        form.desc = u'买断包月:以月为单位进行套餐打包(如包季度,半年,一年等),设定买断总价,用户一次性订购,到期即停止服务。'
        additem(
            btforms.Textbox('fee_price',
                            rules.is_rmb,
                            description=u'买断包月总价(元)',
                            required='required',
                            **input_style))
        additem(
            btforms.Textbox('fee_months',
                            rules.is_number,
                            description=u'买断授权月数',
                            value=0,
                            **input_style))
        additem(btforms.Hidden('fee_times', value=0, description=u'买断时长(小时)'))
        additem(btforms.Hidden('fee_flows', value=0, description=u'买断流量(G)'))
        additem(btforms.Hidden('fee_days', value=0, description=u'买断授权天数'))
    elif _policy == BOTimes:
        form.desc = u'买断时长:一次性将固定的时长打包为套餐,提供用户一次性订购,在使用过程中实时扣除时间,扣完为止。(设备必须支持实时记帐),剩余时长为零时停止服务'
        additem(
            btforms.Textbox('fee_price',
                            rules.is_rmb,
                            description=u'买断时长总价(元)',
                            required='required',
                            **input_style))
        additem(
            btforms.Textbox('fee_times',
                            rules.is_number3,
                            description=u'买断时长(小时)',
                            value=0,
                            **input_style))
        additem(btforms.Hidden('fee_flows', value=0, description=u'买断流量(G)'))
        additem(btforms.Hidden('fee_days', value=0, description=u'买断授权天数'))
        additem(btforms.Hidden('fee_months', value=0, description=u'买断授权月数'))
    elif _policy == BOFlows:
        form.desc = u'买断流量:一次性将固定的流量打包为套餐,提供用户一次性订购,在使用过程中实时扣除流量,扣完为止。(设备必须支持实时记帐),剩余流量为零时停止服务。'
        additem(
            btforms.Textbox('fee_price',
                            rules.is_rmb,
                            description=u'买断流量总价(元)',
                            required='required',
                            **input_style))
        additem(
            btforms.Textbox('fee_flows',
                            rules.is_number3,
                            description=u'买断流量(G)',
                            value=0,
                            **input_style))
        additem(btforms.Hidden('fee_times', value=0, description=u'买断时长(小时)'))
        additem(btforms.Hidden('fee_days', value=0, description=u'买断授权天数'))
        additem(btforms.Hidden('fee_months', value=0, description=u'买断授权月数'))
    elif _policy == PPDay:
        form.desc = u'预付费包日:以每日单价为基础,用户可自由订购多日,到期即停止服务。'
        additem(
            btforms.Textbox('fee_price',
                            rules.is_rmb,
                            description=u'每日单价(元)',
                            required='required',
                            **input_style))
        additem(btforms.Hidden('fee_times', value=0, description=u'买断时长(小时)'))
        additem(btforms.Hidden('fee_flows', value=0, description=u'买断流量(G)'))
        additem(btforms.Hidden('fee_days', value=0, description=u'买断授权天数'))
        additem(btforms.Hidden('fee_months', value=0, description=u'买断授权月数'))
    elif _policy == BODay:
        form.desc = u'买断包日:以日为单位进行套餐打包(任意天数),设定买断总价,用户一次性订购,到期即停止服务。'
        additem(
            btforms.Textbox('fee_price',
                            rules.is_rmb,
                            description=u'买断包日总价(元)',
                            required='required',
                            **input_style))
        additem(
            btforms.Textbox('fee_days',
                            rules.is_number3,
                            description=u'买断授权天数',
                            value=0,
                            **input_style))
        additem(btforms.Hidden('fee_flows', value=0, description=u'买断流量(G)'))
        additem(btforms.Hidden('fee_times', value=0, description=u'买断时长(小时)'))
        additem(btforms.Hidden('fee_months', value=0, description=u'买断授权月数'))
    additem(
        btforms.Dropdown('product_charges',
                         description=u'关联收费项(多选)',
                         args=charges,
                         multiple='multiple',
                         size=6,
                         **input_style))
    additem(
        btforms.Dropdown('addr_pool',
                         args=pools,
                         description=u'地址池',
                         **input_style))
    additem(
        btforms.Textbox('concur_number',
                        rules.is_numberOboveZore,
                        description=u'同时在线数(0表示不限制)',
                        value='0',
                        **input_style))
    additem(
        btforms.Dropdown('bind_mac',
                         args=boolean.items(),
                         description=u'是否绑定MAC ',
                         **input_style))
    additem(
        btforms.Dropdown('bind_vlan',
                         args=boolean.items(),
                         description=u'是否绑定VLAN ',
                         **input_style))
    additem(
        btforms.Textbox('input_max_limit',
                        rules.is_number3,
                        description=u'最大上行速率(Mbps)',
                        required='required',
                        **input_style))
    additem(
        btforms.Textbox('output_max_limit',
                        rules.is_number3,
                        description=u'最大下行速率(Mbps)',
                        required='required',
                        **input_style))
    additem(
        btforms.Dropdown('free_auth',
                         args=boolean.items(),
                         description=u'支持到期免费授权',
                         **input_style))
    additem(
        btforms.Textbox('free_auth_uprate',
                        rules.is_number3,
                        description=u' 免费授权最大上行速率(Mbps)',
                        **input_style))
    additem(
        btforms.Textbox('free_auth_downrate',
                        rules.is_number3,
                        description=u'免费授权最大下行速率(Mbps)',
                        **input_style))
    additem(
        btforms.Button('submit',
                       type='submit',
                       id='submit',
                       html=u'<b>提交</b>',
                       **button_style))
    return form
Exemplo n.º 10
0
def order_form(policy):
    form = btforms.Form(title=u'套餐订购', action='/ssportal/product/order')
    items = form.inputs = []
    items.append(
        btforms.Textbox('realname',
                        rules.not_null,
                        size=64,
                        description=u'用户姓名',
                        required='required',
                        **input_style))
    items.append(
        btforms.Textbox('account_number',
                        description=u'用户账号',
                        readonly='readonly',
                        **input_style))
    items.append(
        btforms.Textbox('email',
                        description=u'电子邮箱',
                        required='required',
                        **input_style))
    items.append(
        btforms.Textbox('password',
                        rules.is_alphanum2(6, 9),
                        description=u'认证密码',
                        required='required',
                        **input_style))
    items.append(
        btforms.Textbox('product_name',
                        readonly='readonly',
                        description=u'资费',
                        **input_style))
    items.append(
        btforms.Hidden('product_id',
                       description=u'资费',
                       required='required',
                       **input_style))
    if int(policy) == PPMonth:
        items.append(
            btforms.Textbox('months',
                            rules.is_number,
                            description=u'订购月数(预付费包月)',
                            required='required',
                            **input_style))
    else:
        items.append(
            btforms.Hidden('months', description=u'订购月数(预付费包月)',
                           **input_style))
    if int(policy) == PPDay:
        items.append(
            btforms.Textbox('days',
                            rules.is_number,
                            description=u'订购天数(预付费包天)',
                            required='required',
                            **input_style))
    else:
        items.append(
            btforms.Hidden('days', description=u'订购天数(预付费包天)', **input_style))
    if os.environ.get('LICENSE_TYPE') != 'community':
        items.append(
            btforms.Textbox('vcard_code', description=u'充值卡', **input_style))
        items.append(
            btforms.Password('vcard_pwd', description=u'充值卡密码', **input_style))
    items.append(
        btforms.Button('submit',
                       type='submit',
                       html=u'<b>提交订单</b>',
                       **button_style))
    return form