本文整理汇总了Python中freepybx.model.meta.Session.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Session.commit方法的具体用法?Python Session.commit怎么用?Python Session.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freepybx.model.meta.Session
的用法示例。
在下文中一共展示了Session.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: agent_edit
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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
示例2: update_campaign_grid
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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."
示例3: del_blacklist
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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
示例4: delete_ivr
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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+"."
示例5: delete_cid
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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
示例6: authenticate_admin
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [as 别名]
def authenticate_admin(username, password):
auth_user = AdminUser.query.filter(AdminUser.username==username).first()
if not auth_user:
log.debug("No user named: '%s'", username)
return False
elif not auth_user.password:
log.error("Bad username/pass:'%s'")
return False
elif password != auth_user.password:
log.debug("Database password for user '%s'", username)
return False
else:
request.environ["REMOTE_USER"] = auth_user.username
request.environ["HTTP_REMOTE_USER"] = auth_user.username
session["perms"]= auth_user.permissions
session["user"] = auth_user
session["name"] = auth_user.name
session['user_id'] = auth_user.id
auth_user.register_login(username, session, request)
db.commit()
db.flush()
session.save()
return True
示例7: edit_crm_account
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [as 别名]
def edit_crm_account(self, **kw):
schema = CrmAccountForm()
try:
form_result = schema.to_python(request.params)
ca = CrmAccount.query.filter(id=form_result["id"]).filter(customer_id=session["customer_id"]).first()
ca.first_name = form_result.get("first_name", "Unknown")
ca.last_name = form_result.get("last_name", "Unknown")
ca.customer = form_result.get("customer")
ca.title = form_result.get("title")
ca.email = form_result.get("email")
ca.address = form_result.get("address")
ca.address_2 = form_result.get("address_2")
ca.city = form_result.get("city")
ca.state = form_result.get("state")
ca.zip = form_result.get("zip")
ca.tel = form_result.get("tel")
ca.tel_ext = form_result.get("tel_ext")
ca.mobile = form_result.get("mobile")
if request.params.has_key("active"):
ca.active = True
else:
ca.active = False
ca.customer_id = session["customer_id"]
ca.user_id = session["user_id"]
ca.crm_campaign_id = form_result.get("crm_campaign_name")
ca.crm_account_status_type_id = form_result.get("status_type_name")
ca.crm_lead_type_id = form_result.get("crm_lead_type_name")
db.add(ca)
db.commit()
db.flush()
except validators.Invalid, error:
return "Error: %s" % error
示例8: delete_conf
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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
示例9: queue_delete
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [as 别名]
def queue_delete(q):
for queue in CallCenterQueue.query.filter(CallCenterQueue.id==q.id).filter(CallCenterQueue.context==session['context']).all():
PbxRoute.query.filter(PbxRoute.pbx_route_type_id==10).filter(PbxRoute.pbx_to_id==queue.id).delete()
CallCenterTier.query.filter(CallCenterTier.queue_id==queue.id).delete()
CallCenterQueue.query.filter(CallCenterQueue.id==q.id).filter(CallCenterQueue.context==session['context']).delete()
db.commit()
db.flush()
return True
示例10: delete_conditions
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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()
示例11: delete_fax_ext
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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
示例12: delete_group
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [as 别名]
def delete_group(name):
for group in PbxGroup.query.filter(PbxGroup.name==name).filter(PbxGroup.context==session['context']).all():
for route in PbxRoute.query.filter(PbxRoute.pbx_route_type_id==4).\
filter(PbxRoute.name==group.name).filter(PbxRoute.context==session['context']).all():
PbxRoute.query.filter(PbxRoute.pbx_route_type_id==4).\
filter(PbxRoute.name==group.name).filter(PbxRoute.context==session['context']).delete()
PbxGroup.query.filter(PbxGroup.name==name).filter(PbxGroup.context==session['context']).delete()
db.commit()
db.flush()
db.remove()
return True
示例13: register_login
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [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()
示例14: del_tier
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [as 别名]
def del_tier(self, **kw):
try:
CallCenterTier.query.filter_by(id=request.params.get("id", 0)).delete()
db.commit()
db.flush()
db.remove()
except:
return "Error deleting tier agent."
return "Successfully deleted tier agent."
示例15: authenticate
# 需要导入模块: from freepybx.model.meta import Session [as 别名]
# 或者: from freepybx.model.meta.Session import commit [as 别名]
def authenticate(username, password):
auth_user = User.query.filter(User.username==username).first()
if not auth_user:
log.debug("No user named: '%s'", username)
return False
elif not auth_user.password:
log.error("Bad user/pass:'%s'")
return False
elif password != auth_user.password:
log.debug("database password for user '%s'", username)
return False
else:
session['username'] = auth_user.username
session['password'] = auth_user.password
session['customer_id'] = auth_user.customer_id
session['user_id'] = auth_user.id
session['name'] = auth_user.first_name+' '+auth_user.last_name
session["last_login"] = auth_user.last_login
session['has_crm'] = auth_user.has_crm
session['customer_name'] = auth_user.get_customer_name(auth_user.customer_id)
if auth_user.has_crm:
ea = auth_user.get_email_account()
session['email_server'] = ea.mail_server
session['email'] = ea.email
session['email_password'] = ea.password
if auth_user.has_call_center():
session['has_call_center'] = True
else:
session['has_call_center'] = False
session['is_agent'] = auth_user.is_agent()
session['context'] = auth_user.get_context()
session['ext'] = auth_user.get_extension()
request.environ["REMOTE_USER"] = auth_user.username
request.environ["HTTP_REMOTE_USER"] = auth_user.username
if auth_user and not auth_user.active:
return False
log.info("authenticated user %s", auth_user.username)
session["perms"] = auth_user.permissions
session['group_id'] = auth_user.group_id
session["user"] = auth_user
session.save()
auth_user.register_login(username, session, request)
db.commit()
db.flush()
return True