src/reversion/models.py
def revert(self, delete=False):
        """Reverts all objects in this revision."""
        version_set = self.version_set.all()
        # Optionally delete objects no longer in the current revision.
        if delete:
            # Get a dict of all objects in this revision.
            old_revision = set()
            for version in version_set:
                try:
                    obj = version.object
                except ContentType.objects.get_for_id(version.content_type_id).model_class().DoesNotExist:
                    pass
                else:
                    old_revision.add(obj)
            # Calculate the set of all objects that are in the revision now.
            from reversion.revisions import RevisionManager
            current_revision = RevisionManager.get_manager(self.manager_slug)._follow_relationships(
                obj for obj in old_revision if obj is not None)
            # Delete objects that are no longer in the current revision.
            for item in current_revision:
                if item not in old_revision:
                    item.delete()
        # Attempt to revert all revisions.
        safe_revert(version_set)
Reverts all objects in this revision.
Reverts all objects in this revision.
Reverts all objects in this revision .
def revert(self, delete=False):
        version_set = self.version_set.all()
        if delete:
            old_revision = set()
            for version in version_set:
                try:
                    obj = version.object
                except ContentType.objects.get_for_id(version.content_type_id).model_class().DoesNotExist:
                    pass
                else:
                    old_revision.add(obj)
            from reversion.revisions import RevisionManager
            current_revision = RevisionManager.get_manager(self.manager_slug)._follow_relationships(
                obj for obj in old_revision if obj is not None)
            for item in current_revision:
                if item not in old_revision:
                    item.delete()
        safe_revert(version_set)
def revert ( self , delete = False ) : version_set = self . version_set . all ( ) if delete : old_revision = set ( ) for version in version_set : try : obj = version . object except ContentType . objects . get_for_id ( version . content_type_id ) . model_class ( ) . DoesNotExist : pass else : old_revision . add ( obj ) from reversion . revisions import RevisionManager current_revision = RevisionManager . get_manager ( self . manager_slug ) . _follow_relationships ( obj for obj in old_revision if obj is not None ) for item in current_revision : if item not in old_revision : item . delete ( ) safe_revert ( version_set )
Reverts all objects in this revision.
Reverts all objects in this revision .
"""Reverts all objects in this revision.""" # Optionally delete objects no longer in the current revision. # Get a dict of all objects in this revision. # Calculate the set of all objects that are in the revision now. # Delete objects that are no longer in the current revision. # Attempt to revert all revisions.
self
delete