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'))
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'))