本文整理汇总了Python中apostello.models.Keyword.get_log_link方法的典型用法代码示例。如果您正苦于以下问题:Python Keyword.get_log_link方法的具体用法?Python Keyword.get_log_link怎么用?Python Keyword.get_log_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apostello.models.Keyword
的用法示例。
在下文中一共展示了Keyword.get_log_link方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_incoming_sms
# 需要导入模块: from apostello.models import Keyword [as 别名]
# 或者: from apostello.models.Keyword import get_log_link [as 别名]
def import_incoming_sms():
"""
Loops over all incoming messages in Twilio's logs and adds them to our db.
"""
try:
sms_page = twilio_client.messages.iter(to_=settings.TWILIO_FROM_NUM)
for x in sms_page:
try:
sms, created = SmsInbound.objects.get_or_create(
sid=x.sid,
time_received=timezone.now()
)
if created:
sender, s_created = Recipient.objects.get_or_create(number=x.from_)
if s_created:
sender.first_name = 'Unknown'
sender.last_name = 'Person'
sender.save()
sms.content = x.body
sms.time_received = timezone.make_aware(x.date_sent, timezone.get_current_timezone())
sms.sender_name = str(sender)
sms.sender_num = x.from_
matched_keyword = Keyword.match(x.body)
sms.matched_keyword = str(matched_keyword)
sms.matched_colour = Keyword.lookup_colour(x.body)
sms.matched_link = Keyword.get_log_link(matched_keyword)
sms.save()
except Exception as e:
print(e)
except TwilioRestException as e:
if e.code == 20008:
return 'test credentials used'
示例2: log_msg_in
# 需要导入模块: from apostello.models import Keyword [as 别名]
# 或者: from apostello.models.Keyword import get_log_link [as 别名]
def log_msg_in(p, t, from_pk):
from apostello.models import Keyword, SmsInbound, Recipient
from_ = Recipient.objects.get(pk=from_pk)
matched_keyword = Keyword.match(p['Body'].strip())
SmsInbound.objects.create(sid=p['MessageSid'],
content=p['Body'],
time_received=t,
sender_name=str(from_),
sender_num=p['From'],
matched_keyword=str(matched_keyword),
matched_link=Keyword.get_log_link(matched_keyword),
matched_colour=Keyword.lookup_colour(p['Body'].strip()))
# check log is consistent:
check_log_consistent.delay(0)
示例3: handle_incoming_sms
# 需要导入模块: from apostello.models import Keyword [as 别名]
# 或者: from apostello.models.Keyword import get_log_link [as 别名]
def handle_incoming_sms(msg):
"""Add incoming sms to log."""
sms, created = SmsInbound.objects.get_or_create(sid=msg.sid)
if created:
check_next_page = True
sender, s_created = Recipient.objects.get_or_create(number=msg.from_)
if s_created:
sender.first_name = 'Unknown'
sender.last_name = 'Person'
sender.save()
sms.content = msg.body
sms.time_received = timezone.make_aware(
msg.date_created, timezone.get_current_timezone()
)
sms.sender_name = str(sender)
sms.sender_num = msg.from_
matched_keyword = Keyword.match(msg.body)
sms.matched_keyword = str(matched_keyword)
sms.matched_colour = Keyword.lookup_colour(msg.body)
sms.matched_link = Keyword.get_log_link(matched_keyword)
sms.save()
return check_next_page
示例4: test_get_log_link_str
# 需要导入模块: from apostello.models import Keyword [as 别名]
# 或者: from apostello.models.Keyword import get_log_link [as 别名]
def test_get_log_link_str(self, keywords):
assert Keyword.get_log_link('test_no_link') == '#'
示例5: test_get_log_link_keyword
# 需要导入模块: from apostello.models import Keyword [as 别名]
# 或者: from apostello.models.Keyword import get_log_link [as 别名]
def test_get_log_link_keyword(self, keywords):
assert Keyword.get_log_link(
keywords['test']
) == '/keyword/responses/{0}/'.format(keywords['test'].pk)