コード例 #1
0
ファイル: views.py プロジェクト: KohTseh/maple-blog
def comment(id):
    '''评论表单'''
    if not writer_permission.can():
        flash(_('You have not confirm your account'))
        return redirect(url_for('blog.index_num'))
    form = CommentForm()
    if form.validate_on_submit() and request.method == "POST":
        post_comment = Comments(author=current_user.username,
                                content=form.comment.data)
        post_comment.articles_id = id
        post_comment.publish = datetime.now()
        db.session.add(post_comment)
        db.session.commit()
        return redirect(url_for('blog.view', id=id, _anchor='comment'))
    return redirect(url_for('blog.view', id=id, _anchor='comment'))
コード例 #2
0
ファイル: views.py プロジェクト: mzcyx/maple-blog
def comment(id):
    '''评论表单'''
    if not writer_permission.can():
        flash(_('You have not confirm your account'))
        return redirect(url_for('blog.index_num'))
    form = CommentForm()
    if form.validate_on_submit() and request.method == "POST":
        post_comment = Comments(author=current_user.name,
                                content=form.comment.data)
        post_comment.articles_id = id
        post_comment.publish = datetime.now()
        db.session.add(post_comment)
        db.session.commit()
        return redirect(url_for('blog.view', id=id, _anchor='comment'))
    return redirect(url_for('blog.view', id=id, _anchor='comment'))
コード例 #3
0
ファイル: views.py プロジェクト: honmaple/maple-blog
class CommentListView(BaseView):
    # form = CommentForm()

    def __init__(self):
        super(MethodView, self).__init__()
        self.form = CommentForm()

    @cache.cached(timeout=180, key_prefix=cache_key)
    def get(self, blogId):
        page, number = self.get_page_info()
        filter_dict = {}
        filter_dict.update(blog_id=blogId)
        comments = Comment.get_list(page, number, filter_dict)
        data = {'comments': comments, 'form': self.form}
        return render_template('blog/commentlist.html', **data)

    @login_required
    def post(self, blogId):
        if not writer_permission.can():
            flash(_('You have not confirm your account'))
            return redirect(url_for('blog.blog', blogId=blogId))
        if self.form.validate_on_submit():
            comment = Comment()
            comment.author = current_user
            comment.content = self.form.content.data
            comment.blog_id = blogId
            db.session.add(comment)
            db.session.commit()
            return redirect(
                url_for(
                    'blog.blog', blogId=blogId, _anchor='blog-comment'))
        return redirect(
            url_for(
                'blog.blog', blogId=blogId, _anchor='blog-comment'))
コード例 #4
0
ファイル: views.py プロジェクト: light0011/maple-blog
 def post(self, blogId):
     user = request.user
     form = CommentForm()
     if form.validate_on_submit():
         comment = Comment()
         comment.content = form.content.data
         comment.blog_id = blogId
         comment.author = user
         db.session.add(comment)
         db.session.commit()
         return redirect(
             url_for(
                 'blog.blog', blogId=blogId, _anchor='blog-comment'))
     return redirect(
         url_for(
             'blog.blog', blogId=blogId, _anchor='blog-comment'))
コード例 #5
0
ファイル: views.py プロジェクト: bigfreecoder/maple-blog
class CommentListView(MethodView):
    # form = CommentForm()

    def __init__(self):
        super(MethodView, self).__init__()
        self.form = CommentForm()

    def get(self, blogId):
        page = request.args.get('page', 1, type=int)
        filter_dict = {}
        filter_dict.update(blog_id=blogId)
        comments = Comment.get_comment_list(page, filter_dict)
        data = {'comments': comments, 'form': self.form}
        return render_template('blog/commentlist.html', **data)

    @login_required
    def post(self, blogId):
        if not writer_permission.can():
            flash(_('You have not confirm your account'))
            return redirect(url_for('blog.blog', blogId=blogId))
        if self.form.validate_on_submit():
            comment = Comment()
            comment.author = current_user
            comment.content = self.form.content.data
            comment.blog_id = blogId
            db.session.add(comment)
            db.session.commit()
            return redirect(
                url_for('blog.blog', blogId=blogId, _anchor='blog-comment'))
        return redirect(
            url_for('blog.blog', blogId=blogId, _anchor='blog-comment'))
コード例 #6
0
ファイル: views.py プロジェクト: KohTseh/maple-blog
def view(id):
    '''记录用户浏览次数'''
    redis_data.zincrby('visited:article', 'article:%s' % str(id), 1)
    comment_form = CommentForm()
    article = Articles.load_by_id(id)
    tags = article.tags
    return render_template('blog/blog_page.html',
                           article=article,
                           tags=tags,
                           comment_form=comment_form)
コード例 #7
0
def view(id):
    '''记录用户浏览次数'''
    redis_data.zincrby('visited:article', 'article:%s' % str(id), 1)
    comment_form = CommentForm()
    reply_form = ReplyForm()
    article = Articles.load_by_id(id)
    all_tags = Tags.query.distinct(Tags.name).all()
    tags = article.tags
    return render_template('blog/blog_page.html',
                           article=article,
                           all_tags=all_tags,
                           tags=tags,
                           comment_form=comment_form,
                           reply_form=reply_form)
コード例 #8
0
ファイル: views.py プロジェクト: honmaple/maple-blog
 def __init__(self):
     super(MethodView, self).__init__()
     self.form = CommentForm()
コード例 #9
0
ファイル: views.py プロジェクト: bigfreecoder/maple-blog
 def __init__(self):
     super(MethodView, self).__init__()
     self.form = CommentForm()