本文整理匯總了Python中newebe.apps.pictures.models.PictureManager.get_contact_picture方法的典型用法代碼示例。如果您正苦於以下問題:Python PictureManager.get_contact_picture方法的具體用法?Python PictureManager.get_contact_picture怎麽用?Python PictureManager.get_contact_picture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類newebe.apps.pictures.models.PictureManager
的用法示例。
在下文中一共展示了PictureManager.get_contact_picture方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: put
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_contact_picture [as 別名]
def put(self):
'''
Delete picture of which data are given inside request.
Picture is found with contact key and creation date.
If author is not inside trusted contacts, the request is rejected.
'''
data = self.get_body_as_dict()
if data:
contact = ContactManager.getTrustedContact(
data.get("authorKey", ""))
if contact:
picture = PictureManager.get_contact_picture(
contact.key, data.get("date", ""))
if picture:
self.create_deletion_activity(contact,
picture, "deletes", "picture")
picture.delete()
self.return_success("Deletion succeeds")
else:
self.return_failure("Author is not trusted.", 400)
else:
self.return_failure("No data sent.", 405)
示例2: post
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_contact_picture [as 別名]
def post(self):
'''
Extract picture and file linked to the picture from request, then
creates a picture in database for the contact who sends it. An
activity is created too.
If author is not inside trusted contacts, the request is rejected.
'''
file = self.request.files['picture'][0]
data = json_decode(self.get_argument("json"))
if file and data:
contact = ContactManager.getTrustedContact(
data.get("authorKey", ""))
if contact:
date = date_util.get_date_from_db_date(data.get("date", ""))
picture = PictureManager.get_contact_picture(
contact.key, data.get("date", ""))
if not picture:
picture = Picture(
_id=data.get("_id", ""),
title=data.get("title", ""),
path=data.get("path", ""),
contentType=data.get("contentType", ""),
authorKey=data.get("authorKey", ""),
author=data.get("author", ""),
tags=contact.tags,
date=date,
isMine=False,
isFile=False
)
picture.save()
picture.put_attachment(content=file["body"],
name="th_" + picture._id)
picture.save()
self.create_creation_activity(contact,
picture, "publishes", "picture")
logger.info("New picture from %s" % contact.name)
self.return_success("Creation succeeds", 201)
else:
self.return_failure("Author is not trusted.", 400)
else:
self.return_failure("No data sent.", 405)
示例3: when_i_get_first_from_its_date_and_author
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_contact_picture [as 別名]
def when_i_get_first_from_its_date_and_author(step):
picture = world.pictures[0]
world.picture = PictureManager.get_contact_picture(picture.authorKey,
date_util.get_db_date_from_date(picture.date))