def get(self, id): post = Post.objects.get_or_404(id=id) Post.objects(id=id).update_one(inc__views=1) return render_template('posts/detail.html', post=post, Markdown=Markdown, gen_author=gen_author, gen_author_name=gen_author_name, short_timesince=short_timesince)
def post(self): title = request.form.get('title') content = request.form.get('content') category_id = request.form.get('category', '') if category_id.isdigit(): category_id = int(category_id) category = Category.objects.filter(id=category_id).first() post = Post(title=title, content=content, category=category) post.save() return jsonify(ok=0)
def post(self): title = request.form.get("title") content = request.form.get("content") category_id = request.form.get("category", "") if category_id.isdigit(): category_id = int(category_id) category = Category.objects.filter(id=category_id).first() post = Post(title=title, content=content, category=category) post.save() html = render_template_def("/widgets/topic_item.html", "main", post=post, is_new=True) return jsonify(ok=0, html=html)
def post(self): title = request.form.get('title') content = request.form.get('content') category_id = request.form.get('category', '') if category_id.isdigit(): category_id = int(category_id) category = Category.objects.filter(id=category_id).first() post = Post(title=title, content=content, category=category) post.save() html = render_template_def( '/widgets/topic_item.html', 'main', post=post, is_new=True) return jsonify(ok=0, html=html)
def post(self): title = request.form.get('title') content = request.form.get('content') category_id = request.form.get('category', '') if category_id.isdigit(): category_id = int(category_id) author_id = current_user.id category = Category.objects.filter(id=category_id).first() post = Post(title=title, content=content, category=category, author=User.objects.get_or_404(id=author_id)) post.save() res = get_post(post) return jsonify(ok=0, res=res)
def post(self): title = request.form.get('title') content = request.form.get('content') category_id = request.form.get('category', '') if category_id.isdigit(): category_id = int(category_id) author_id = current_user.id category = Category.objects.filter(id=category_id).first() post = Post(title=title, content=content, category=category, author=User.objects.get_or_404(id=author_id)) post.save() html = render_template_def( '/widgets/topic_item.html', 'main', post=post, is_new=True) return jsonify(ok=0, html=html)
def post(self): ref_id = request.form.get('ref_id', 0) content = request.form.get('content') author = User.objects.get_or_404(id=current_user.id) c = Comment(ref_id=ref_id, content=content, author=author) c.save() context = Post.objects(id=int(ref_id)) if not context: context = Comment.objects(id=int(ref_id)) if not context: return jsonify(ok=1, msg='not exists') else: context = context[0] context.comments.append(c) context.save() return jsonify(ok=0)
def get(self, id): context = self.get_context(id) Post.objects(id=id).update_one(inc__views=1) return render_template('posts/detail.html', **context)
def post(self): title = request.form.get('title') content = request.form.get('content') post = Post(title=title, content=content) post.save() return jsonify(ok=0)
def get(self, id): post = Post.objects.get_or_404(id=id) Post.objects(id=id).update_one(inc__views=1) return render_template('posts/detail.html', post=post)