示例#1
0
文件: post.py 项目: guoyu07/firefly
 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)
示例#2
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,
                            Markdown=Markdown,
                            gen_author=gen_author,
                            gen_author_name=gen_author_name,
                            short_timesince=short_timesince)
示例#3
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()
     return jsonify(ok=0)
示例#4
0
文件: home.py 项目: tmacjx/firefly
    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)
示例#5
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)
示例#6
0
文件: home.py 项目: guoyu07/firefly
 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)
示例#7
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)
        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)
示例#8
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)
     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)
示例#9
0
    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)
示例#10
0
文件: home.py 项目: guoyu07/firefly
    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)
示例#11
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)
示例#12
0
文件: home.py 项目: zbing3/firefly
 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)
示例#13
0
文件: post.py 项目: IanZhao/firefly
 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)