def post(self): node_id = force_int(self.get_argument('node_id', 0), 0) node = Node.get(id=node_id) user = self.current_user form = TopicForm(self.request.arguments) if form.validate(): topic = form.save(user=user) topic.put_notifier() result = {'status': 'success', 'message': '主题创建成功', 'topic_url': topic.url} if self.is_ajax: return self.write(result) self.flash_message(**result) return self.redirect(topic.url) if self.is_ajax: return self.write(form.result) return self.render("topic/create.html", form=form, node=node)
def post(self, topic_id): topic = Topic.get(id=topic_id) if not topic or (topic.author != self.current_user and not self.current_user.is_admin): return self.redirect_next_url() user = self.current_user form = TopicForm(self.request.arguments) if form.validate(): topic = form.save(user=user, topic=topic) topic.put_notifier() result = {'status': 'success', 'message': '主题修改成功', 'topic_url': topic.url} if self.is_ajax: return self.write(result) self.flash_message(**result) return self.redirect(topic.url) if self.is_ajax: return self.write(form.result) return self.render("topic/create.html", form=form, node=topic.node)