本文整理汇总了Python中models.Contact.getByPhoneNumber方法的典型用法代码示例。如果您正苦于以下问题:Python Contact.getByPhoneNumber方法的具体用法?Python Contact.getByPhoneNumber怎么用?Python Contact.getByPhoneNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Contact
的用法示例。
在下文中一共展示了Contact.getByPhoneNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import getByPhoneNumber [as 别名]
def post(self):
user = json.loads(self.request.body)
if not phonenumberutils.validateNumber(user['phoneNumber']):
raise errors.ValidationError("Invalid phone number.")
#return validationError(self.response, 'Invalid number ' + user['phoneNumber'])
if not user['name']:
raise errors.ValidationError("Name is required.")
# Make sure we're not duplicating another contact
existingContact = Contact.getByName(user['name'])
if existingContact:
raise errors.ValidationError('User already exists with name ' + user['name'])
existingContact = Contact.getByPhoneNumber(user['phoneNumber'])
if existingContact:
raise errors.ValidationError('User ' + existingContact.name +
' already exists with number ' + existingContact.phoneNumber)
logging.info("Creating contact " + user["name"])
contact = Contact(
name = user['name'].lower(),
phoneNumber = phonenumberutils.toPrettyNumber(user['phoneNumber']),
normalizedPhoneNumber = phonenumberutils.toNormalizedNumber(user['phoneNumber']))
Contact.update(contact)
xmppVoiceMail.sendXmppInvite(contact.name)
self.response.headers['Content-Type'] = 'application/json'
self.response.write(json.dumps(contact.toDict()))
示例2: getDisplayNameAndContact
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import getByPhoneNumber [as 别名]
def getDisplayNameAndContact(self, number):
displayName = toPrettyNumber(number)
# Find the XMPP user to send this from
contact = Contact.getByPhoneNumber(number)
if contact:
displayName = contact.name
else:
contact = Contact.getDefaultSender()
return (displayName, contact)
示例3: handleIncomingCall
# 需要导入模块: from models import Contact [as 别名]
# 或者: from models.Contact import getByPhoneNumber [as 别名]
def handleIncomingCall(self, fromNumber, callStatus):
"""Handle an incoming call.
"""
displayFrom = toPrettyNumber(fromNumber)
# Find the XMPP user to send this from
contact = Contact.getByPhoneNumber(fromNumber)
if contact:
displayFrom = contact.name
else:
contact = Contact.getDefaultSender()
self.sendMessageToOwner("Call from: " + displayFrom + " status:" + callStatus, contact, fromNumber)