本文整理汇总了Python中freepybx.model.meta.Session.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Session.remove方法的具体用法?Python Session.remove怎么用?Python Session.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freepybx.model.meta.Session
的用法示例。
在下文中一共展示了Session.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: account_by_id
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def account_by_id(self, id):
items = []
for account in (
CrmAccount.query.join(CrmCampaign)
.filter(CrmAccount.customer_id == session["customer_id"])
.filter(CrmAccount.user_id == session["user_id"])
.filter(CrmCampaign.name == id)
.all()
):
items.append(
{
"id": account.id,
"name": str(account.first_name) + " " + str(account.last_name),
"address": account.address,
"city": account.city,
"state": account.state,
"zip": account.zip,
"tel": account.tel,
"mobile": account.mobile,
"email": account.email,
"crm_campaign_id": account.crm_campaign_id,
}
)
db.remove()
out = dict({"identifier": "id", "label": "name", "items": items})
response = make_response(out)
response.headers = [("Content-type", "application/json")]
return response(request.environ, self.start_response)
示例2: delete_ivr
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def delete_ivr(name):
for ivr in PbxIVR.query.filter_by(name=name).filter_by(context=session['context']).all():
r = PbxRoute.query.filter(PbxRoute.pbx_route_type_id==5).\
filter(PbxRoute.name==ivr.name).filter(PbxRoute.context==session['context']).first()
did = PbxDid.did.query.filter(PbxDid.pbx_route_id==r.id).first()
if did:
msg = "Error: IVR is in use by Inbound DID: "+str(did.did)+"!"
tod = db.execute("select * from pbx_tod_routes where match_route_id = :id or nomatch_route_id = :id", {'id': r.id}).first()
if tod:
msg = "Error: IVR is in a TOD route!"
ivr_opt = PbxIVROption.query.filter(PbxIVROption.pbx_route_id==r.id).first()
if ivr_opt:
msg = "Error: IVR belongs to another IVR Option."
if not did and not ivr_opt and not tod:
PbxRoute.query.filter(PbxRoute.pbx_route_type_id==5).\
filter(PbxRoute.name==ivr.name).filter(PbxRoute.context==session['context']).delete()
PbxIVROption.query.filter(PbxIVROption.pbx_ivr_id==ivr.id).delete()
PbxIVR.query.filter(PbxIVR.name==name).filter(PbxIVR.context==session['context']).delete()
db.commit()
db.flush()
db.remove()
else:
return msg
db.remove()
return "Successfully deleted IVR: "+name+"."
示例3: ad_audio
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def ad_audio(self):
items = []
dir = fs_vm_dir + session["context"] + "/recordings/"
try:
for i in os.listdir(dir):
fo = generateFileObject(i, "", dir)
items.append(
{
"id": "1," + fo["name"],
"name": "Recording: " + fo["name"],
"data": fo["path"],
"type": 1,
"real_id": "",
}
)
db.remove()
except:
pass
out = dict({"identifier": "id", "label": "name", "items": items})
response = make_response(out)
response.headers = [("Content-type", "application/json; charset=UTF-8")]
return response(request.environ, self.start_response)
示例4: getUsers
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def getUsers(self, sid):
users = []
ep_stats = []
user = User.query.filter_by(session_id=sid).first()
if user:
context = user.get_context()
else:
raise Exception("No session id in db matching the user calling this method.")
for r in db.execute("SELECT DISTINCT users.first_name, users.last_name, users.id, users.customer_id, "
"customers.context AS context, users.portal_extension, "
"users.tel, users.mobile, users.username, sip_dialogs.uuid AS uuid "
"FROM users "
"INNER JOIN customers ON users.customer_id = customers.id "
"LEFT JOIN sip_dialogs ON sip_dialogs.presence_id = users.portal_extension || '@' || customers.context "
"WHERE customers.context = :context ORDER BY users.id", {'context': context}):
for pbx_reg in PbxRegistration.query.filter(PbxRegistration.sip_realm==context).filter(PbxRegistration.sip_user==r[5]).all():
ep_stats.append({'ip': pbx_reg.network_ip, 'port':pbx_reg.network_port})
is_online = True if len(ep_stats) > 0 else False
ep_stats = []
# make_broker_user(name, id, customer_id, email, tel, mobile, ext, uuid, is_online):
users.append(make_broker_user(r[0]+' '+r[1], r[2], r[3], r[8], r[6], r[7], r[5], r[9], is_online))
db.remove()
return users
示例5: update_campaign_grid
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def update_campaign_grid(self, **kw):
w = loads(urllib.unquote_plus(request.params.get("data")))
try:
for i in w["modified"]:
sg = (
CrmCampaignGroup.query.filter(CrmCampaignGroup.crm_campaign_id == i["id"])
.filter(CrmCampaignGroup.context == session["context"])
.first()
)
CrmGroupMember.query.filter(CrmGroupMember.crm_group_id == sg.crm_group_id).delete()
for gm in i["members"].split(","):
if not gm.strip().isdigit():
continue
sm = CrmGroupMember()
sm.crm_group_id = sg.crm_group_id
sm.extension = gm.strip()
sm.context = session["context"]
db.add(sm)
db.commit()
db.flush()
except:
db.remove()
return "Error updating campaign."
return "Successfully updated campaign."
示例6: del_blacklist
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def del_blacklist(cid_number):
PbxBlacklistedNumber.query.filter(PbxBlacklistedNumber.cid_number==cid_number)\
.filter(PbxBlacklistedNumber.context==session['context']).delete()
db.commit()
db.flush()
db.remove()
return True
示例7: delete_cid
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def delete_cid(cid_number):
PbxCallerIDRoute.query.filter(PbxCallerIDRoute.cid_number==cid_number)\
.filter(PbxCallerIDRoute.context==session['context']).delete()
db.commit()
db.flush()
db.remove()
return True
示例8: agent_edit
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def agent_edit(self):
schema = AgentEditForm()
try:
form_result = schema.to_python(request.params)
cca = (
CallCenterAgent.query.filter_by(context=session["context"])
.filter(CallCenterAgent.id == form_result.get("agent_id"))
.first()
)
cca.extension = form_result.get("extension")
e = (
PbxEndpoint.query.filter_by(user_context=session["context"])
.filter(PbxEndpoint.auth_id == cca.extension)
.first()
)
cca.context = session["context"]
cca.domain = session["context"]
cca.type = "callback"
cca.record_calls = form_result.get("record_calls", 0)
cca.timeout = form_result.get("timeout", 30)
cca.max_no_answer = form_result.get("max_no_answer", 3)
cca.wrap_up_time = form_result.get("wrap_up_time", 30)
cca.reject_delay_time = form_result.get("reject_delay_time", 30)
cca.busy_delay_time = form_result.get("busy_delay_time", 0)
cca.no_answer_delay_time = form_result.get("no_answer_delay_time", 5)
cca.user_id = e.user_id
cca.pbx_endpoint_id = e.id
db.commit()
db.flush()
except validators.Invalid, error:
db.remove()
return "Error: %s." % error
示例9: getCallers
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def getCallers(self, sid):
callers = []
user = User.query.filter_by(session_id=sid).first()
if user:
context = user.get_context()
for row in PbxDid.query.filter(PbxDid.context==context).all():
for cal in db.execute("SELECT * FROM channels WHERE dest like :did", {'did': "%"+row.did}).fetchall():
#PbxChannel.query.filter(PbxChannel.dest.like('%'+row.did).all():
l = PbxChannel.query.filter_by(uuid=cal.uuid).first()
if l:
to_user = l.dest
status = l.callstate
else:
to_user = ""
status = ""
direction = "inbound"
if len(cal.cid_num) > 10:
cid_num = cal.cid_num[len(cal.cid_num)-10:]
else:
cid_num = cal.cid_num
time_in_queue = db.execute("SELECT now() FROM channels WHERE uuid = :uuid", {'uuid': cal.uuid}).fetchone()
callers.append(make_caller(cal.dest, cal.cid_name,cid_num, direction, cal.created, time_in_queue[0], to_user, cal.uuid, status))
for cal in PbxChannel.query.filter_by(context=context).distinct(PbxChannel.call_uuid).all():
if len(cal.presence_id)>3:
if cal.presence_id.split("@")[1] == context:
time_in_queue = db.execute("SELECT now() FROM channels WHERE uuid = :uuid", {'uuid': cal.uuid}).fetchone()
callers.append(make_caller(cal.dest, cal.cid_name, cal.cid_num, "outbound", cal.created, "", cal.dest, cal.uuid, cal.callstate))
db.remove()
return callers
示例10: delete_conf
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def delete_conf(extension):
PbxRoute.query.filter(PbxRoute.pbx_route_type_id==7)\
.filter(PbxRoute.name==extension).filter(PbxRoute.context==session['context']).delete()
PbxConferenceBridge.query.filter(PbxConferenceBridge.extension==extension).delete()
db.commit()
db.flush()
db.remove()
return True
示例11: delete_conditions
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def delete_conditions(route_id):
for route in PbxRoute.query.filter(PbxRoute.pbx_route_type_id==1).\
filter(PbxRoute.id==route_id).filter(PbxRoute.context==session['context']).all():
for condition in PbxCondition.query.filter_by(pbx_route_id=route.id).all():
PbxAction.query.filter_by(pbx_condition_id=condition.id).delete()
PbxCondition.query.filter_by(pbx_route_id=route.id).delete()
db.commit()
db.flush()
db.remove()
示例12: __call__
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def __call__(self, environ, start_response):
"""Invoke the Controller"""
# WSGIController.__call__ dispatches to the Controller method
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']
try:
return WSGIController.__call__(self, environ, start_response)
finally:
Session.remove()
示例13: get_talk_time
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def get_talk_time(ext, context):
rows = db.execute("SELECT coalesce(sum(billsec)/60,0) AS mins FROM cdr "
"WHERE (caller_id_number=:ext OR destination_number=:ext) "
"AND start_stamp BETWEEN CURRENT_DATE AND CURRENT_TIMESTAMP "
"AND bleg_uuid IS NOT NULL AND context = :context",
{'ext':ext, 'context': context})
r = rows.fetchone()
db.remove()
return r.mins
示例14: register_login
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def register_login(class_, username, session, request):
user = db.query(AdminUser).filter(AdminUser.username==username).first()
if user:
now = datetime.now()
user.last_login = now
user.session_id = session.id
user.remote_addr = request.environ["HTTP_REMOTE_EU"]
db.commit()
db.flush()
db.remove()
示例15: delete_fax_ext
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import remove [as 别名]
def delete_fax_ext(extension):
for ext in PbxFax.query.filter(PbxFax.extension==extension).filter(PbxFax.context==session['context']).all():
for route in PbxRoute.query.filter(PbxRoute.pbx_route_type_id==12).\
filter(PbxRoute.name==ext.extension).filter(PbxRoute.context==session['context']).all():
PbxRoute.query.filter(PbxRoute.pbx_route_type_id==12).\
filter(PbxRoute.name==ext.extension).filter(PbxRoute.context==session['context']).delete()
PbxFax.query.filter(PbxFax.extension==extension).filter(PbxFax.context==session['context']).delete()
db.commit()
db.flush()
db.remove()
return True