Example #1
0
    def get(self, story_uid=None):
        """Get a story or a list of a user's stories"""
        request_args = get_current_request_args()

        user_uid = request_args.get('user_uid')

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

        if story_uid is not None:
            story = Story.get_active(uid=story_uid, has_expired=False)
            if story is None:
                raise ResourceNotFound('Story not found')

            return api_success_response(data=story.as_json())

        todays_stories = Story.prepare_get_active(user_id=user.id).filter_by(
            has_expired=False).all()

        return api_success_response(
            [story.as_json() for story in todays_stories])
Example #2
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()