Permalink
Browse files

Removed revision support from core (#5615)

  • Loading branch information...
1 parent a3a1b33 commit a0e25894a078dbb263eb550820539696afc04b8f @czpython czpython committed on GitHub Aug 26, 2016
Showing with 133 additions and 1,861 deletions.
  1. +4 −0 CHANGELOG.txt
  2. +23 −450 cms/admin/pageadmin.py
  3. +0 −68 cms/admin/views.py
  4. +11 −41 cms/api.py
  5. +0 −33 cms/cms_toolbars.py
  6. +2 −2 cms/constants.py
  7. +0 −14 cms/forms/wizards.py
  8. +1 −1 cms/management/commands/subcommands/moderator.py
  9. +44 −159 cms/models/pagemodel.py
  10. +1 −0 cms/models/permissionmodels.py
  11. +2 −1 cms/models/placeholdermodel.py
  12. +1 −0 cms/models/pluginmodel.py
  13. +1 −1 cms/models/titlemodels.py
  14. +3 −2 cms/plugin_pool.py
  15. +0 −9 cms/signals/__init__.py
  16. +0 −12 cms/signals/reversion_signals.py
  17. +0 −26 cms/templates/admin/cms/page/history/recover_header.html
  18. +0 −23 cms/templates/admin/cms/page/history/revision_header.html
  19. 0 cms/test_utils/project/fileapp/__init__.py
  20. +0 −23 cms/test_utils/project/fileapp/migrations/0001_initial.py
  21. 0 cms/test_utils/project/fileapp/migrations/__init__.py
  22. +0 −7 cms/test_utils/project/fileapp/models.py
  23. +0 −3 cms/test_utils/testcases.py
  24. +0 −36 cms/tests/test_admin.py
  25. +1 −78 cms/tests/test_api.py
  26. +2 −2 cms/tests/test_page.py
  27. +1 −1 cms/tests/test_publisher.py
  28. +0 −724 cms/tests/test_reversion_tests.py
  29. +30 −69 cms/utils/helpers.py
  30. +1 −0 cms/utils/reversion_hacks.py
  31. +0 −5 cms/utils/setup.py
  32. +1 −2 docs/contributing/testing.rst
  33. +0 −21 docs/how_to/install.rst
  34. +0 −1 docs/introduction/install.rst
  35. +2 −4 docs/reference/api_references.rst
  36. +0 −36 docs/reference/configuration.rst
  37. +2 −2 gulpfile.js
  38. +0 −2 manage.py
  39. +0 −1 test_requirements/django-1.8.txt
  40. +0 −1 test_requirements/django-1.9.txt
  41. +0 −1 testserver.py
View
@@ -22,6 +22,10 @@
publishing the page first.
* Added help text to an ``Alias`` plugin change form when attached to a page
to show the content editor where the content is aliased from.
+* Removed revision support from djangoCMS core.
+ As a result both ``CMS_MAX_PAGE_HISTORY_REVERSIONS`` and ``CMS_MAX_PAGE_PUBLISH_REVERSIONS``
+ settings are no longer supported, as well as the ``with_revision`` parameter
+ in ``cms.api.create_page`` and ``cms.api.create_title``.
=== 3.3.3 (unreleased) ===
View
Oops, something went wrong.
View
@@ -1,68 +0,0 @@
-# -*- coding: utf-8 -*-
-from django.http import Http404
-from django.shortcuts import get_object_or_404
-
-from cms.models import Page, Title, CMSPlugin, Placeholder
-from cms.utils.page_permissions import user_can_change_page
-
-
-def revert_plugins(request, version_id, obj):
- from cms.utils.reversion_hacks import Version
-
- version = get_object_or_404(Version, pk=version_id)
- revs = [related_version.object_version for related_version in version.revision.version_set.all()]
- cms_plugin_list = []
- placeholders = {}
- plugin_list = []
- titles = []
- others = []
- page = obj
- for rev in revs:
- obj = rev.object
- if obj.__class__ == Placeholder:
- placeholders[obj.pk] = obj
- if obj.__class__ == CMSPlugin:
- cms_plugin_list.append(obj)
- elif hasattr(obj, 'cmsplugin_ptr_id'):
- plugin_list.append(obj)
- elif obj.__class__ == Page:
- pass
- elif obj.__class__ == Title:
- titles.append(obj)
- else:
- others.append(rev)
- if not user_can_change_page(request.user, page):
- raise Http404
- current_plugins = list(CMSPlugin.objects.filter(placeholder__page=page))
- for pk, placeholder in placeholders.items():
- # admin has already created the placeholders/ get them instead
- try:
- placeholders[pk] = page.placeholders.get(slot=placeholder.slot)
- except Placeholder.DoesNotExist:
- placeholders[pk].save()
- page.placeholders.add(placeholders[pk])
- for plugin in cms_plugin_list:
- # connect plugins to the correct placeholder
- plugin.placeholder = placeholders[plugin.placeholder_id]
- plugin.save(no_signals=True)
- for plugin in cms_plugin_list:
- plugin.save()
- for p in plugin_list:
- if int(p.cmsplugin_ptr_id) == int(plugin.pk):
- plugin.set_base_attr(p)
- p.save()
- for old in current_plugins:
- if old.pk == plugin.pk:
- plugin.save()
- current_plugins.remove(old)
- for title in titles:
- title.page = page
- try:
- title.save()
- except:
- title.pk = Title.objects.get(page=page, language=title.language).pk
- title.save()
- for other in others:
- other.object.save()
- for plugin in current_plugins:
- plugin.delete()
View
@@ -7,11 +7,11 @@
calling these methods!
"""
import datetime
+import warnings
from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.core.exceptions import FieldError
-from django.core.exceptions import ImproperlyConfigured
from django.core.exceptions import PermissionDenied
from django.core.exceptions import ValidationError
from django.template.defaultfilters import slugify
@@ -33,7 +33,6 @@
from cms.plugin_pool import plugin_pool
from cms.utils import copy_plugins
from cms.utils.conf import get_cms_setting
-from cms.utils.compat.dj import is_installed
from cms.utils.i18n import get_language_list
from cms.utils.permissions import _thread_locals, current_user
from menus.menu_pool import menu_pool
@@ -64,18 +63,6 @@ def generate_valid_slug(source, parent, language):
return slug
-def _create_revision(obj, user=None, message=None):
- from cms.utils.helpers import make_revision_with_plugins
- from cms.utils.reversion_hacks import create_revision
-
- with create_revision():
- make_revision_with_plugins(
- obj=obj,
- user=user,
- message=message,
- )
-
-
def _verify_apphook(apphook, namespace):
"""
Verifies the apphook given is valid and returns the normalized form (name)
@@ -104,12 +91,11 @@ def _verify_apphook(apphook, namespace):
return apphook_name
-def _verify_revision_support():
- if not is_installed('reversion'):
- raise ImproperlyConfigured(
- "You have requested to create a revision "
- "but the reversion app is not in settings.INSTALLED_APPS"
- )
+def _raise_revision_warning():
+ warnings.warn('Revision support has been removed from the core.'
+ 'As a result the with_revision parameter is no longer '
+ 'supported and will be removed in version 3.5',
+ UserWarning)
def _verify_plugin_type(plugin_type):
@@ -147,16 +133,14 @@ def create_page(title, template, language, menu_title=None, slug=None,
navigation_extenders=None, published=False, site=None,
login_required=False, limit_visibility_in_menu=constants.VISIBILITY_ALL,
position="last-child", overwrite_url=None,
- xframe_options=Page.X_FRAME_OPTIONS_INHERIT, with_revision=False):
+ xframe_options=Page.X_FRAME_OPTIONS_INHERIT, with_revision=None):
"""
Create a CMS Page and it's title for the given language
See docs/extending_cms/api_reference.rst for more info
"""
- if with_revision:
- # fail fast if revision is requested
- # but not enabled on the project.
- _verify_revision_support()
+ if with_revision in (True, False):
+ _raise_revision_warning()
# ugly permissions hack
if created_by and isinstance(created_by, get_user_model()):
@@ -262,15 +246,6 @@ def create_page(title, template, language, menu_title=None, slug=None,
if published:
page.publish(language)
- if with_revision:
- from cms.constants import REVISION_INITIAL_COMMENT
-
- _create_revision(
- obj=page,
- user=_thread_locals.user,
- message=REVISION_INITIAL_COMMENT,
- )
-
del _thread_locals.user
page = page.reload()
@@ -297,10 +272,8 @@ def create_title(language, title, page, menu_title=None, slug=None,
# validate language:
assert language in get_language_list(page.site_id)
- if with_revision:
- # fail fast if revision is requested
- # but not enabled on the project.
- _verify_revision_support()
+ if with_revision in (True, False):
+ _raise_revision_warning()
# set default slug:
if not slug:
@@ -320,9 +293,6 @@ def create_title(language, title, page, menu_title=None, slug=None,
title.has_url_overwrite = True
title.path = overwrite_url
title.save()
-
- if with_revision:
- _create_revision(obj=page)
return title
View
@@ -16,7 +16,6 @@
from cms.toolbar_base import CMSToolbar
from cms.toolbar_pool import toolbar_pool
from cms.utils.i18n import get_language_tuple, force_language, get_language_dict, get_default_language
-from cms.utils.compat.dj import is_installed
from cms.utils import get_cms_setting, get_language_from_request
from cms.utils import page_permissions
from cms.utils.permissions import get_user_sites_queryset
@@ -40,7 +39,6 @@
PAGE_MENU_THIRD_BREAK = 'Page Menu Third Break'
PAGE_MENU_FOURTH_BREAK = 'Page Menu Fourth Break'
PAGE_MENU_LAST_BREAK = 'Page Menu Last Break'
-HISTORY_MENU_IDENTIFIER = 'history'
HISTORY_MENU_BREAK = 'History Menu Break'
MANAGE_PAGES_BREAK = 'Manage Pages Break'
ADMIN_SITES_BREAK = 'Admin Sites Break'
@@ -609,37 +607,6 @@ def add_page_menu(self):
on_success=refresh,
)
- # fourth break
- current_page_menu.add_break(PAGE_MENU_FOURTH_BREAK)
- history_menu = current_page_menu.get_or_create_menu(HISTORY_MENU_IDENTIFIER, _('History'))
- if is_installed('reversion'):
- from cms.utils.reversion_hacks import reversion, Revision
-
- versions = reversion.get_for_object(self.page)
- if self.page.revision_id:
- current_revision = Revision.objects.get(pk=self.page.revision_id)
- has_undo = versions.filter(revision__pk__lt=current_revision.pk).exists()
- has_redo = versions.filter(revision__pk__gt=current_revision.pk).exists()
- else:
- has_redo = False
- has_undo = versions.count() > 1
-
- undo_action = admin_reverse('cms_page_undo', args=(self.page.pk,))
- redo_action = admin_reverse('cms_page_redo', args=(self.page.pk,))
-
- history_menu.add_ajax_item(_('Undo'), action=undo_action, disabled=not has_undo, on_success=refresh)
- history_menu.add_ajax_item(_('Redo'), action=redo_action, disabled=not has_redo, on_success=refresh)
-
- history_menu.add_break(HISTORY_MENU_BREAK)
-
- revert_action = admin_reverse('cms_page_revert_page', args=(self.page.pk, self.current_lang))
- revert_question = _('Are you sure you want to revert to live?')
- is_enabled = self.page.is_dirty(self.current_lang) and self.page.publisher_public
- history_menu.add_ajax_item(_('Revert to live'), action=revert_action, question=revert_question,
- disabled=not is_enabled,
- on_success=refresh, extra_classes=('cms-toolbar-revert',))
- history_menu.add_modal_item(_('View history'), url=admin_reverse('cms_page_history', args=(self.page.pk,)))
-
# last break
current_page_menu.add_break(PAGE_MENU_LAST_BREAK)
View
@@ -29,8 +29,6 @@
PAGE_USERNAME_MAX_LENGTH = 255
-REVISION_INITIAL_COMMENT = "Initial version."
-
SLUG_REGEXP = '[0-9A-Za-z-_.//]+'
EXPIRE_NOW = 0
@@ -47,3 +45,5 @@
ROOT_USER_LEVEL = -1
GRANT_ALL_PERMISSIONS = 'All'
+
+PUBLISH_COMMENT = "Publish"
View
@@ -7,7 +7,6 @@
from django.core.exceptions import PermissionDenied
from django.utils.encoding import smart_text
from django.utils.translation import (
- ugettext,
ugettext_lazy as _,
get_language,
)
@@ -23,7 +22,6 @@
user_can_add_page,
user_can_add_subpage,
)
-from cms.utils.compat.dj import is_installed
from cms.utils.conf import get_cms_setting
try:
@@ -251,18 +249,6 @@ def save(self, **kwargs):
# is it home? publish it right away
if not self.page and page.is_home:
page.publish(self.language_code)
-
- if is_installed('reversion'):
- from cms.utils.helpers import make_revision_with_plugins
- from cms.constants import REVISION_INITIAL_COMMENT
- from cms.utils.reversion_hacks import create_revision
-
- with create_revision():
- make_revision_with_plugins(
- obj=page,
- user=self.user,
- message=ugettext(REVISION_INITIAL_COMMENT),
- )
return page
@@ -33,7 +33,7 @@ def handle(self, *args, **options):
for language in page.get_languages():
if CMSPlugin.objects.filter(placeholder__page=page, language=language).exists():
log.debug('Reverting page pk=%d' % (page.pk,))
- page.publisher_draft.revert(language)
+ page.publisher_draft.reset_to_public(language)
log.info('Publishing all published drafts')
for title in Title.objects.filter(publisher_is_draft=True, publisher_public_id__gt=0):
Oops, something went wrong.

0 comments on commit a0e2589

Please sign in to comment.