本文整理汇总了Python中corehq.apps.sms.models.CallLog.answered_call_exists方法的典型用法代码示例。如果您正苦于以下问题:Python CallLog.answered_call_exists方法的具体用法?Python CallLog.answered_call_exists怎么用?Python CallLog.answered_call_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.models.CallLog
的用法示例。
在下文中一共展示了CallLog.answered_call_exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fire_ivr_survey_event
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import answered_call_exists [as 别名]
def fire_ivr_survey_event(reminder, handler, recipients, verified_numbers):
if handler.recipient == RECIPIENT_CASE:
# If there are no recipients, just move to the next reminder event
if len(recipients) == 0:
return True
# If last_fired is None, it means that the reminder fired for the first time on a timeout interval. So we can
# skip the lookup for the answered call since no call went out yet.
if reminder.last_fired is not None and reminder.callback_try_count > 0 and CallLog.answered_call_exists(recipients[0].doc_type, recipients[0].get_id, reminder.last_fired):
reminder.skip_remaining_timeouts = True
return True
verified_number = verified_numbers[recipients[0].get_id]
if verified_number is not None:
if initiate_outbound_call(verified_number, reminder.current_event.form_unique_id, handler.submit_partial_forms, handler.include_case_side_effects, handler.max_question_retries):
return True
else:
reminder = CaseReminder.get(reminder._id)
reminder.error_retry_count += 1
if reminder.error_retry_count > getattr(settings, "IVR_OUTBOUND_RETRIES", DEFAULT_OUTBOUND_RETRIES):
return True
else:
reminder.next_fire += timedelta(minutes=getattr(settings, "IVR_OUTBOUND_RETRY_INTERVAL", DEFAULT_OUTBOUND_RETRY_INTERVAL))
reminder.save()
return False
else:
raise_error(reminder, ERROR_NO_VERIFIED_NUMBER)
return False
else:
# TODO: Implement ivr survey for RECIPIENT_USER, RECIPIENT_OWNER, and RECIPIENT_SURVEY_SAMPLE
return False
示例2: fire_ivr_survey_event
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import answered_call_exists [as 别名]
def fire_ivr_survey_event(reminder, handler, recipients, verified_numbers, logged_event):
domain_obj = Domain.get_by_name(reminder.domain, strict=True)
for recipient in recipients:
initiate_call = True
if reminder.callback_try_count > 0 and reminder.event_initiation_timestamp:
initiate_call = not CallLog.answered_call_exists(
recipient.doc_type, recipient.get_id,
reminder.event_initiation_timestamp,
CaseReminderHandler.get_now())
if initiate_call:
if (isinstance(recipient, CommCareCase) and
not handler.force_surveys_to_use_triggered_case):
case_id = recipient.get_id
else:
case_id = reminder.case_id
verified_number, unverified_number = get_recipient_phone_number(
reminder, recipient, verified_numbers)
if verified_number:
initiate_outbound_call.delay(
recipient,
reminder.current_event.form_unique_id,
handler.submit_partial_forms,
handler.include_case_side_effects,
handler.max_question_retries,
logged_event.pk,
verified_number=verified_number,
case_id=case_id,
case_for_case_submission=handler.force_surveys_to_use_triggered_case,
timestamp=CaseReminderHandler.get_now(),
)
elif domain_obj.send_to_duplicated_case_numbers and unverified_number:
initiate_outbound_call.delay(
recipient,
reminder.current_event.form_unique_id,
handler.submit_partial_forms,
handler.include_case_side_effects,
handler.max_question_retries,
logged_event.pk,
unverified_number=unverified_number,
case_id=case_id,
case_for_case_submission=handler.force_surveys_to_use_triggered_case,
timestamp=CaseReminderHandler.get_now(),
)
else:
# initiate_outbound_call will create the subevent automatically,
# so since we're not initiating the call here, we have to create
# the subevent explicitly in order to log the error.
logged_subevent = logged_event.create_subevent(handler, reminder, recipient)
logged_subevent.error(MessagingEvent.ERROR_NO_PHONE_NUMBER)
示例3: fire_ivr_survey_event
# 需要导入模块: from corehq.apps.sms.models import CallLog [as 别名]
# 或者: from corehq.apps.sms.models.CallLog import answered_call_exists [as 别名]
def fire_ivr_survey_event(reminder, handler, recipients, verified_numbers):
domain_obj = Domain.get_by_name(reminder.domain, strict=True)
for recipient in recipients:
initiate_call = True
if reminder.callback_try_count > 0 and reminder.event_initiation_timestamp:
initiate_call = not CallLog.answered_call_exists(
recipient.doc_type, recipient.get_id,
reminder.event_initiation_timestamp,
CaseReminderHandler.get_now())
if initiate_call:
if (isinstance(recipient, CommCareCase) and
not handler.force_surveys_to_use_triggered_case):
case_id = recipient.get_id
else:
case_id = reminder.case_id
verified_number, unverified_number = get_recipient_phone_number(
reminder, recipient, verified_numbers)
if verified_number:
initiate_outbound_call.delay(
recipient,
reminder.current_event.form_unique_id,
handler.submit_partial_forms,
handler.include_case_side_effects,
handler.max_question_retries,
verified_number=verified_number,
case_id=case_id,
case_for_case_submission=handler.force_surveys_to_use_triggered_case,
timestamp=CaseReminderHandler.get_now(),
)
elif domain_obj.send_to_duplicated_case_numbers and unverified_number:
initiate_outbound_call.delay(
recipient,
reminder.current_event.form_unique_id,
handler.submit_partial_forms,
handler.include_case_side_effects,
handler.max_question_retries,
unverified_number=unverified_number,
case_id=case_id,
case_for_case_submission=handler.force_surveys_to_use_triggered_case,
timestamp=CaseReminderHandler.get_now(),
)
else:
#No phone number to send to
pass
return True