Exemplo n.º 1
0
    def test_batch_cancel_review(self):
        self.doc1.get_latest_revision().start_review()
        self.doc2.get_latest_revision().start_review()

        self.assertTrue(self.doc1.get_latest_revision().is_under_review())
        self.assertTrue(self.doc2.get_latest_revision().is_under_review())
        self.assertFalse(self.doc3.get_latest_revision().is_under_review())

        batch_cancel_reviews.delay(
            self.user.id,
            self.category.id,
            self.content_type.id,
            [self.doc1.id, self.doc2.id, self.doc3.id])

        doc1 = Document.objects.get(pk=self.doc1.pk)
        doc2 = Document.objects.get(pk=self.doc2.pk)
        doc3 = Document.objects.get(pk=self.doc3.pk)

        self.assertFalse(doc1.get_latest_revision().is_under_review())
        self.assertFalse(doc2.get_latest_revision().is_under_review())
        self.assertFalse(doc3.get_latest_revision().is_under_review())

        # Check audit trail
        activities = Activity.objects.order_by('created_on')
        # Only two reviews were canceled
        self.assertEqual(activities.count(), 2)
        for i, doc in enumerate([doc1, doc2]):
            self.assertEqual(activities[i].verb,
                             Activity.VERB_CANCELLED_REVIEW)
            self.assertEqual(activities[i].target,
                             doc.get_latest_revision())
Exemplo n.º 2
0
    def test_batch_cancel_review(self):
        self.doc1.get_latest_revision().start_review()
        self.doc2.get_latest_revision().start_review()

        self.assertTrue(self.doc1.get_latest_revision().is_under_review())
        self.assertTrue(self.doc2.get_latest_revision().is_under_review())
        self.assertFalse(self.doc3.get_latest_revision().is_under_review())

        batch_cancel_reviews.delay(self.user.id, self.category.id,
                                   self.content_type.id,
                                   [self.doc1.id, self.doc2.id, self.doc3.id])

        doc1 = Document.objects.get(pk=self.doc1.pk)
        doc2 = Document.objects.get(pk=self.doc2.pk)
        doc3 = Document.objects.get(pk=self.doc3.pk)

        self.assertFalse(doc1.get_latest_revision().is_under_review())
        self.assertFalse(doc2.get_latest_revision().is_under_review())
        self.assertFalse(doc3.get_latest_revision().is_under_review())

        # Check audit trail
        activities = Activity.objects.order_by('created_on')
        # Only two reviews were canceled
        self.assertEqual(activities.count(), 2)
        for i, doc in enumerate([doc1, doc2]):
            self.assertEqual(activities[i].verb,
                             Activity.VERB_CANCELLED_REVIEW)
            self.assertEqual(activities[i].target, doc.get_latest_revision())
Exemplo n.º 3
0
 def start_job(self, contenttype, document_ids):
     job = batch_cancel_reviews.delay(
         self.request.user.id,
         self.category.id,
         contenttype.id,
         document_ids)
     return job
Exemplo n.º 4
0
    def test_batch_cancel_review(self):
        self.doc1.get_latest_revision().start_review()
        self.doc2.get_latest_revision().start_review()

        self.assertTrue(self.doc1.get_latest_revision().is_under_review())
        self.assertTrue(self.doc2.get_latest_revision().is_under_review())
        self.assertFalse(self.doc3.get_latest_revision().is_under_review())

        batch_cancel_reviews.delay(
            self.user.id,
            self.category.id,
            self.content_type.id,
            [self.doc1.id, self.doc2.id, self.doc3.id])

        doc1 = Document.objects.get(pk=self.doc1.pk)
        doc2 = Document.objects.get(pk=self.doc2.pk)
        doc3 = Document.objects.get(pk=self.doc3.pk)

        self.assertFalse(doc1.get_latest_revision().is_under_review())
        self.assertFalse(doc2.get_latest_revision().is_under_review())
        self.assertFalse(doc3.get_latest_revision().is_under_review())
Exemplo n.º 5
0
 def start_job(self, contenttype, document_ids):
     job = batch_cancel_reviews.delay(self.request.user.id,
                                      self.category.id, contenttype.id,
                                      document_ids)
     return job