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))
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)
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)
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)
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)
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)