本文整理汇总了Python中corehq.apps.sms.models.PhoneNumber.by_extensive_search方法的典型用法代码示例。如果您正苦于以下问题:Python PhoneNumber.by_extensive_search方法的具体用法?Python PhoneNumber.by_extensive_search怎么用?Python PhoneNumber.by_extensive_search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.models.PhoneNumber
的用法示例。
在下文中一共展示了PhoneNumber.by_extensive_search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ivr_in
# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_extensive_search [as 别名]
def ivr_in(request):
"""
Handles tropo call requests
"""
if request.method == "POST":
data = json.loads(request.body)
phone_number = data["session"]["from"]["id"]
# TODO: Implement tropo as an ivr backend. In the meantime, just log the call.
if phone_number:
cleaned_number = strip_plus(phone_number)
v = PhoneNumber.by_extensive_search(cleaned_number)
else:
v = None
# Save the call entry
msg = Call(
phone_number=cleaned_number,
direction=INCOMING,
date=datetime.utcnow(),
backend_api=SQLTropoBackend.get_api_id(),
)
if v is not None:
msg.domain = v.domain
msg.couch_recipient_doc_type = v.owner_doc_type
msg.couch_recipient = v.owner_id
msg.save()
t = Tropo()
t.reject()
return HttpResponse(t.RenderJson())
else:
return HttpResponseBadRequest("Bad Request")
示例2: log_call
# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_extensive_search [as 别名]
def log_call(phone_number, gateway_session_id, backend=None):
cleaned_number = strip_plus(phone_number)
v = PhoneNumber.by_extensive_search(cleaned_number)
call = Call(
phone_number=cleaned_number,
direction=INCOMING,
date=datetime.utcnow(),
backend_api=backend.get_api_id() if backend else None,
backend_id=backend.couch_id if backend else None,
gateway_session_id=gateway_session_id,
)
if v:
call.domain = v.domain
call.couch_recipient_doc_type = v.owner_doc_type
call.couch_recipient = v.owner_id
call.save()
示例3: test_extensive_search
# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import by_extensive_search [as 别名]
def test_extensive_search(self):
number = PhoneNumber.objects.create(
domain=self.domain,
owner_doc_type='X',
owner_id='X',
phone_number='999123',
verified=True
)
self.assertEqual(PhoneNumber.by_extensive_search('999123'), number)
self.assertEqual(PhoneNumber.by_extensive_search('0999123'), number)
self.assertEqual(PhoneNumber.by_extensive_search('00999123'), number)
self.assertEqual(PhoneNumber.by_extensive_search('000999123'), number)
self.assertEqual(PhoneNumber.by_extensive_search('123'), number)
self.assertIsNone(PhoneNumber.by_extensive_search('999124'), number)