Пример #1
0
def user_passwd_edit(post_id):
    error = None
    if not writer_permission.can():
        error = u'你没有验证账户,不能修改密码,请尽快验证账户.'
        return jsonify(judge=False, error=error)
    form = EditPasswdForm()
    action = EditManager(post_id, form)
    if form.validate_on_submit() and request.method == "POST":
        user = User.query.filter_by(id=post_id).first()
        if check_password_hash(user.passwd, form.passwd.data):
            action.edit_user_passwd()
            flash('密码修改成功,请重新登陆')
            logout_user()
            for key in ('identity.id', 'identity.auth_type'):
                session.pop(key, None)
            identity_changed.send(current_app._get_current_object(),
                                  identity=AnonymousIdentity())
            error = "密码修改"
            return jsonify(judge=True, error=error)
        else:
            error = u'密码错误,请重新输入'
            return jsonify(judge=False, error=error)
    else:
        if form.errors:
            return return_errors(form)
        else:
            pass
        return redirect(url_for('index.index'))
Пример #2
0
def reply(id, comment_id):
    '''回复表单'''
    if not writer_permission.can():
        flash(_('You have not confirm your account'))
        return redirect(url_for('blog.index_num'))
    form = ReplyForm()
    if form.validate_on_submit() and request.method == "POST":
        post_reply = Replies(author=current_user.name, content=form.reply.data)
        post_reply.comments_id = comment_id
        post_reply.publish = datetime.now()
        db.session.add(post_reply)
        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
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'))
Пример #4
0
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'))
Пример #5
0
 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
 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'))
Пример #7
0
 def post(self):
     if not writer_permission.can():
         flash(_('You have not confirm your account'))
         return redirect(url_for('question.quelist'))
     if self.form.validate_on_submit():
         question = Question()
         question.author = current_user
         question.title = self.form.title.data
         question.describ = self.form.describ.data
         question.answer = self.form.answer.data
         '''简单私人日记实现'''
         question.is_private = self.form.private.data
         db.session.add(question)
         db.session.commit()
         flash('感谢你的提交')
         return redirect(url_for('question.quelist'))
     else:
         if self.form.errors:
             flash_errors(self.form)
         return redirect(url_for('question.quelist'))
Пример #8
0
 def post(self):
     if not writer_permission.can():
         flash(_('You have not confirm your account'))
         return redirect(url_for('question.quelist'))
     if self.form.validate_on_submit():
         question = Question()
         question.author = current_user
         question.title = self.form.title.data
         question.describ = self.form.describ.data
         question.answer = self.form.answer.data
         '''简单私人日记实现'''
         question.is_private = self.form.private.data
         db.session.add(question)
         db.session.commit()
         flash('感谢你的提交')
         return redirect(url_for('question.quelist'))
     else:
         if self.form.errors:
             flash_errors(self.form)
         return redirect(url_for('question.quelist'))
Пример #9
0
 def post(self):
     form = QuestionForm()
     user = request.user
     if not writer_permission.can():
         flash(_('You have not confirm your account'))
         return redirect(url_for('question.quelist'))
     if form.validate_on_submit():
         question = Question()
         question.author = user
         question.title = form.title.data
         question.describ = form.describ.data
         question.answer = form.answer.data
         '''简单私人日记实现'''
         question.is_private = form.private.data
         question.save()
         flash('感谢你的提交')
         return redirect(url_for('question.quelist'))
     else:
         if form.errors:
             flash_errors(form)
         return redirect(url_for('question.quelist'))