def send_pictures_to_contact(self, client, contact, now, date): ''' Send pictures from last month to given contact. ''' pictures = PictureManager.get_owner_last_pictures( startKey=date_util.get_db_date_from_date(now), endKey=date_util.get_db_date_from_date(date)) for picture in pictures: client.post_files(contact, PICTURE_PATH, { "json": str(picture.toJson(localized=False)) }, [("picture", str(picture.path), picture.fetch_attachment("th_" + picture.path))] , self.onContactResponse)
def post(self): ''' When a post request is sent, the newebe downloads full size version of picture specified in the request from the contact also specified in the request. ''' data = self.get_body_as_dict() contact = ContactManager.getTrustedContact(data["contact"]["key"]) if contact: date = data["picture"]["date"] picture = PictureManager.get_owner_last_pictures(date).first() if picture: self.on_picture_found(picture, id) else: logger.info("Picture no more available.") self.return_failure("Picture not found.", 404) else: logger.info("Contact unknown") self.return_failure("Picture not found", 404)
def when_i_get_owner_pictures_until_november_1(step): world.pictures = PictureManager.get_owner_last_pictures( "2011-11-01T23:59:00Z").all()
def when_i_get_my_last_pictures(step): world.pictures = PictureManager.get_owner_last_pictures().all()