Exemplo n.º 1
0
def article_detail(request,article_id):
    if request.method == "POST":
        data = json.loads(request.POST['data'])
        if  data['comment_type'] == 1:
            get_article_id = models.Article.objects.get(title=data['article_id'])
            user_id = models.UserProfile.objects.get(name=data['user_id']).id
            data['article_id'] = get_article_id.id
            data['user_id'] = user_id
            create_data = models.Comment.objects.create(**data)
            result_data = ["True",create_data.date.strftime('%Y-%m-%d %T')]
            return HttpResponse(json.dumps(result_data))
        elif data['comment_type'] == 2:
            data['article_id'] = models.Article.objects.get(title=data['article_id']).id
            data['user_id'] = models.UserProfile.objects.get(name=data['user_id']).id
            print('----点赞data',data)
            models.Comment.objects.create(**data)
            return HttpResponse("True")
        # result.save()
        # obj.add(**datas)
    article_obj = models.Article.objects.get(id=article_id)

    comment_tree = get_comment.get_comment(article_obj.comment_set.select_related().order_by("date"))
    return render(request,'bbs/article_detail.html',{'article_obj':article_obj,
                                                     'category_list':category_list,
                                                     'comment_tree':comment_tree})
Exemplo n.º 2
0
def article_detail(request, article_id):
    if request.method == "POST":
        data = json.loads(request.POST['data'])
        if data['comment_type'] == 1:
            get_article_id = models.Article.objects.get(
                title=data['article_id'])
            user_id = models.UserProfile.objects.get(name=data['user_id']).id
            data['article_id'] = get_article_id.id
            data['user_id'] = user_id
            create_data = models.Comment.objects.create(**data)
            result_data = ["True", create_data.date.strftime('%Y-%m-%d %T')]
            return HttpResponse(json.dumps(result_data))
        elif data['comment_type'] == 2:
            data['article_id'] = models.Article.objects.get(
                title=data['article_id']).id
            data['user_id'] = models.UserProfile.objects.get(
                name=data['user_id']).id
            print('----点赞data', data)
            models.Comment.objects.create(**data)
            return HttpResponse("True")
        # result.save()
        # obj.add(**datas)
    article_obj = models.Article.objects.get(id=article_id)

    comment_tree = get_comment.get_comment(
        article_obj.comment_set.select_related().order_by("date"))
    return render(
        request, 'bbs/article_detail.html', {
            'article_obj': article_obj,
            'category_list': category_list,
            'comment_tree': comment_tree
        })
Exemplo n.º 3
0
def get_comments(request,article_id):
    article_obj = models.Article.objects.get(id=article_id)
    print('---->article_obj:',article_obj)
    # comment_tree = comment_hander.build_tree(article_obj.comment_set.select_related())
    comment_tree = get_comment.get_comment(article_obj.comment_set.select_related().order_by("parent_comment",'-id'))
    print(comment_tree)
    # tree_html = comment_hander.render_comment_tree(comment_tree)
    return HttpResponse(comment_tree)
Exemplo n.º 4
0
def article_detail(request,article_id):
    if request.method == "POST":
        print('----------接收ajax的数据',request.POST)
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = get_comment.get_comment(article_obj.comment_set.select_related().order_by("date"))
    # print('------------视图接收的数据',comment_tree)
    return render(request,'bbs/article_detail.html',{'article_obj':article_obj,
                                                     'category_list':category_list,
                                                     'comment_tree':comment_tree})
Exemplo n.º 5
0
def get_comments(request, article_id):
    article_obj = models.Article.objects.get(id=article_id)
    print('---->article_obj:', article_obj)
    # comment_tree = comment_hander.build_tree(article_obj.comment_set.select_related())
    comment_tree = get_comment.get_comment(
        article_obj.comment_set.select_related().order_by(
            "parent_comment", '-id'))
    print(comment_tree)
    # tree_html = comment_hander.render_comment_tree(comment_tree)
    return HttpResponse(comment_tree)
Exemplo n.º 6
0
def get_comments(request, article_id):
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = get_comment.get_comment(
        article_obj.comment_set.select_related().order_by(
            "parent_comment", '-id'))
    return HttpResponse(comment_tree)
Exemplo n.º 7
0
def get_comments(request,article_id):
    article_obj = models.Article.objects.get(id=article_id)
    comment_tree = get_comment.get_comment(article_obj.comment_set.select_related().order_by("parent_comment",'-id'))
    return HttpResponse(comment_tree)