Ejemplo n.º 1
0
 def test_post_comment(self):
     ct = ContentType.objects.get_for_model(self.user1)
     pk = self.user1.pk
     p = api.post_comment(content_type_id=ct.id,
                          object_pk=pk,
                          user_id=pk,
                          comment="Root message")
     self.assertEqual(p.path, u'1'.zfill(settings.STEPLEN))
     c = api.post_comment(content_type_id=ct.id,
                          object_pk=pk,
                          user_id=pk,
                          comment="Reply",
                          parent_id=p.id)
     self.assertEqual(
         c.path,
         u'1'.zfill(settings.STEPLEN) + u'2'.zfill(settings.STEPLEN))
     self.assertEqual(c.get_parents()[0].id, p.id)
     self.assertEqual(len(p.get_parents()), 0)
     self.assertEqual(p.get_replies()[0].id, c.id)
     self.assertEqual(len(c.get_replies()), 0)
     self.assertEqual(api.get_comment_replies(p.id)[0].id, c.id)
     self.assertEqual(api.get_comment_parents(c.id)[0].id, p.id)
     tp = api.get_comment_thread(p.id)
     tc = api.get_comment_thread(c.id)
     self.assertEqual(len(tp), 2)
     self.assertEqual(len(tc), 2)
     # Non existing parent
     c = api.post_comment(content_type_id=ct.id,
                          object_pk=pk,
                          user_id=pk,
                          comment="Reply",
                          parent_id=-1)
     self.assertEqual(c, None)
Ejemplo n.º 2
0
   def test_post_comment(self):
       ct = ContentType.objects.get_for_model(self.user1)
       pk = self.user1.pk
       p = api.post_comment(content_type_id=ct.id, object_pk=pk,
                            user_id=pk, comment="Root message")
       self.assertEqual(p.path,  u'1'.zfill(settings.STEPLEN))
       c = api.post_comment(content_type_id=ct.id, object_pk=pk,
                            user_id=pk, comment="Reply", parent_id=p.id)
       self.assertEqual(c.path,  u'1'.zfill(settings.STEPLEN)+u'2'.zfill(settings.STEPLEN))
       self.assertEqual(c.get_parents()[0].id, p.id)
       self.assertEqual(len(p.get_parents()), 0)
       self.assertEqual(p.get_replies()[0].id, c.id)
       self.assertEqual(len(c.get_replies()), 0)
       self.assertEqual(api.get_comment_replies(p.id)[0].id, c.id)
       self.assertEqual(api.get_comment_parents(c.id)[0].id, p.id)
       tp = api.get_comment_thread(p.id)
       tc = api.get_comment_thread(c.id)
       self.assertEqual(len(tp), 2)
       self.assertEqual(len(tc), 2)
 # Non existing parent
       c = api.post_comment(content_type_id=ct.id, object_pk=pk,
                            user_id=pk, comment="Reply", parent_id=-1)
       self.assertEqual(c, None)
Ejemplo n.º 3
0
def replies(request, parent_id):
    comments = api.get_comment_replies(parent_id).wrap(orm.id_to_user)
    context = RequestContext(request, {'comments': comments})
    return render_to_response('tcc/replies.html', context)
Ejemplo n.º 4
0
def replies(request, parent_id):
    comments = api.get_comment_replies(parent_id).wrap(orm.id_to_user)
    context = RequestContext(request, {'comments': comments})
    return render_to_response('tcc/replies.html', context)
Ejemplo n.º 5
0
def replies(request, parent_id):
    comments = api.get_comment_replies(parent_id)
    context = RequestContext(request, {"comments": comments})
    return render_to_response("tcc/replies.html", context)