예제 #1
0
 def test_replies(self):
     ct = ContentType.objects.get_for_model(self.user1)
     pk = self.user1.pk
     for _ in range(5):
         p = api.post_comment(content_type_id=ct.id, object_pk=pk,
                              user_id=pk, comment="Root message %s" % _)
         for __ in range(settings.REPLY_LIMIT+3):
             c = api.post_reply(user_id=pk, comment="Reply %s%s" % (_, __), parent_id=p.id)
     self.assertEqual(api.get_comments_limited(ct.id, pk).count(), 5*(settings.REPLY_LIMIT+1))
예제 #2
0
 def test_replies(self):
     ct = ContentType.objects.get_for_model(self.user1)
     pk = self.user1.pk
     for _ in range(5):
         p = api.post_comment(content_type_id=ct.id, object_pk=pk,
                              user_id=pk, comment="Root message %s" % _)
         for __ in range(settings.REPLY_LIMIT+3):
             c = api.post_reply(user_id=pk, comment="Reply %s%s" % (_, __), parent_id=p.id)
     self.assertEqual(api.get_comments_limited(ct.id, pk).count(), 5*(settings.REPLY_LIMIT+1))
예제 #3
0
def index(request, content_type_id, object_pk):
    comments = (
        api.get_comments_limited(content_type_id, object_pk)
        .extra(
            select={
                "sortdate": "CASE WHEN tcc_comment.parent_id is null "
                " THEN tcc_comment.submit_date ELSE T3.submit_date END"
            }
        )
        .order_by("-sortdate", "path")
    )
    form = _get_comment_form(content_type_id, object_pk)
    context = RequestContext(request, {"comments": comments, "form": form})
    return render_to_response("tcc/index.html", context)
예제 #4
0
def get_comments_for_object(context, object, next=None):
    ct = ContentType.objects.get_for_model(object)
    request = context['request']
    initial = {'content_type': ct.id,
               'object_pk': object.pk,
               'next': next,
               }
    form = CommentForm(object, initial=initial)
    thread_id = request.GET.get('cpermalink', None)
    if thread_id:
        comments = api.get_comment_thread(thread_id)
    else:
        comments = api.get_comments_limited(ct.id, object.pk)
    if not comments:
        comments = []
    else:
        comments = comments.order_by('-sort_date', 'path')
    context.update({'comments': comments, 'form': form})
    return render_to_string('tcc/list-comments.html',
                            context_instance=context)
예제 #5
0
def get_comments_for_object(context, object, next=None):
    ct = ContentType.objects.get_for_model(object)
    request = context['request']
    initial = {
        'content_type': ct.id,
        'object_pk': object.pk,
        'next': next,
    }
    form = CommentForm(object, initial=initial)
    thread_id = request.GET.get('cpermalink', None)
    if thread_id:
        comments = api.get_comment_thread(thread_id)
    else:
        comments = api.get_comments_limited(ct.id, object.pk)
    if not comments:
        comments = []
    else:
        comments = comments.order_by('-sort_date', 'path')
    context.update({'comments': comments, 'form': form})
    return render_to_string('tcc/list-comments.html', context_instance=context)
예제 #6
0
def index(request, content_type_id, object_pk):
    comments = api.get_comments_limited(content_type_id, object_pk).order_by(
        '-sort_date', 'path')
    form = _get_comment_form(content_type_id, object_pk)
    context = RequestContext(request, {'comments': comments, 'form': form})
    return render_to_response('tcc/index.html', context)
예제 #7
0
파일: views.py 프로젝트: WoLpH/django-tcc
def index(request, content_type_id, object_pk):
    comments = api.get_comments_limited(
        content_type_id, object_pk).order_by('-sort_date', 'path')
    form = _get_comment_form(content_type_id, object_pk)
    context = RequestContext(request, {'comments': comments, 'form': form })
    return render_to_response('tcc/index.html', context)