本文整理匯總了Python中newebe.apps.pictures.models.PictureManager.get_picture方法的典型用法代碼示例。如果您正苦於以下問題:Python PictureManager.get_picture方法的具體用法?Python PictureManager.get_picture怎麽用?Python PictureManager.get_picture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類newebe.apps.pictures.models.PictureManager
的用法示例。
在下文中一共展示了PictureManager.get_picture方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_picture [as 別名]
def post(self, key):
'''
Resend post with *key* as key to the contact given in the posted
JSON. Corresponding activity ID is given inside the posted json.
Here is the format : {"contactId":"data","activityId":"data"}
'''
picture = PictureManager.get_picture(key)
idInfos = self.request.body
ids = json_decode(idInfos)
if picture and idInfos:
contactId = ids["contactId"]
activityId = ids["activityId"]
contact = ContactManager.getTrustedContact(contactId)
activity = ActivityManager.get_activity(activityId)
if not contact:
self.return_failure("Contact not found", 404)
elif not activity:
self.return_failure("Activity not found", 404)
else:
info = "Attemp to resend a picture to contact: {}."
logger.info(info.format(contact.name))
self.forward_to_contact(picture, contact, activity)
else:
self.return_failure("Picture not found", 404)
示例2: ensure_that_picture_date_is_ok_with_time_zone
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_picture [as 別名]
def ensure_that_picture_date_is_ok_with_time_zone(step):
world.date_picture = world.pictures[0]
picture_db = PictureManager.get_picture(world.date_picture["_id"])
date = date_util.convert_utc_date_to_timezone(picture_db.date)
date = date_util.get_db_date_from_date(date)
assert world.date_picture["date"] == date
示例3: get
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_picture [as 別名]
def get(self, id):
'''
Retrieves picture corresponding to id. Returns a 404 response if
picture is not found.
'''
picture = PictureManager.get_picture(id)
if picture:
self.on_picture_found(picture, id)
else:
self.return_failure("Picture not found.", 404)
示例4: get
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_picture [as 別名]
def get(self, id, filename):
"""
Retrieves picture corresponding to id. Returns a 404 response if
picture is not found.
"""
picture = PictureManager.get_picture(id)
if picture:
self.filename = filename
self.on_picture_found(picture, id)
else:
self.return_failure("Picture not found.", 404)
示例5: delete
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_picture [as 別名]
def delete(self, id):
"""
Deletes picture corresponding to id.
"""
picture = PictureManager.get_picture(id)
if picture:
user = UserManager.getUser()
if picture.authorKey == user.key:
self.create_owner_deletion_activity(picture, "deletes", "picture")
self.send_deletion_to_contacts("pictures/contact/", picture)
picture.delete()
self.return_success("Picture deleted.")
else:
self.return_failure("Picture not found.", 404)
示例6: convert
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_picture [as 別名]
def convert(self, data):
'''
Expect to have an attachments field in given dict. When dict has some
attachments, it retrieves corresponding docs and convert them in
attachment dict (same as usual dict with less fields).
Then attach docs are returned inside an array.
'''
docs = []
self.fileDocs = []
for doc in data.get("attachments", []):
if doc["type"] == "Note":
note = NoteManager.get_note(doc["id"])
docs.append(note.toDictForAttachment())
elif doc["type"] == "Picture":
picture = PictureManager.get_picture(doc["id"])
docs.append(picture.toDictForAttachment())
self.fileDocs.append(picture)
return docs
示例7: when_i_get_first_from_its_id
# 需要導入模塊: from newebe.apps.pictures.models import PictureManager [as 別名]
# 或者: from newebe.apps.pictures.models.PictureManager import get_picture [as 別名]
def when_i_get_first_from_its_id(step):
world.picture = PictureManager.get_picture(world.pictures[0]._id)