Permalink
Browse files

Merge branch 'develop' into fix-2685

Conflicts:
	cms/templates/admin/cms/page/tree/menu_item.html
  • Loading branch information...
2 parents 1f5db0c + ca9bdc7 commit b7137c246261624e06880a979be035c8a8944ce8 @digi604 digi604 committed Feb 27, 2014
Showing with 718 additions and 213 deletions.
  1. +2 −1 CHANGELOG.txt
  2. +25 −3 cms/admin/pageadmin.py
  3. +2 −0 cms/cms_toolbar.py
  4. +3 −3 cms/context_processors.py
  5. +11 −2 cms/middleware/toolbar.py
  6. +31 −4 cms/models/pagemodel.py
  7. +2 −0 cms/plugin_base.py
  8. +7 −0 cms/signals/apphook.py
  9. +1 −1 cms/static/cms/css/cms.base.css
  10. +36 −1 cms/static/cms/js/plugins/cms.base.js
  11. +45 −41 cms/static/cms/js/plugins/cms.modal.js
  12. +1 −1 cms/static/cms/js/plugins/cms.plugins.js
  13. +7 −0 cms/static/cms/js/plugins/cms.sideframe.js
  14. +2 −2 cms/static/cms/js/plugins/cms.structureboard.js
  15. +16 −17 cms/static/cms/js/plugins/cms.toolbar.js
  16. +3 −0 cms/static/cms/sass/modules/_structureboard.scss
  17. +5 −4 cms/templates/admin/cms/page/permissions.html
  18. +3 −0 cms/templates/admin/cms/page/tree/base.html
  19. +3 −3 cms/templates/admin/cms/page/tree/menu_item.html
  20. +1 −1 cms/templates/cms/toolbar/items/item_modal.html
  21. +1 −1 cms/templates/cms/toolbar/items/item_sideframe.html
  22. +2 −3 cms/templates/cms/toolbar/plugin.html
  23. +0 −1 cms/templates/cms/toolbar/toolbar.html
  24. +5 −0 cms/templates/cms/toolbar/toolbar_javascript.html
  25. +2 −0 cms/templatetags/cms_tags.py
  26. +0 −1 cms/test_utils/cli.py
  27. +1 −1 cms/tests/admin.py
  28. +84 −5 cms/tests/cache.py
  29. +36 −0 cms/tests/i18n.py
  30. +1 −1 cms/tests/multilingual.py
  31. +165 −60 cms/tests/toolbar.py
  32. +25 −2 cms/toolbar/toolbar.py
  33. +1 −0 cms/toolbar_base.py
  34. +93 −7 cms/views.py
  35. +49 −31 develop.py
  36. +4 −16 docs/extending_cms/api_references.rst
  37. +8 −0 docs/extending_cms/custom_plugins.rst
  38. +23 −0 docs/extending_cms/toolbar.rst
  39. +12 −0 docs/upgrade/3.0.rst
View
@@ -213,4 +213,5 @@ Please see Install/2.4 release notes *before* attempting to upgrade to version 2
- Publishing is now language independent and the tree-view has been updated to reflect this
- Removed the plugin DB-name magic and added a compatibility layer
- urls_need_reloading signal added when an apphook change is detected.
-- CMS_PAGE_CACHE, CMS_PLACEHOLDER_CACHE and CMS_PLUGIN_CACHE settings and functionality added. Default is True
+- CMS_PAGE_CACHE, CMS_PLACEHOLDER_CACHE and CMS_PLUGIN_CACHE settings and functionality added. Default is True
+- Detect admin object creation and changes via toolbar and redirect to them.
@@ -130,7 +130,7 @@ def get_urls(self):
pat(r'^([0-9]+)/([a-z\-]+)/unpublish/$', self.unpublish),
pat(r'^([0-9]+)/([a-z\-]+)/revert/$', self.revert_page),
pat(r'^([0-9]+)/([a-z\-]+)/preview/$', self.preview_page),
-
+ url(r'^resolve/$', self.resolve, name="cms_page_resolve"),
)
if plugin_pool.get_all_plugins():
@@ -1161,8 +1161,7 @@ def change_innavigation(self, request, page_id):
"""
page = get_object_or_404(Page, pk=page_id)
if page.has_change_permission(request):
- page.in_navigation = not page.in_navigation
- page.save()
+ page.toggle_in_navigation()
return admin_utils.render_admin_menu_item(request, page)
return HttpResponseForbidden(force_unicode(_("You do not have permission to change this page's in_navigation status")))
@@ -1178,6 +1177,29 @@ def descendants(self, request, page_id):
return admin_utils.render_admin_menu_item(request, page,
template="admin/cms/page/tree/lazy_menu.html")
+ def resolve(self, request):
+ if not request.user.is_staff:
+ return HttpResponse('/')
+ if request.session.get('cms_log_latest', False):
+ log = LogEntry.objects.get(pk=request.session['cms_log_latest'])
+ obj = log.get_edited_object()
+ del request.session['cms_log_latest']
+ try:
+ return HttpResponse(force_unicode(obj.get_absolute_url()))
+ except:
+ pass
+ pk = request.REQUEST.get('pk')
+ app_label, model = request.REQUEST.get('model').split('.')
+ if pk and app_label:
+ ctype = ContentType.objects.get(app_label=app_label, model=model)
+ try:
+ instance = ctype.get_object_for_this_type(pk=pk)
+ except ctype.model_class().DoesNotExist:
+ return HttpResponse('/')
+ return HttpResponse(force_unicode(instance.get_absolute_url()))
+ else:
+ return HttpResponse('/')
+
def lookup_allowed(self, key, *args, **kwargs):
if key == 'site__exact':
return True
View
@@ -120,6 +120,8 @@ def add_language_menu(self):
@toolbar_pool.register
class PageToolbar(CMSToolbar):
+ model = Title
+
def populate(self):
# always use draft if we have a page
self.page = get_page_draft(self.request.current_page)
@@ -7,15 +7,15 @@ def cms_settings(request):
"""
Adds cms-related variables to the context.
"""
-
+
return {
'CMS_MEDIA_URL': get_cms_setting('MEDIA_URL'),
'CMS_TEMPLATE': lambda: get_template_from_request(request),
}
def media(request):
- warnings.warn('cms.context_processors.media has been deprecated in favor of'
- 'cms.context_processors.cms_settings. Please update your'
+ warnings.warn('cms.context_processors.media has been deprecated in favor of '
+ 'cms.context_processors.cms_settings. Please update your '
'configuration', DeprecationWarning)
return cms_settings(request)
@@ -5,6 +5,7 @@
from cms.plugin_pool import plugin_pool
from cms.toolbar.toolbar import CMSToolbar
from cms.utils.i18n import force_language
+from django.contrib.admin.models import LogEntry
from menus.menu_pool import menu_pool
from django.http import HttpResponse
from django.template.loader import render_to_string
@@ -64,13 +65,14 @@ def process_request(self, request):
request.session['cms_build'] = False
if 'build' in request.GET and not request.session.get('cms_build', False):
request.session['cms_build'] = True
+ if request.user.is_staff:
+ request.session['cms_log_entries'] = LogEntry.objects.filter(user=request.user).count()
request.toolbar = CMSToolbar(request)
def process_view(self, request, view_func, view_args, view_kwarg):
response = request.toolbar.request_hook()
if isinstance(response, HttpResponse):
return response
- return None
def process_response(self, request, response):
from django.utils.cache import add_never_cache_headers
@@ -83,4 +85,11 @@ def process_response(self, request, response):
break
if found:
add_never_cache_headers(response)
- return response
+ if request.user.is_staff:
+ count = LogEntry.objects.filter(user=request.user).count()
+ if request.session.get('cms_log_entries', 0) < count:
+ request.session['cms_log_entries'] = count
+ log = LogEntry.objects.filter(user=request.user)[0]
+ if log.action_flag == 1 or log.action_flag == 2:
+ request.session['cms_log_latest'] = log.pk
+ return response
@@ -4,7 +4,7 @@
from os.path import join
from cms import constants
from cms.constants import PUBLISHER_STATE_DEFAULT, PUBLISHER_STATE_PENDING, PUBLISHER_STATE_DIRTY, TEMPLATE_INHERITANCE_MAGIC
-from cms.exceptions import PublicIsUnmodifiable, LanguageError
+from cms.exceptions import PublicIsUnmodifiable, LanguageError, PublicVersionNeeded
from cms.models.managers import PageManager, PagePermissionsPermissionManager
from cms.models.metaclasses import PageMetaClass
from cms.models.placeholdermodel import Placeholder
@@ -193,6 +193,9 @@ def move_page(self, target, position='first-child'):
public_page.save()
page_utils.check_title_slugs(public_page)
+ from cms.views import invalidate_cms_page_cache
+ invalidate_cms_page_cache()
+
def _copy_titles(self, target, language, published):
"""
Copy all the titles to a new page (which must have a pk).
@@ -318,6 +321,7 @@ def copy_page(self, target, site, position='first-child',
page.lft = None
page.tree_id = None
page.publisher_public_id = None
+ page.is_home = False
# only set reverse_id on standard copy
if page.reverse_id in site_reverse_ids:
page.reverse_id = None
@@ -477,6 +481,19 @@ def is_published(self, language, force_reload=False):
except Title.DoesNotExist:
return False
+ def toggle_in_navigation(self, set_to=None):
+ '''
+ Toggles (or sets) in_navigation and invalidates the cms page cache
+ '''
+ if set_to in [True, False]:
+ self.in_navigation = set_to
+ else:
+ self.in_navigation = not self.in_navigation
+ self.save()
+ from cms.views import invalidate_cms_page_cache
+ invalidate_cms_page_cache()
+ return self.in_navigation
+
def get_publisher_state(self, language, force_reload=False):
from cms.models import Title
@@ -579,10 +596,12 @@ def publish(self, language):
if page.publisher_public:
if page.publisher_public.parent.is_published(language):
from cms.models import Title
-
- public_title = Title.objects.get(page=page.publisher_public, language=language)
+ try:
+ public_title = Title.objects.get(page=page.publisher_public, language=language)
+ except Title.DoesNotExist:
+ public_title = None
draft_title = Title.objects.get(page=page, language=language)
- if not public_title.published:
+ if public_title and not public_title.published:
public_title._publisher_keep_state = True
public_title.published = True
public_title.publisher_state = PUBLISHER_STATE_DEFAULT
@@ -598,6 +617,9 @@ def publish(self, language):
cms_signals.post_publish.send(sender=Page, instance=self, language=language)
+ from cms.views import invalidate_cms_page_cache
+ invalidate_cms_page_cache()
+
return published
def unpublish(self, language):
@@ -628,8 +650,13 @@ def unpublish(self, language):
# trigger update home
self.save()
self.mark_descendants_pending(language)
+
+ from cms.views import invalidate_cms_page_cache
+ invalidate_cms_page_cache()
+
from cms.signals import post_unpublish
post_unpublish.send(sender=Page, instance=self, language=language)
+
return True
def mark_descendants_pending(self, language):
View
@@ -114,6 +114,8 @@ class CMSPluginBase(with_metaclass(CMSPluginBaseMetaclass, admin.ModelAdmin)):
require_parent = False
parent_classes = None
+ disable_child_plugin = False
+
cache = get_cms_setting('PLUGIN_CACHE')
opts = {}
@@ -26,6 +26,9 @@ def apphook_post_page_checker(page):
if (old_page and (
old_page.application_urls != page.application_urls or old_page.application_namespace != page.application_namespace)) or (
not old_page and page.application_urls):
+
+ from cms.views import invalidate_cms_page_cache
+ invalidate_cms_page_cache()
request_finished.connect(trigger_restart, dispatch_uid=DISPATCH_UID)
@@ -53,6 +56,8 @@ def apphook_post_delete_title_checker(instance, **kwargs):
Check if this was an apphook
"""
if instance.page.application_urls:
+ from cms.views import invalidate_cms_page_cache
+ invalidate_cms_page_cache()
request_finished.connect(trigger_restart, dispatch_uid=DISPATCH_UID)
@@ -61,6 +66,8 @@ def apphook_post_delete_page_checker(instance, **kwargs):
Check if this was an apphook
"""
if instance.application_urls:
+ from cms.views import invalidate_cms_page_cache
+ invalidate_cms_page_cache()
request_finished.connect(trigger_restart, dispatch_uid=DISPATCH_UID)
# import the logging library
Oops, something went wrong. Retry.

0 comments on commit b7137c2

Please sign in to comment.