Skip to content
Permalink
Browse files

Merged stale PR's (#6759)

* add missing changelog entries

* update docs

* updated changelog

* updates from comments

* merge #6347

* merged #6530

* merge #6538

* merge #6549

* merge #6704

* changelog for #6705
  • Loading branch information
FinalAngel committed Nov 8, 2019
1 parent 4379f09 commit a94fbb498babde06b1d8ac6a118fa5958e6c07dd
@@ -289,6 +289,7 @@ Contributors (based on gitlog, 543 unique authors):
* Keryn Knight
* Kevin Burton
* Kevin Funk
* Kevin Möllering
* Kevin Richardson
* Kim Thoenen
* kochin
@@ -1,11 +1,22 @@
=== 3.7.1 (unreleased) ===

* Fixed ``ValueError`` when creating a ``Site``-bound ``StaticPlaceholder``
* Updated branch policy
* Improved and simplified permissions documentation
* Improved apphooks documentation
* Improved CMSPluginBase documentation
* Improved documentation related to nested plugins
* Fixed a bug where creating a page via the ``cms.api.create_page`` ignores
left/right positions.
* Fixed documentation example for ``urls.py`` when using multiple languages.
* Mark public static placeholder dirty when published.
* Fixed a bug where ``request.current_page`` would always be the public page,
regardless of the toolbar status (draft / live). This only affected custom
urls from an apphook.
* Fixed a bug where the menu would render draft pages even if the page on
the request was a public page. This happens when a user without change
permissions requests edit mode.
* Prevent non-staff users to login with the django CMS toolbar
* Added missing ``{% trans %}?? to toolbar shortcuts.
* Updated branch policy.
* Improved and simplified permissions documentation.
* Improved apphooks documentation.
* Improved CMSPluginBase documentation.
* Improved documentation related to nested plugins.


=== 3.7.0 (2019-09-25) ===
@@ -96,7 +96,7 @@ def add_sibling(self, pos=None, *args, **kwargs):
kwargs['instance'].parent_id = self.parent_id
else:
kwargs['parent_id'] = self.parent_id
return super(TreeNode, self).add_sibling(*args, **kwargs)
return super(TreeNode, self).add_sibling(pos, *args, **kwargs)

def update(self, **data):
cls = self.__class__
@@ -70,6 +70,7 @@ def clean(self):
def publish(self, request, language, force=False):
if force or self.has_publish_permission(request):
self.public.clear(language=language)
self.public.clear_cache(language=language)
plugins = self.draft.get_plugins_list(language=language)
copy_plugins_to(plugins, self.public, no_signals=True)
self.dirty = False
@@ -42,7 +42,7 @@
'unhandledPageChange': '{% filter escapejs %}{% trans "The page was changed in the meantime, reloading..." %}{% endfilter %}',
'shortcutAreas': [
{
'title': 'CMS-wide Shortcuts',
'title': '{% filter escapejs %}{% trans "CMS-wide Shortcuts" %}{% endfilter %}',
'shortcuts': {
'help': {
'shortcut': '?',
@@ -71,7 +71,7 @@
}
},
{
'title': 'Structureboard',
'title': '{% filter escapejs %}{% trans "Structureboard" %}{% endfilter %}',
'shortcuts': {
'placeholders': {
'shortcut': 'f > p / alt+p',
@@ -242,3 +242,12 @@ def test_create_page_assert_parent_is_draft(self):
def test_create_page_page_title(self):
page = create_page(**dict(self._get_default_create_page_arguments(), page_title='page title'))
self.assertEqual(page.get_title_obj_attribute('page_title'), 'page title')

def test_create_page_with_position_regression_6345(self):
# ref: https://github.com/divio/django-cms/issues/6345
parent = create_page('p', 'nav_playground.html', 'en')
rightmost = create_page('r', 'nav_playground.html', 'en', parent=parent)
leftmost = create_page('l', 'nav_playground.html', 'en', parent=rightmost, position='left')
create_page('m', 'nav_playground.html', 'en', parent=leftmost, position='right')
children_titles = list(p.get_title('de') for p in parent.get_child_pages())
self.assertEqual(children_titles, ['l', 'm', 'r'])
@@ -504,6 +504,28 @@ def test_show_menu_cache_key_leak(self):
tpl.render(context)
self.assertEqual(CacheKey.objects.count(), 1)

def test_menu_nodes_request_page_takes_precedence(self):
"""
Tests a condition where the user requests a draft page
but the page object on the request is a public page.
This can happen when the user has no permissions to edit
the requested draft page.
"""
public_page = self.get_page(1)
draft_page = public_page.publisher_public
edit_on_path = draft_page.get_absolute_url() + '?%s' % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON')

with self.login_user_context(self.get_superuser()):
context = self.get_context(path=edit_on_path, page=public_page)
context['request'].session['cms_edit'] = True
Template("{% load menu_tags %}{% show_menu %}").render(context)
# All nodes should be public nodes because the request page is public
nodes = [node for node in context['children']]
node_ids = [node.id for node in nodes]
page_count = Page.objects.public().filter(pk__in=node_ids).count()
self.assertEqual(len(node_ids), page_count, msg='Not all pages in the public menu are public')
self.assertEqual(nodes[0].selected, True)

def test_menu_cache_draft_only(self):
# Tests that the cms uses a separate cache for draft & live
public_page = self.get_page(1)
@@ -24,23 +24,23 @@ on the subject.

Here's a full example of ``urls.py``::

from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.conf.urls.i18n import i18n_patterns, JavascriptCatalog
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.i18n import JavaScriptCatalog

admin.autodiscover()

urlpatterns = [
url(r'^jsi18n/(?P<packages>\S+?)/$', JavascriptCatalog.as_view()),
]
admin.autodiscover()

urlpatterns = i18n_patterns(
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),
)
urlpatterns += staticfiles_urlpatterns()

# note the django CMS URLs included via i18n_patterns
urlpatterns += i18n_patterns('',
url(r'^admin/', admin.site.urls),
urlpatterns += i18n_patterns(
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('cms.urls')),
)

@@ -104,7 +104,6 @@ def __init__(self, pool, request):
self.request = request
self.request_language = get_language_from_request(request, check_path=True)
self.site = Site.objects.get_current(request)
self.draft_mode_active = use_draft(request)

@property
def cache_key(self):
@@ -121,6 +120,17 @@ def cache_key(self):
key += ':public'
return key

@cached_property
def draft_mode_active(self):
try:
# Under certain conditions, the request page won't match
# the requested state.
# For example, user requests draft page but gets public.
_use_draft = self.request.current_page.publisher_is_draft
except AttributeError:
_use_draft = use_draft(self.request)
return _use_draft

@cached_property
def is_cached(self):
db_cache_key_lookup = CacheKey.objects.filter(

0 comments on commit a94fbb4

Please sign in to comment.
You can’t perform that action at this time.