本文整理汇总了Python中temba.contacts.models.Contact.all方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.all方法的具体用法?Python Contact.all怎么用?Python Contact.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类temba.contacts.models.Contact
的用法示例。
在下文中一共展示了Contact.all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_spam
# 需要导入模块: from temba.contacts.models import Contact [as 别名]
# 或者: from temba.contacts.models.Contact import all [as 别名]
def send_spam(user_id, contact_id): # pragma: no cover
"""
Processses a single incoming message through our queue.
"""
from django.contrib.auth.models import User
from temba.contacts.models import Contact, TEL_SCHEME
from temba.msgs.models import Broadcast
contact = Contact.all().get(pk=contact_id)
user = User.objects.get(pk=user_id)
channel = contact.org.get_send_channel(TEL_SCHEME)
if not channel: # pragma: no cover
print("Sorry, no channel to be all spammy with")
return
long_text = (
"Test Message #%d. The path of the righteous man is beset on all sides by the iniquities of the "
"selfish and the tyranny of evil men. Blessed is your face."
)
# only trigger sync on the last one
for idx in range(10):
broadcast = Broadcast.create(contact.org, user, long_text % (idx + 1), contacts=[contact])
broadcast.send(trigger_send=(idx == 149))