def roster_add_post(db): form = forms.roster_add_form() if not form.validates(source=request.forms): return render("sys_roster_form", form=form) if db.query(models.SlcRadRoster.id).filter_by( mac_addr=form.d.mac_addr).count() > 0: return render("sys_roster_form", form=form, msg=u"MAC地址已经存在") roster = models.SlcRadRoster() roster.mac_addr = form.d.mac_addr.replace("-", ":").upper() roster.begin_time = form.d.begin_time roster.end_time = form.d.end_time roster.roster_type = form.d.roster_type db.add(roster) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)新增黑白名单信息:%s' % (get_cookie("username"), serial_json(roster)) db.add(ops_log) db.commit() websock.update_cache("roster", mac_addr=roster.mac_addr) redirect("/roster")
def product_update(db): form = forms.product_update_form() if not form.validates(source=request.forms): return render("sys_product_form", form=form) product = db.query(models.SlcRadProduct).get(form.d.id) product.product_name = form.d.product_name product.product_status = form.d.product_status product.fee_months = form.d.get("fee_months", 0) product.bind_mac = form.d.bind_mac product.bind_vlan = form.d.bind_vlan product.concur_number = form.d.concur_number product.fee_period = form.d.fee_period product.fee_price = utils.yuan2fen(form.d.fee_price) product.input_max_limit = form.d.input_max_limit product.output_max_limit = form.d.output_max_limit product.update_time = utils.get_currtime() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改资费信息:%s' % (get_cookie("username"), serial_json(product)) db.add(ops_log) db.commit() websock.update_cache("product", product_id=product.id) redirect("/product")
def account_update(db): form = forms.account_update_form() if not form.validates(source=request.forms): return render("base_form", form=form) account = db.query(models.SlcRadAccount).get(form.d.account_number) account.ip_address = form.d.ip_address account.install_address = form.d.install_address account.user_concur_number = form.d.user_concur_number account.bind_mac = form.d.bind_mac account.bind_vlan = form.d.bind_vlan if form.d.new_password: account.password = utils.encrypt(form.d.new_password) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() _d = form.d.copy() del _d['new_password'] ops_log.operate_desc = u'操作员(%s)修改上网账号信息:%s' % (get_cookie("username"), json.dumps(_d)) db.add(ops_log) db.commit() websock.update_cache("account", account_number=account.account_number) redirect("/bus/member/detail?member_id={}".format(account.member_id))
def account_pause(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) if account.status != 1: return dict(msg=u"用户当前状态不允许停机") _datetime = utils.get_currtime() account.last_pause = _datetime account.status = 2 accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'pause' accept_log.accept_source = 'console' accept_log.accept_desc = u"用户停机:上网账号:%s" % (account_number) accept_log.account_number = account.account_number accept_log.accept_time = _datetime accept_log.operator_name = get_cookie("username") db.add(accept_log) db.commit() websock.update_cache("account", account_number=account.account_number) onlines = db.query( models.SlcRadOnline).filter_by(account_number=account_number) for _online in onlines: websock.invoke_admin("coa_request", nas_addr=_online.nas_addr, acct_session_id=_online.acct_session_id, message_type='disconnect') return dict(msg=u"操作成功")
def account_update(db): form = forms.account_update_form() if not form.validates(source=request.forms): return render("base_form", form=form) account = db.query(models.SlcRadAccount).get(form.d.account_number) account.ip_address = form.d.ip_address account.install_address = form.d.install_address account.user_concur_number = form.d.user_concur_number account.bind_mac = form.d.bind_mac account.bind_vlan = form.d.bind_vlan if form.d.new_password: account.password = utils.encrypt(form.d.new_password) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() _d = form.d.copy() del _d['new_password'] ops_log.operate_desc = u'操作员(%s)修改上网账号信息:%s'%(get_cookie("username"),json.dumps(_d)) db.add(ops_log) db.commit() websock.update_cache("account",account_number=account.account_number) redirect(member_detail_url_formatter(account.member_id))
def account_resume(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) if account.status != 2: return dict(msg=u"用户当前状态不允许复机") account.status = 1 _datetime = datetime.datetime.now() _pause_time = datetime.datetime.strptime(account.last_pause, "%Y-%m-%d %H:%M:%S") _expire_date = datetime.datetime.strptime( account.expire_date + ' 23:59:59', "%Y-%m-%d %H:%M:%S") days = (_expire_date - _pause_time).days new_expire = (_datetime + datetime.timedelta(days=int(days))).strftime("%Y-%m-%d") account.expire_date = new_expire accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'resume' accept_log.accept_source = 'console' accept_log.accept_desc = u"用户复机:上网账号:%s" % (account_number) accept_log.account_number = account.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") db.add(accept_log) db.commit() websock.update_cache("account", account_number=account.account_number) return dict(msg=u"操作成功")
def account_resume(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) if account.status != 2: return dict(msg=u"用户当前状态不允许复机") account.status = 1 _datetime = datetime.datetime.now() _pause_time = datetime.datetime.strptime(account.last_pause,"%Y-%m-%d %H:%M:%S") _expire_date = datetime.datetime.strptime(account.expire_date+' 23:59:59',"%Y-%m-%d %H:%M:%S") days = (_expire_date - _pause_time).days new_expire = (_datetime + datetime.timedelta(days=int(days))).strftime("%Y-%m-%d") account.expire_date = new_expire accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'resume' accept_log.accept_source = 'console' accept_log.accept_desc = u"用户复机:上网账号:%s"%(account_number) accept_log.account_number = account.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") db.add(accept_log) db.commit() websock.update_cache("account",account_number=account.account_number) return dict(msg=u"操作成功")
def account_pause(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) if account.status != 1: return dict(msg=u"用户当前状态不允许停机") _datetime = utils.get_currtime() account.last_pause = _datetime account.status = 2 accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'pause' accept_log.accept_source = 'console' accept_log.accept_desc = u"用户停机:上网账号:%s"%(account_number) accept_log.account_number = account.account_number accept_log.accept_time = _datetime accept_log.operator_name = get_cookie("username") db.add(accept_log) db.commit() websock.update_cache("account",account_number=account.account_number) onlines = db.query(models.SlcRadOnline).filter_by(account_number=account_number) for _online in onlines: websock.invoke_admin("coa_request", nas_addr=_online.nas_addr, acct_session_id=_online.acct_session_id, message_type='disconnect') return dict(msg=u"操作成功")
def product_update(db): form=forms.product_update_form() if not form.validates(source=request.forms): return render("sys_product_form", form=form) product = db.query(models.SlcRadProduct).get(form.d.id) product.product_name = form.d.product_name product.product_status = form.d.product_status product.fee_months = form.d.get("fee_months",0) product.bind_mac = form.d.bind_mac product.bind_vlan = form.d.bind_vlan product.concur_number = form.d.concur_number product.fee_period = form.d.fee_period product.fee_price = utils.yuan2fen(form.d.fee_price) product.input_max_limit = form.d.input_max_limit product.output_max_limit = form.d.output_max_limit product.update_time = utils.get_currtime() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改资费信息:%s'%(get_cookie("username"),serial_json(product)) db.add(ops_log) db.commit() websock.update_cache("product",product_id=product.id) redirect("/product")
def account_next(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) user = query_account(db, account_number) form = forms.account_next_form() form.product_id.set_value(user.product_id) if account.status not in (1, 4): return render("bus_account_next_form", user=user, form=form, msg=u"无效用户状态") if not form.validates(source=request.forms): return render("bus_account_next_form", user=user, form=form) accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'next' accept_log.accept_source = 'console' accept_log.accept_desc = u"用户续费:上网账号:%s,续费%s元" % (account_number, form.d.fee_value) accept_log.account_number = form.d.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") db.add(accept_log) db.flush() db.refresh(accept_log) order_fee = 0 product = db.query(models.SlcRadProduct).get(user.product_id) order_fee = decimal.Decimal(product.fee_price) * decimal.Decimal( form.d.months) order_fee = int(order_fee.to_integral_value()) order = models.SlcMemberOrder() order.order_id = utils.gen_order_id() order.member_id = user.member_id order.product_id = user.product_id order.account_number = form.d.account_number order.order_fee = order_fee order.actual_fee = utils.yuan2fen(form.d.fee_value) order.pay_status = 1 order.accept_id = accept_log.id order.order_source = 'console' order.create_time = utils.get_currtime() order.order_desc = u"用户续费" db.add(order) account.status = 1 account.expire_date = form.d.expire_date db.commit() websock.update_cache("account", account_number=account_number) redirect("/bus/member/detail?member_id={}".format(user.member_id))
def account_next(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) user = query_account(db, account_number) form = forms.account_cancel_form() if account.status != 1: return render("bus_account_form", user=user, form=form, msg=u"无效用户状态") if not form.validates(source=request.forms): return render("bus_account_form", user=user, form=form) accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'cancel' accept_log.accept_source = 'console' accept_log.account_number = form.d.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") accept_log.accept_desc = u"用户销户:上网账号:%s,退费%s(元)" % (account_number, form.d.fee_value) db.add(accept_log) db.flush() db.refresh(accept_log) order = models.SlcMemberOrder() order.order_id = utils.gen_order_id() order.member_id = user.member_id order.product_id = user.product_id order.account_number = form.d.account_number order.order_fee = 0 order.actual_fee = -utils.yuan2fen(form.d.fee_value) order.pay_status = 1 order.order_source = 'console' order.accept_id = accept_log.id order.create_time = utils.get_currtime() order.order_desc = u'用户销户' db.add(order) account.status = 3 db.commit() websock.update_cache("account", account_number=account_number) onlines = db.query( models.SlcRadOnline).filter_by(account_number=account_number) for _online in onlines: websock.invoke_admin("coa_request", nas_addr=_online.nas_addr, acct_session_id=_online.acct_session_id, message_type='disconnect') redirect("/bus/member/detail?member_id={}".format(user.member_id))
def roster_delete(db): roster_id = request.params.get("roster_id") db.query(models.SlcRadRoster).filter_by(id=roster_id).delete() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)删除黑白名单信息:%s' % (get_cookie("username"), roster_id) db.add(ops_log) db.commit() websock.update_cache("roster", roster_id=roster_id) redirect("/roster")
def roster_delete(db): roster_id = request.params.get("roster_id") mac_addr = db.query(models.SlcRadRoster).get(roster_id).mac_addr db.query(models.SlcRadRoster).filter_by(id=roster_id).delete() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)删除黑白名单信息:%s'%(get_cookie("username"),roster_id) db.add(ops_log) db.commit() websock.update_cache("roster",mac_addr=mac_addr) redirect("/roster")
def group_delete(db): group_id = request.params.get("group_id") db.query(models.SlcRadGroup).filter_by(id=group_id).delete() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)删除用户组信息:%s' % (get_cookie("username"), group_id) db.add(ops_log) db.commit() websock.update_cache("group", group_id=group_id) redirect("/group")
def product_attr_update(db): attr_id = request.params.get("attr_id") attr = db.query(models.SlcRadProductAttr).get(attr_id) product_id = attr.product_id db.query(models.SlcRadProductAttr).filter_by(id=attr_id).delete() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)删除资费属性信息:%s'%(get_cookie("username"),serial_json(attr)) db.add(ops_log) db.commit() websock.update_cache("product",product_id=product_id) redirect("/product/detail?product_id=%s"%product_id)
def product_delete(db): product_id = request.params.get("product_id") if db.query(models.SlcRadAccount).filter_by(product_id=product_id).count()>0: return render("error",msg=u"该套餐有用户使用,不允许删除") db.query(models.SlcRadProduct).filter_by(id=product_id).delete() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)删除资费信息:%s'%(get_cookie("username"),product_id) db.add(ops_log) db.commit() websock.update_cache("product",product_id=product_id) redirect("/product")
def account_next(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) user = query_account(db,account_number) form = forms.account_next_form() form.product_id.set_value(user.product_id) if account.status not in (1,4): return render("bus_account_next_form", user=user,form=form,msg=u"无效用户状态") if not form.validates(source=request.forms): return render("bus_account_next_form", user=user,form=form) accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'next' accept_log.accept_source = 'console' accept_log.accept_desc = u"用户续费:上网账号:%s,续费%s元"%(account_number,form.d.fee_value) accept_log.account_number = form.d.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") db.add(accept_log) db.flush() db.refresh(accept_log) order_fee = 0 product = db.query(models.SlcRadProduct).get(user.product_id) order_fee = decimal.Decimal(product.fee_price) * decimal.Decimal(form.d.months) order_fee = int(order_fee.to_integral_value()) order = models.SlcMemberOrder() order.order_id = utils.gen_order_id() order.member_id = user.member_id order.product_id = user.product_id order.account_number = form.d.account_number order.order_fee = order_fee order.actual_fee = utils.yuan2fen(form.d.fee_value) order.pay_status = 1 order.accept_id = accept_log.id order.order_source = 'console' order.create_time = utils.get_currtime() order.order_desc = u"用户续费" db.add(order) account.status = 1 account.expire_date = form.d.expire_date db.commit() websock.update_cache("account",account_number=account_number) redirect(member_detail_url_formatter(user.member_id))
def account_next(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) user = query_account(db,account_number) form = forms.account_cancel_form() if account.status !=1 : return render("bus_account_form", user=user,form=form,msg=u"无效用户状态") if not form.validates(source=request.forms): return render("bus_account_form", user=user,form=form) accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'cancel' accept_log.accept_source = 'console' accept_log.account_number = form.d.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") accept_log.accept_desc = u"用户销户:上网账号:%s,退费%s(元)"%(account_number,form.d.fee_value) db.add(accept_log) db.flush() db.refresh(accept_log) order = models.SlcMemberOrder() order.order_id = utils.gen_order_id() order.member_id = user.member_id order.product_id = user.product_id order.account_number = form.d.account_number order.order_fee = 0 order.actual_fee = -utils.yuan2fen(form.d.fee_value) order.pay_status = 1 order.order_source = 'console' order.accept_id = accept_log.id order.create_time = utils.get_currtime() order.order_desc = u'用户销户' db.add(order) account.status = 3 db.commit() websock.update_cache("account",account_number=account_number) onlines = db.query(models.SlcRadOnline).filter_by(account_number=account_number) for _online in onlines: websock.invoke_admin("coa_request", nas_addr=_online.nas_addr, acct_session_id=_online.acct_session_id, message_type='disconnect') redirect(member_detail_url_formatter(user.member_id))
def user_release(db): account_number = request.params.get('account_number') user = db.query(models.SlcRadAccount).filter_by(account_number=account_number).first() user.mac_addr = '' user.vlan_id = 0 user.vlan_id2 = 0 ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'释放用户账号(%s)绑定信息'%(account_number,) db.add(ops_log) db.commit() websock.update_cache("account",account_number=account_number) return dict(code=0,msg=u"解绑成功")
def product_attr_update(db): attr_id = request.params.get("attr_id") attr = db.query(models.SlcRadProductAttr).get(attr_id) product_id = attr.product_id db.query(models.SlcRadProductAttr).filter_by(id=attr_id).delete() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)删除资费属性信息:%s' % (get_cookie("username"), serial_json(attr)) db.add(ops_log) db.commit() websock.update_cache("product", product_id=product_id) redirect("/product/detail?product_id=%s" % product_id)
def user_release(db): account_number = request.params.get('account_number') user = db.query( models.SlcRadAccount).filter_by(account_number=account_number) user.mac_addr = '' user.vlan_id = 0 user.vlan_id2 = 0 ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'释放用户账号(%s)绑定信息' % (account_number, ) db.add(ops_log) db.commit() websock.update_cache("account", account_number=account_number) return dict(code=0, msg=u"解绑成功")
def product_delete(db): product_id = request.params.get("product_id") if db.query( models.SlcRadAccount).filter_by(product_id=product_id).count() > 0: return render("error", msg=u"该套餐有用户使用,不允许删除") db.query(models.SlcRadProduct).filter_by(id=product_id).delete() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)删除资费信息:%s' % (get_cookie("username"), product_id) db.add(ops_log) db.commit() websock.update_cache("product", product_id=product_id) redirect("/product")
def product_attr_update(db): form = forms.product_attr_update_form() if not form.validates(source=request.forms): return render("pattr_form", form=form,pattrs=radius_attrs) attr = db.query(models.SlcRadProductAttr).get(form.d.id) attr.attr_name = form.d.attr_name attr.attr_value = form.d.attr_value attr.attr_desc = form.d.attr_desc ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改资费属性信息:%s'%(get_cookie("username"),serial_json(attr)) db.add(ops_log) db.commit() websock.update_cache("product",product_id=form.d.product_id) redirect("/product/detail?product_id="+form.d.product_id)
def account_charge(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) user = query_account(db, account_number) form = forms.account_charge_form() if account.status != 1: return render("bus_account_form", user=user, form=form, msg=u"无效用户状态") if not form.validates(source=request.forms): return render("bus_account_form", user=user, form=form) accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'charge' accept_log.accept_source = 'console' accept_log.account_number = form.d.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") _new_fee = account.balance + utils.yuan2fen(form.d.fee_value) accept_log.accept_desc = u"用户充值:上网账号:%s,充值前%s(分),充值后%s(分)" % ( account_number, account.balance, _new_fee) db.add(accept_log) db.flush() db.refresh(accept_log) order = models.SlcMemberOrder() order.order_id = utils.gen_order_id() order.member_id = user.member_id order.product_id = user.product_id order.account_number = form.d.account_number order.order_fee = 0 order.actual_fee = utils.yuan2fen(form.d.fee_value) order.pay_status = 1 order.accept_id = accept_log.id order.order_source = 'console' order.create_time = utils.get_currtime() order.order_desc = u"用户充值" db.add(order) account.balance += order.actual_fee db.commit() websock.update_cache("account", account_number=account_number) redirect("/bus/member/detail?member_id={}".format(user.member_id))
def roster_add_update(db): form=forms.roster_update_form() if not form.validates(source=request.forms): return render("sys_roster_form", form=form) roster = db.query(models.SlcRadRoster).get(form.d.id) roster.begin_time = form.d.begin_time roster.end_time = form.d.end_time roster.roster_type = form.d.roster_type ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改黑白名单信息:%s'%(get_cookie("username"),serial_json(roster)) db.add(ops_log) db.commit() websock.update_cache("roster",mac_addr=roster.mac_addr) redirect("/roster")
def account_charge(db): account_number = request.params.get("account_number") account = db.query(models.SlcRadAccount).get(account_number) user = query_account(db,account_number) form = forms.account_charge_form() if account.status !=1 : return render("bus_account_form", user=user,form=form,msg=u"无效用户状态") if not form.validates(source=request.forms): return render("bus_account_form", user=user,form=form) accept_log = models.SlcRadAcceptLog() accept_log.accept_type = 'charge' accept_log.accept_source = 'console' accept_log.account_number = form.d.account_number accept_log.accept_time = utils.get_currtime() accept_log.operator_name = get_cookie("username") _new_fee = account.balance + utils.yuan2fen(form.d.fee_value) accept_log.accept_desc = u"用户充值:上网账号:%s,充值前%s(分),充值后%s(分)"%(account_number,account.balance,_new_fee) db.add(accept_log) db.flush() db.refresh(accept_log) order = models.SlcMemberOrder() order.order_id = utils.gen_order_id() order.member_id = user.member_id order.product_id = user.product_id order.account_number = form.d.account_number order.order_fee = 0 order.actual_fee = utils.yuan2fen(form.d.fee_value) order.pay_status = 1 order.accept_id = accept_log.id order.order_source = 'console' order.create_time = utils.get_currtime() order.order_desc = u"用户充值" db.add(order) account.balance += order.actual_fee db.commit() websock.update_cache("account",account_number=account_number) redirect(member_detail_url_formatter(user.member_id))
def roster_add_update(db): form = forms.roster_update_form() if not form.validates(source=request.forms): return render("sys_roster_form", form=form) roster = db.query(models.SlcRadRoster).get(form.d.id) roster.begin_time = form.d.begin_time roster.end_time = form.d.end_time roster.roster_type = form.d.roster_type ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改黑白名单信息:%s' % (get_cookie("username"), serial_json(roster)) db.add(ops_log) db.commit() websock.update_cache("roster", mac_addr=roster.mac_addr) redirect("/roster")
def product_attr_update(db): form = forms.product_attr_update_form() if not form.validates(source=request.forms): return render("pattr_form", form=form, pattrs=radius_attrs) attr = db.query(models.SlcRadProductAttr).get(form.d.id) attr.attr_name = form.d.attr_name attr.attr_value = form.d.attr_value attr.attr_desc = form.d.attr_desc ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改资费属性信息:%s' % (get_cookie("username"), serial_json(attr)) db.add(ops_log) db.commit() websock.update_cache("product", product_id=form.d.product_id) redirect("/product/detail?product_id=" + form.d.product_id)
def bas_add_update(db): form=forms.bas_update_form() if not form.validates(source=request.forms): return render("base_form", form=form) bas = db.query(models.SlcRadBas).get(form.d.id) 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 ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改BAS信息:%s'%(get_cookie("username"),serial_json(bas)) db.add(ops_log) db.commit() websock.update_cache("bas",ip_addr=bas.ip_addr) redirect("/bas")
def param_update(db): params = db.query(models.SlcParam) wsflag = False for param in params: if param.param_name in request.forms: _value = request.forms.get(param.param_name) if _value: _value = _value.decode('utf-8') if _value and param.param_value not in _value: param.param_value = _value if param.param_name == '3_radiusd_address': if param.param_value != MakoTemplate.defaults['radaddr']: MakoTemplate.defaults['radaddr'] = param.param_value wsflag = True if param.param_name == '4_radiusd_admin_port': if param.param_value != MakoTemplate.defaults['adminport']: MakoTemplate.defaults['adminport'] = param.param_value wsflag = True if param.param_name == u'reject_delay': websock.update_cache("reject_delay", reject_delay=param.param_value) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改参数:%s' % ( get_cookie("username"), json.dumps(','.join([serial_json(param) for p in params]), ensure_ascii=False)) db.add(ops_log) db.commit() if wsflag: websock.reconnect( MakoTemplate.defaults['radaddr'], MakoTemplate.defaults['adminport'], ) websock.update_cache("param") redirect("/param")
def password_update_post(db): form = forms.password_update_form() if not form.validates(source=request.forms): return render("base_form", form=form) account = db.query(models.SlcRadAccount).filter_by(account_number=form.d.account_number).first() if not account: return render("base_form", form=form,msg=u'没有这个账号') if account.member_id != get_cookie("customer_id"): return render("base_form", form=form,msg=u'该账号用用户不匹配') if utils.decrypt(account.password) != form.d.old_password: return render("base_form", form=form,msg=u'旧密码不正确') if form.d.new_password != form.d.new_password2: return render("base_form", form=form,msg=u'确认新密码不匹配') account.password = utils.encrypt(form.d.new_password) db.commit() websock.update_cache("account",account_number=account.account_number) redirect("/")
def bas_add_update(db): form = forms.bas_update_form() if not form.validates(source=request.forms): return render("base_form", form=form) bas = db.query(models.SlcRadBas).get(form.d.id) 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 ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改BAS信息:%s' % (get_cookie("username"), serial_json(bas)) db.add(ops_log) db.commit() websock.update_cache("bas", ip_addr=bas.ip_addr) redirect("/bas")
def group_add_update(db): form = forms.group_update_form() if not form.validates(source=request.forms): return render("base_form", form=form) group = db.query(models.SlcRadGroup).get(form.d.id) group.group_name = form.d.group_name group.group_desc = form.d.group_desc group.bind_mac = form.d.bind_mac group.bind_vlan = form.d.bind_vlan group.concur_number = form.d.concur_number group.update_time = utils.get_currtime() ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改用户组信息:%s' % (get_cookie("username"), serial_json(group)) db.add(ops_log) db.commit() websock.update_cache("group", group_id=group.id) redirect("/group")
def roster_add_post(db): form=forms.roster_add_form() if not form.validates(source=request.forms): return render("sys_roster_form", form=form) if db.query(models.SlcRadRoster.id).filter_by(mac_addr=form.d.mac_addr).count()>0: return render("sys_roster_form", form=form,msg=u"MAC地址已经存在") roster = models.SlcRadRoster() roster.mac_addr = form.d.mac_addr.replace("-",":").upper() roster.begin_time = form.d.begin_time roster.end_time = form.d.end_time roster.roster_type = form.d.roster_type db.add(roster) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)新增黑白名单信息:%s'%(get_cookie("username"),serial_json(roster)) db.add(ops_log) db.commit() websock.update_cache("roster",mac_addr=roster.mac_addr) redirect("/roster")
def password_update_post(db): form = forms.password_update_form() if not form.validates(source=request.forms): return render("base_form", form=form) account = db.query(models.SlcRadAccount).filter_by( account_number=form.d.account_number).first() if not account: return render("base_form", form=form, msg=u'没有这个账号') if account.member_id != get_cookie("customer_id"): return render("base_form", form=form, msg=u'该账号用用户不匹配') if utils.decrypt(account.password) != form.d.old_password: return render("base_form", form=form, msg=u'旧密码不正确') if form.d.new_password != form.d.new_password2: return render("base_form", form=form, msg=u'确认新密码不匹配') account.password = utils.encrypt(form.d.new_password) db.commit() websock.update_cache("account", account_number=account.account_number) redirect("/")
def param_update(db): params = db.query(models.SlcParam) wsflag = False for param in params: if param.param_name in request.forms: _value = request.forms.get(param.param_name) if _value: _value = _value.decode('utf-8') if _value and param.param_value not in _value: param.param_value = _value if param.param_name == '3_radiusd_address': if param.param_value != MakoTemplate.defaults['radaddr']: MakoTemplate.defaults['radaddr'] = param.param_value wsflag = True if param.param_name == '4_radiusd_admin_port': if param.param_value != MakoTemplate.defaults['adminport']: MakoTemplate.defaults['adminport'] = param.param_value wsflag = True if param.param_name == u'reject_delay': websock.update_cache("reject_delay",reject_delay=param.param_value) ops_log = models.SlcRadOperateLog() ops_log.operator_name = get_cookie("username") ops_log.operate_ip = get_cookie("login_ip") ops_log.operate_time = utils.get_currtime() ops_log.operate_desc = u'操作员(%s)修改参数'%(get_cookie("username")) db.add(ops_log) db.commit() if wsflag: websock.reconnect( MakoTemplate.defaults['radaddr'], MakoTemplate.defaults['adminport'], ) websock.update_cache("param") redirect("/param")