本文整理汇总了Python中newebe.contacts.models.ContactManager.getContact方法的典型用法代码示例。如果您正苦于以下问题:Python ContactManager.getContact方法的具体用法?Python ContactManager.getContact怎么用?Python ContactManager.getContact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newebe.contacts.models.ContactManager
的用法示例。
在下文中一共展示了ContactManager.getContact方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getContact [as 别名]
def post(self):
'''
Updates contact from sent data (contact object at JSON format).
Sets its status to Trusted.
'''
data = self.get_body_as_dict(expectedFields=["url", "key", "name"])
if data:
url = data["url"]
slug = slugify(url)
contact = ContactManager.getContact(slug)
if contact:
contact.state = STATE_TRUSTED
contact.key = data["key"]
contact.name = data["name"]
contact.save()
self.return_success("Contact trusted.")
else:
self.return_failure("No contact for this slug.", 400)
else:
self.return_failure("Sent data are incorrects.", 400)
示例2: get
# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getContact [as 别名]
def get(self, slug):
'''
Retrieves contact corresponding to slug at JSON format.
'''
contact = ContactManager.getContact(slug)
self.return_one_document_or_404(contact, "Contact does not exist.")
示例3: delete
# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getContact [as 别名]
def delete(self, slug):
'''
Deletes contact corresponding to slug.
'''
contact = ContactManager.getContact(slug)
if contact:
contact.delete()
return self.return_success("Contact has been deleted.")
else:
self.return_failure("Contact does not exist.")
示例4: put
# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getContact [as 别名]
def put(self, slug):
'''
Grab tags sent inside request to set is on contact matching slug.
'''
contact = ContactManager.getContact(slug)
data = self.get_body_as_dict(["tags"])
if contact:
if data:
contact.tags = data["tags"]
contact.save()
else:
self.return_failure("No tags were sent")
else:
self.return_failure("Contact to modify does not exist.", 404)
示例5: checks_that_default_contact_data_are_updated
# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getContact [as 别名]
def checks_that_default_contact_data_are_updated(step):
contact = ContactManager.getContact(slugify(u"http://default:8000/"))
assert "http://default:8010/" == contact.url
assert "default contact 2" == contact.name
assert "desc 2" == contact.description
示例6: change_default_contact_data_through_handlers
# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getContact [as 别名]
def change_default_contact_data_through_handlers(step):
contact = ContactManager.getContact(slugify(u"http://default:8000/"))
contact.description = "desc 2"
contact.url = u"http://default:8010/"
contact.name = "default contact 2"
world.browser.put("contacts/update-profile/", contact.toJson())
示例7: get_contact_with_slug
# 需要导入模块: from newebe.contacts.models import ContactManager [as 别名]
# 或者: from newebe.contacts.models.ContactManager import getContact [as 别名]
def get_contact_with_slug(step, slug):
world.contact = ContactManager.getContact(slug)