예제 #1
0
 def _log(self, message):
     if message:
         revision.start()
         revision.user = self.user
         revision.comment = "%s." % message
         revision.add(self.object)
         revision.end()
         return message
     return ""
예제 #2
0
    def test_file_persistence(self):
        with revision_manager:
            # add a file instance
            file1 = FileModel()
            file1.test_file.save('file1.txt',
                SimpleUploadedFile('file1.txt', 'content1'), False)
            file1.save()
            # manually add a revision because we use the explicit way
            # django-cms uses too.
            revision_manager.add(file1)

        # reload the instance from db
        file2 = FileModel.objects.all()[0]
        # delete the instance.
        file2.delete()

        # revert the old version
        file_version = Version.objects.get_for_object(file1)[0]
        file_version.revert()

        # reload the reverted instance and check for its content
        file1 = FileModel.objects.all()[0]
        self.assertEqual(file1.test_file.file.read(), 'content1')