• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.PictureManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中newebe.apps.pictures.models.PictureManager的典型用法代码示例。如果您正苦于以下问题:Python PictureManager类的具体用法?Python PictureManager怎么用?Python PictureManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PictureManager类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: put

    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)
开发者ID:mpmedia,项目名称:newebe,代码行数:30,代码来源:handlers.py


示例2: post

    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)
开发者ID:mpmedia,项目名称:newebe,代码行数:29,代码来源:handlers.py


示例3: ensure_that_picture_date_is_ok_with_time_zone

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
开发者ID:DopeChicCity,项目名称:newebe,代码行数:8,代码来源:steps.py


示例4: get

 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)
开发者ID:mpmedia,项目名称:newebe,代码行数:10,代码来源:handlers.py


示例5: get

    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)
开发者ID:WentaoXu,项目名称:newebe,代码行数:12,代码来源:handlers.py


示例6: and_one_activity_for_first_picture_with_one_error_for_my_contact

def and_one_activity_for_first_picture_with_one_error_for_my_contact(step):
    author = world.browser.user
    world.contact = world.browser2.user.asContact()
    world.picture = PictureManager.get_last_pictures().first()

    world.activity = Activity(
        author=author.name,
        verb="posts",
        docType="picture",
        docId=world.picture._id,
    )
    world.activity.add_error(world.contact)
    world.activity.save()
开发者ID:DopeChicCity,项目名称:newebe,代码行数:13,代码来源:steps.py


示例7: post

    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)
开发者ID:DopeChicCity,项目名称:newebe,代码行数:50,代码来源:handlers.py


示例8: and_i_add_one_deletion_activity_for_first_picture_with_one_error

def and_i_add_one_deletion_activity_for_first_picture_with_one_error(step):
    author = world.browser.user
    world.contact = world.browser2.user.asContact()
    world.picture = PictureManager.get_last_pictures().first()

    world.activity = Activity(
        author=author.name,
        verb="deletes",
        docType="picture",
        docId=world.picture._id,
        method="PUT"
    )
    date = date_util.get_db_date_from_date(world.picture.date)
    world.activity.add_error(world.contact, extra=date)
    world.activity.save()
开发者ID:DopeChicCity,项目名称:newebe,代码行数:15,代码来源:steps.py


示例9: delete

    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)
开发者ID:WentaoXu,项目名称:newebe,代码行数:16,代码来源:handlers.py


示例10: send_pictures_to_contact

    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:
            if tags_match(picture, contact):
                client.post_files(
                    contact,
                    PICTURE_PATH,
                    {"json": str(picture.toJson(localized=False))},
                    [("picture",
                      str(picture.path),
                      picture.fetch_attachment("th_" + picture.path))
                    ],
                    self.onContactResponse)
开发者ID:DopeChicCity,项目名称:newebe,代码行数:19,代码来源:handlers.py


示例11: convert

    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
开发者ID:DopeChicCity,项目名称:newebe,代码行数:20,代码来源:attach.py


示例12: when_i_get_first_from_its_date_and_author

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))
开发者ID:DopeChicCity,项目名称:newebe,代码行数:4,代码来源:steps.py


示例13: when_i_get_owner_pictures_until_november_1

def when_i_get_owner_pictures_until_november_1(step):
    world.pictures = PictureManager.get_owner_last_pictures(
            "2011-11-01T23:59:00Z").all()
开发者ID:DopeChicCity,项目名称:newebe,代码行数:3,代码来源:steps.py


示例14: clear_all_pictures

def clear_all_pictures(step):
    pictures = PictureManager.get_last_pictures()
    while pictures:
        for picture in pictures:
            picture.delete()
        pictures = PictureManager.get_last_pictures()
开发者ID:DopeChicCity,项目名称:newebe,代码行数:6,代码来源:steps.py


示例15: when_i_get_first_from_its_id

def when_i_get_first_from_its_id(step):
    world.picture = PictureManager.get_picture(world.pictures[0]._id)
开发者ID:DopeChicCity,项目名称:newebe,代码行数:2,代码来源:steps.py


示例16: when_i_get_my_last_pictures

def when_i_get_my_last_pictures(step):
    world.pictures = PictureManager.get_owner_last_pictures().all()
开发者ID:DopeChicCity,项目名称:newebe,代码行数:2,代码来源:steps.py



注:本文中的newebe.apps.pictures.models.PictureManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.UserManager类代码示例发布时间:2022-05-27
下一篇:
Python models.ContactManager类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap