def test_approve(self): ct = ContentType.objects.get_for_model(self.user1) pk = self.user1.pk c = api.post_comment(content_type_id=ct.id, object_pk=pk, user_id=pk, comment="Root message") self.assertTrue(c is not None) # wrong user x = api.approve_comment(c.id, self.user2) self.assertTrue(x is None) c = api.approve_comment(c.id, self.user1) self.assertTrue(c is not None) self.assertTrue(c.is_approved) # wrong user x = api.disapprove_comment(c.id, self.user2) self.assertTrue(x is None) c = api.disapprove_comment(c.id, self.user1) self.assertTrue(c is not None) self.assertFalse(c.is_approved) disapproved = api.get_comments_disapproved( content_type_id=ct.id, object_pk=pk) self.assertEqual(len(disapproved), 1) c = api.approve_comment(c.id, self.user1) self.assertTrue(c is not None) self.assertTrue(c.is_approved) disapproved = api.get_comments_disapproved( content_type_id=ct.id, object_pk=pk) self.assertEqual(len(disapproved), 0) c = api.approve_comment(-1, self.user1) self.assertEqual(c, None) c = api.disapprove_comment(-1, self.user1) self.assertEqual(c, None)
def test_approve(self): ct = ContentType.objects.get_for_model(self.user1) pk = self.user1.pk c = api.post_comment(content_type_id=ct.id, object_pk=pk, user_id=pk, comment="Root message") self.assertTrue(c is not None) # wrong user x = api.approve_comment(c.id, self.user2) self.assertTrue(x is None) c = api.approve_comment(c.id, self.user1) self.assertTrue(c is not None) self.assertTrue(c.is_approved) # wrong user x = api.disapprove_comment(c.id, self.user2) self.assertTrue(x is None) c = api.disapprove_comment(c.id, self.user1) self.assertTrue(c is not None) self.assertFalse(c.is_approved) disapproved = api.get_comments_disapproved(content_type_id=ct.id, object_pk=pk) self.assertEqual(len(disapproved), 1) c = api.approve_comment(c.id, self.user1) self.assertTrue(c is not None) self.assertTrue(c.is_approved) disapproved = api.get_comments_disapproved(content_type_id=ct.id, object_pk=pk) self.assertEqual(len(disapproved), 0) c = api.approve_comment(-1, self.user1) self.assertEqual(c, None) c = api.disapprove_comment(-1, self.user1) self.assertEqual(c, None)
def disapprove(request, comment_id): comment = api.disapprove_comment(comment_id, request.user) if comment: tcc_index = _get_tcc_index(comment) return HttpResponseRedirect(tcc_index) raise Http404()
def disapprove(request, comment_id): comment = api.disapprove_comment(comment_id, request.user) if comment: tcc_index = _get_tcc_index(comment) return HttpResponseRedirect(tcc_index) raise Http404()