Exemplo n.º 1
0
    def post_comment(self, slug):
        post = self.post_service.get_by_slug(slug)
        if not post:
            return self.theme_render('404.html', page_title='Not Found')

        if post and not post.allow_comment:
            return self.redirect(self.reverse_url('site_post', slug))

        p = self.get_argument
        name = p('name', default='')
        email = p('email', default='')
        content = p('content', default='')

        name, content, email = name.strip(), content.strip(), email.strip()

        validator = Validator()
        (validator.check(email, 'email', text('comment.email_missing'))
            .check(content, 'min', text('comment.email_missing'), 1)
         )

        if validator.errors:
            self.flash(validator.errors, 'error')
            return redirect(self.reverse_url('site_post', slug))

        status = site.get(
            'auto_published_comments', False) and 'approved' or 'pending'
        self.comment_service.add_comment(name, email, content, status, post)

        self.redirect(self.reverse_url('site_post', slug))
Exemplo n.º 2
0
    def post_comment(self, slug):
        post = self.post_service.get_by_slug(slug)
        if not post:
            return self.theme_render('404.html', page_title='Not Found')

        if post and not post.allow_comment:
            return self.redirect(self.reverse_url('site_post', slug))

        p = self.get_argument
        name = p('name', default='')
        email = p('email', default='')
        content = p('content', default='')

        name, content, email = name.strip(), content.strip(), email.strip()

        validator = Validator()
        (validator.check(email, 'email', text('comment.email_missing')).check(
            content, 'min', text('comment.email_missing'), 1))

        if validator.errors:
            self.flash(validator.errors, 'error')
            return redirect(self.reverse_url('site_post', slug))

        status = site.get('auto_published_comments',
                          False) and 'approved' or 'pending'
        self.comment_service.add_comment(name, email, content, status, post)

        self.redirect(self.reverse_url('site_post', slug))
Exemplo n.º 3
0
    def get(self, slug=None):
        if slug:
            if slug == "admin":
                return self.post_admin_page()
            elif slug == "search":
                return self.search()
            elif slug == "rss":
                return self.feed_rss()

            slug = slug.split("/")[-1]
            page = self.page_service.get_by_slug(slug)
        else:
            site_page = site.get("site_page", 0)
            if site_page == 0:
                return self.posts()
            else:
                page = self.page_service.get(site_page)

        if not page:
            self.notfound()
        self.theme_render("page.html", page_content=page.content, page_title=page.title, page=page)
Exemplo n.º 4
0
    def get(self, slug=None):
        if slug:
            if slug == 'admin':
                return self.post_admin_page()
            elif slug == 'search':
                return self.search()
            elif slug == 'rss':
                return self.feed_rss()

            slug = slug.split('/')[-1]
            page = self.page_service.get_by_slug(slug)
        else:
            site_page = site.get('site_page', 0)
            if site_page == 0:
                return self.posts()
            else:
                page = self.page_service.get(site_page)

        if not page:
            self.notfound()
        self.theme_render('page.html',
                          page_content=page.content,
                          page_title=page.title,
                          page=page)