コード例 #1
0
ファイル: views.py プロジェクト: DengPeter/pythonTrainig
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})
コード例 #2
0
ファイル: views.py プロジェクト: github3823/LearnDjango
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,})
コード例 #3
0
ファイル: views.py プロジェクト: wangyuhui12/S12bbs
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
    })
コード例 #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)
コード例 #5
0
ファイル: views.py プロジェクト: Atuski/s12bbs
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
コード例 #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
        })
コード例 #7
0
ファイル: views.py プロジェクト: XiaJieCom/change
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)
コード例 #8
0
ファイル: views.py プロジェクト: XiaJieCom/change
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,})
コード例 #9
0
ファイル: views.py プロジェクト: TaleG/s12bbs
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))