def make_revision_with_plugins(obj, user=None, message=None):
    """
    Only add to revision if it is a draft.
    """
    from cms.models.pluginmodel import CMSPlugin
    # we can safely import reversion - calls here always check for
    # reversion in installed_applications first
    from cms.utils.reversion_hacks import revision_context, revision_manager
    cls = obj.__class__
    if hasattr(revision_manager, '_registration_key_for_model'):
        model_key = revision_manager._registration_key_for_model(cls)
    else:
        model_key = cls

    if model_key in revision_manager._registered_models:

        placeholder_relation = find_placeholder_relation(obj)

        if revision_context.is_active():
            if user:
                revision_context.set_user(user)
            if message:
                revision_context.set_comment(message)
            # add toplevel object to the revision
            adapter = revision_manager.get_adapter(obj.__class__)
            revision_context.add_to_context(revision_manager, obj, adapter.get_version_data(obj))
            # add placeholders to the revision
            for ph in obj.get_placeholders():
                phadapter = revision_manager.get_adapter(ph.__class__)
                revision_context.add_to_context(revision_manager, ph, phadapter.get_version_data(ph))
            # add plugins and subclasses to the revision
            filters = {'placeholder__%s' % placeholder_relation: obj}
            for plugin in CMSPlugin.objects.filter(**filters):
                plugin_instance, admin = plugin.get_plugin_instance()
                if plugin_instance:
                    padapter = revision_manager.get_adapter(plugin_instance.__class__)
                    revision_context.add_to_context(revision_manager, plugin_instance, padapter.get_version_data(plugin_instance))
                bpadapter = revision_manager.get_adapter(plugin.__class__)
                revision_context.add_to_context(revision_manager, plugin, bpadapter.get_version_data(plugin))
dataset/ETHPy150Open divio/django-cms/cms/utils/helpers.py/make_revision_with_plugins/original