def get(self, queId): question = Question.get(queId) if question.is_private and current_user.id != question.author.id: flash('你没有权限查看') return redirect(url_for('question.quelist')) data = { 'title': _('%(title)s - Answer - HonMaple', title=question.title), 'question': question } return render_template('question/question.html', **data)
def get(self, queId): question = Question.get(queId) if question.is_private and current_user != question.author: flash('你没有权限查看') return redirect(url_for('question.quelist')) data = { 'title': _('%(title)s - 自问自答 - HonMaple', title=question.title), 'question': question } return render_template('question/question.html', **data)
def get(self): page = request.args.get('page', 1, type=int) filter_dict = {} filter_dict.update(dict(is_private=True, author=current_user)) questions = Question.get_question_list(page, filter_dict) data = { 'title': _('自问自答 - HonMaple'), 'form': self.form, 'questions': questions } return render_template('question/questionlist.html', **data)
def get(self): page = request.args.get('page', 1, type=int) filter_dict = {} filter_dict.update(dict(is_private=True, author__id=current_user.id)) questions = Question.get_list(page, 18, filter_dict) data = { 'title': _('Answer - HonMaple'), 'form': self.form, 'questions': questions } return render_template('question/questionlist.html', **data)
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'))
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'))