Ejemplo n.º 1
0
def article_dietail(request,article_id):
    # print(request.user.userprofile.name,'------------')
    category = models.Category.objects.filter(set_as_top_menu=True).order_by('position_index')
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = comment_hander.build_tree(article_obj.comment_set.select_related())
    tree_html = comment_hander.render_comment_tree(comment_tree)
    return render(request,'bbs/article_detail.html',{'article_obj':article_obj,'categorys':category,'tree_html':tree_html})
Ejemplo n.º 2
0
def article_detail(request,article_id):
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = comment_hander.build_tree(article_obj.comment_set.select_related())


    return render(request,'bbs/html/article_detail.html',{'article_obj':article_obj,
                                                          'category_list': category_list,})
Ejemplo n.º 3
0
def ariticle_detail(request, id):
    ariticle_obj = models.Article.objects.get(id=id)
    comment_tree = comment_hander.build_tree(
        ariticle_obj.comment_set.select_related(
        ))  #在这里将这片文章所有的评论传给build_tree函数,生成一个有层级关系的字典
    return render(request, 'bbs/article_detail.html', {
        'article_obj': ariticle_obj,
        'category_list': category_list
    })
Ejemplo n.º 4
0
def get_comments(request, article_id):
    '''
    获取Ajax评论在前端的展示
    '''
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = comment_hander.build_tree(
        article_obj.comment_set.select_related())
    tree_html = comment_hander.render_comment_tree(comment_tree)

    return HttpResponse(tree_html)
Ejemplo n.º 5
0
def ariticle_detail(request, id):
    ariticle_obj = models.Article.objects.get(id=id)
    comment_tree = comment_hander.build_tree(
        ariticle_obj.comment_set.select_related(
        ))  #在这里将这片文章所有的评论传给build_tree函数,生成一个有层级关系的字典
    if not request.COOKIES.get(id):
        ariticle_obj.read_num += 1
        ariticle_obj.save()
    response = render(request, 'bbs/article_detail.html', {
        'article_obj': ariticle_obj,
        'category_list': category_list
    })
    response.set_cookie(id, 'true')
    return response
Ejemplo n.º 6
0
def article_detail(request, article_id):
    article_obj = models.Article.objects.get(id=article_id)
    author_id = article_obj.author.id
    author_article_num = models.Article.objects.filter(id=author_id).count()
    author_comment_num = models.Comment.objects.filter(id=author_id).count()
    if not author_comment_num:
        author_comment_num = 0
    click_count = article_obj.click_count
    article_obj.click_count = click_count + 1
    priority = article_obj.priority + 1
    article_obj.priority = priority
    article_obj.save()
    comment_tree = comment_hander.build_tree(
        article_obj.comment_set.select_related())
    return render(
        request, 'bbs/article_detail.html', {
            'article_obj': article_obj,
            'comment_tree': comment_tree,
            'category_list': category_list,
            'author_article_num': author_article_num,
            'author_comment_num': author_comment_num
        })
Ejemplo n.º 7
0
def get_comments(request,article_id):
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = comment_hander.build_tree(article_obj.comment_set.select_related())
    tree_html = comment_hander.render_comment_tree(comment_tree)
    return HttpResponse(tree_html)
Ejemplo n.º 8
0
def article_detail(request,article_id):
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = comment_hander.build_tree(article_obj.comment_set.select_related())
    return render(request,'bbs/article_detail.html',{'article_obj':article_obj,
                                                     'category_list':category_list,})
Ejemplo n.º 9
0
def get_comments(request, article_id):
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = comment_hander.build_tree(
        article_obj.comment_set.select_related())
    # tree_html = comment_hander.render_comment_tree(comment_tree)
    return HttpResponse(json.dumps(comment_tree))