本文整理汇总了Python中corehq.apps.sms.models.PhoneNumber.get_reserved_number方法的典型用法代码示例。如果您正苦于以下问题:Python PhoneNumber.get_reserved_number方法的具体用法?Python PhoneNumber.get_reserved_number怎么用?Python PhoneNumber.get_reserved_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.models.PhoneNumber
的用法示例。
在下文中一共展示了PhoneNumber.get_reserved_number方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_inbound_phone_entry
# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import get_reserved_number [as 别名]
def get_inbound_phone_entry(msg):
if msg.backend_id:
backend = SQLMobileBackend.load(msg.backend_id, is_couch_id=True)
if not backend.is_global and toggles.INBOUND_SMS_LENIENCY.enabled(backend.domain):
p = PhoneNumber.get_two_way_number_with_domain_scope(msg.phone_number, backend.domains_with_access)
return (
p,
p is not None
)
return (
PhoneNumber.get_reserved_number(msg.phone_number),
False
)
示例2: initiate_sms_verification_workflow
# 需要导入模块: from corehq.apps.sms.models import PhoneNumber [as 别名]
# 或者: from corehq.apps.sms.models.PhoneNumber import get_reserved_number [as 别名]
def initiate_sms_verification_workflow(contact, phone_number):
# For now this is only applicable to mobile workers
assert isinstance(contact, CommCareUser)
phone_number = apply_leniency(phone_number)
logged_event = MessagingEvent.get_current_verification_event(
contact.domain, contact.get_id, phone_number)
p = PhoneNumber.get_reserved_number(phone_number)
if p:
if p.owner_id != contact.get_id:
return VERIFICATION__ALREADY_IN_USE
if p.verified:
return VERIFICATION__ALREADY_VERIFIED
else:
result = VERIFICATION__RESENT_PENDING
else:
entry = contact.get_or_create_phone_entry(phone_number)
try:
entry.set_pending_verification()
except PhoneNumberInUseException:
# On the off chance that the phone number was reserved between
# the check above and now
return VERIFICATION__ALREADY_IN_USE
result = VERIFICATION__WORKFLOW_STARTED
# Always create a new event when the workflow starts
if logged_event:
logged_event.status = MessagingEvent.STATUS_NOT_COMPLETED
logged_event.save()
logged_event = MessagingEvent.create_verification_event(contact.domain, contact)
if not logged_event:
logged_event = MessagingEvent.create_verification_event(contact.domain, contact)
send_verification(contact.domain, contact, phone_number, logged_event)
return result