def store(self, request: Request):
        title = request.input('title')
        body = request.input('body')

        Post.create(title=title, body=body, author_id=1)

        return request.redirect('/blog')
    def create(self, Request, Upload):
        """ Create new post """

        if not Auth(Request).user():
            Request.redirect('/dashboard')

        # Make slug
        slug = slugify(Request.input('title'))

        # Save image
        try:
            image = Upload.driver('s3').store_prepend(
                Request.input('file_upload'), 'blog/img/')
        except AttributeError:
            # If user did not pick image, set image to none. (Load default)
            image = "nightlife1.jpg"

        Post.create(title=remove_whitespaces(Request.input('title')),
                    slug=slug,
                    category=remove_whitespaces(Request.input('category')),
                    body=remove_whitespaces(Request.input('body')),
                    image=image,
                    author_id=Request.user().id,
                    is_live=1)

        return Request.redirect('dashboard/blog', {'Auth': Auth(Request)})
Example #3
0
    def store(self, request: Request):
        # New store Method
        Post.create(title=request.input('title'),
                    image='no img',
                    body=request.input('body'),
                    author_id=request.user().id)

        return 'post created'
    def store(self):
        Post.create(
            title=request().input('title'),
            body=request().input('body'),
            author_id=request().user().id
        )

        return 'Post created'
    def store(self, request: Request):
        Post.create(title=request.input('title'),
                    body=request.input('body'),
                    author_id=request.user().id)

        return 'post created'