コード例 #1
0
    def delete(self, username):
        user = User.get_active(username=username)
        if user is None:
            raise ResourceNotFound('User not found')

        user.delete()

        return api_deleted_response()
コード例 #2
0
    def delete(self, collection_uid):
        """Delete a collection"""
        collection = Collection.get_active(collection_uid)
        if collection is None:
            raise ResourceNotFound('Collection not found')

        collection.delete()

        return api_deleted_response()
コード例 #3
0
    def delete(self, conversation_uid):
        """Delete a conversation"""
        conversation = Conversation.get_not_deleted(uid=conversation_uid)

        if conversation is None:
            raise ResourceNotFound('Conversation not found')

        conversation.delete()

        return api_deleted_response()
コード例 #4
0
    def delete(self, hash_tag):
        """Unfollow a hash tag"""
        user = get_current_user()

        to_unfollow = HashTag.get_active(entity=hash_tag)
        if to_unfollow is None:
            raise ResourceNotFound('Hash tag not found')

        user.hash_tags_followed.remove(to_unfollow)

        return api_deleted_response()
コード例 #5
0
    def delete(self, user_uid):
        """Unfollow a user"""
        user = get_current_user()

        to_unfollow = User.get_active(uid=user_uid)
        if to_unfollow is None:
            raise ResourceNotFound('User not found')

        user.followed.remove(to_unfollow)

        return api_deleted_response()
コード例 #6
0
    def delete(self, post_uid):
        """Delete a post"""
        post = Post.get_active(uid=post_uid)
        if post is None:
            raise ResourceNotFound('Post not found')

        if post.user != get_current_user():
            raise UnauthorizedError()

        post.delete()

        return api_deleted_response()
コード例 #7
0
    def delete(self, story_uid):
        """Delete a slide from a user's story"""
        story = Story.get_active(uid=story_uid)
        if story is None:
            raise ResourceNotFound('Story not found')

        if story.user != get_current_user():
            raise UnauthorizedError()

        story.delete()

        return api_deleted_response()
コード例 #8
0
    def delete(self, collection_uid, post_uid):
        """Remove a post from a collection"""
        collection = Collection.get_not_deleted(uid=collection_uid)
        if collection is None:
            raise ResourceNotFound('Collection not found')

        post = Post.get_not_deleted(uid=post_uid)
        if post is None:
            raise ResourceNotFound('Post not found')

        if post.collection_id != collection.id:
            raise ResourceNotFound('Post not found')

        post.update(collection_id=None)

        return api_deleted_response()