From 6e823ba8bf457fac5180fab1a99c0a710dbfd3fe Mon Sep 17 00:00:00 2001 From: David Lee Date: Mon, 10 Feb 2014 13:53:14 -0800 Subject: [PATCH 01/51] fix for setting inheritance on a page --- cms/models/pagemodel.py | 3 ++- cms/utils/conf.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cms/models/pagemodel.py b/cms/models/pagemodel.py index 2bbeae311dc..7c6378ce259 100644 --- a/cms/models/pagemodel.py +++ b/cms/models/pagemodel.py @@ -38,6 +38,7 @@ class Page(with_metaclass(PageMetaClass, MPTTModel)): (1, _('for logged in users only')), (2, _('for anonymous users only')), ) + TEMPLATE_DEFAULT = TEMPLATE_INHERITANCE_MAGIC if get_cms_setting('TEMPLATE_INHERITANCE') else get_cms_setting('TEMPLATES')[0][0] template_choices = [(x, _(y)) for x, y in get_cms_setting('TEMPLATES')] @@ -60,7 +61,7 @@ class Page(with_metaclass(PageMetaClass, MPTTModel)): navigation_extenders = models.CharField(_("attached menu"), max_length=80, db_index=True, blank=True, null=True) template = models.CharField(_("template"), max_length=100, choices=template_choices, help_text=_('The template used to render the content.'), - default=TEMPLATE_INHERITANCE_MAGIC) + default=TEMPLATE_DEFAULT) site = models.ForeignKey(Site, help_text=_('The site the page is accessible at.'), verbose_name=_("site"), related_name='djangocms_pages') diff --git a/cms/utils/conf.py b/cms/utils/conf.py index c1845b68041..7a7c5d87477 100644 --- a/cms/utils/conf.py +++ b/cms/utils/conf.py @@ -75,7 +75,8 @@ def get_media_url(): def get_templates(): templates = list(getattr(settings, 'CMS_TEMPLATES', [])) - templates.append((constants.TEMPLATE_INHERITANCE_MAGIC, _('Inherit the template of the nearest ancestor'))) + if get_cms_setting('TEMPLATE_INHERITANCE'): + templates.append((constants.TEMPLATE_INHERITANCE_MAGIC, _('Inherit the template of the nearest ancestor'))) return templates From 859867cdc47cb1bbbd64ee7e9d4db182272a9da9 Mon Sep 17 00:00:00 2001 From: David Lee Date: Mon, 10 Feb 2014 14:45:58 -0800 Subject: [PATCH 02/51] temp reverting #2606 change as it is blowing up --- cms/utils/django_load.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cms/utils/django_load.py b/cms/utils/django_load.py index bb333379629..0b51e7a78e2 100644 --- a/cms/utils/django_load.py +++ b/cms/utils/django_load.py @@ -9,7 +9,6 @@ For documentation on how to use the functions described in this file, please refer to http://django-load.readthedocs.org/en/latest/index.html. """ -import imp import traceback # changed from django.conf import settings @@ -23,7 +22,7 @@ def get_module(app, modname, verbose, failfast): # the module *should* exist - raise an error if it doesn't app_mod = import_module(app) try: - imp.find_module(modname, app_mod.__path__) + module = import_module(module_name) except ImportError: # this ImportError will be due to the module not existing # so here we can silently ignore it. But an ImportError @@ -35,8 +34,6 @@ def get_module(app, modname, verbose, failfast): traceback.print_exc() # changed return None - module = import_module(module_name) - if verbose: print(u"Loaded %r from %r" % (modname, app)) return module From 79da7760f775eaa34c8bdd5490ac88f783d8394d Mon Sep 17 00:00:00 2001 From: David Lee Date: Mon, 10 Feb 2014 21:30:43 -0800 Subject: [PATCH 03/51] removing the spaceless tags as it mucks with html output --- cms/templates/cms/toolbar/content.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cms/templates/cms/toolbar/content.html b/cms/templates/cms/toolbar/content.html index 506975ccf64..7cb70396425 100644 --- a/cms/templates/cms/toolbar/content.html +++ b/cms/templates/cms/toolbar/content.html @@ -1,8 +1,7 @@ -{# render the placeholder within placeholder.html - this is optional, you need to pass the edit context #}{% spaceless %} +{# render the placeholder within placeholder.html - this is optional, you need to pass the edit context #} {% if edit and placeholder %} {{ placeholder }} {% endif %} {# render the content within plugin.html #} -{{ content }} -{% endspaceless %} \ No newline at end of file +{{ content }} \ No newline at end of file From 019c21cda6be865e51261a6559794efacaaeb9d9 Mon Sep 17 00:00:00 2001 From: Patrick Lauber Date: Tue, 25 Feb 2014 17:54:26 +0100 Subject: [PATCH 04/51] fixes the backend part --- cms/admin/change_list.py | 6 +++++- cms/admin/pageadmin.py | 3 ++- cms/cms_toolbar.py | 9 ++++++--- cms/templates/admin/cms/page/tree/menu_item.html | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cms/admin/change_list.py b/cms/admin/change_list.py index bac01247051..f70e816fccb 100644 --- a/cms/admin/change_list.py +++ b/cms/admin/change_list.py @@ -62,6 +62,10 @@ def __init__(self, request, *args, **kwargs): def get_query_set(self, request=None): if COPY_VAR in self.params: del self.params[COPY_VAR] + if 'language' in self.params: + del self.params['language'] + if 'page_id' in self.params: + del self.params['page_id'] if django.VERSION[1] > 3: qs = super(CMSChangeList, self).get_query_set(request).drafts() else: @@ -82,7 +86,7 @@ def get_query_set(self, request=None): def is_filtered(self): from cms.utils.plugins import SITE_VAR lookup_params = self.params.copy() # a dictionary of the query string - for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, SITE_VAR): + for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, SITE_VAR, 'language', 'page_id'): if i in lookup_params: del lookup_params[i] if not lookup_params.items() and not self.query: diff --git a/cms/admin/pageadmin.py b/cms/admin/pageadmin.py index 0d709c207df..eef24f3003e 100644 --- a/cms/admin/pageadmin.py +++ b/cms/admin/pageadmin.py @@ -20,7 +20,7 @@ from django.shortcuts import render_to_response, get_object_or_404 from django.template.context import RequestContext from django.template.defaultfilters import escape -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, get_language from django.utils.decorators import method_decorator from django.views.decorators.http import require_POST @@ -636,6 +636,7 @@ def changelist_view(self, request, extra_context=None): 'has_add_permission': self.has_add_permission(request), 'root_path': reverse('admin:index'), 'app_label': app_label, + 'preview_language': request.GET.get('language', get_language()), 'CMS_MEDIA_URL': get_cms_setting('MEDIA_URL'), 'CMS_PERMISSION': get_cms_setting('PERMISSION'), 'DEBUG': settings.DEBUG, diff --git a/cms/cms_toolbar.py b/cms/cms_toolbar.py index 9ce972467f4..0def7ee7d06 100644 --- a/cms/cms_toolbar.py +++ b/cms/cms_toolbar.py @@ -101,7 +101,7 @@ def add_admin_menu(self): for site in sites_queryset: sites_menu.add_link_item(site.name, url='http://%s' % site.domain, active=site.pk == self.current_site.pk) - # admin + # admin admin_menu.add_sideframe_item(_('Administration'), url=reverse('admin:index')) admin_menu.add_break(ADMINISTRATION_BREAK) # cms users @@ -138,7 +138,7 @@ def populate(self): self.change_admin_menu() if self.page: self.add_page_menu() - # history menu + # history menu if self.page and self.toolbar.edit_mode: self.add_history_menu() self.change_language_menu() @@ -247,7 +247,10 @@ def change_language_menu(self): def change_admin_menu(self): admin_menu = self.toolbar.get_or_create_menu(ADMIN_MENU_IDENTIFIER) # cms page admin - admin_menu.add_sideframe_item(_('Pages'), url=reverse("admin:cms_page_changelist"), position=0) + url = "%s?language=%s" % (reverse("admin:cms_page_changelist"), self.toolbar.language) + if self.page: + url += "&page_id=%s" % self.page.pk + admin_menu.add_sideframe_item(_('Pages'), url=url, position=0) def add_page_menu(self): # menu for current page diff --git a/cms/templates/admin/cms/page/tree/menu_item.html b/cms/templates/admin/cms/page/tree/menu_item.html index 6956b7ec706..aeb69054451 100644 --- a/cms/templates/admin/cms/page/tree/menu_item.html +++ b/cms/templates/admin/cms/page/tree/menu_item.html @@ -3,7 +3,9 @@
{% if has_change_permission %} - {{ page.get_admin_tree_title }} + {% language preview_language %} + {{ page.get_admin_tree_title }} + {% endlanguage %} {% else %} {{ page.get_admin_tree_title }} {% endif %} From ac804871b44ee67f182d586f43988b289a9fb2b9 Mon Sep 17 00:00:00 2001 From: David Lee Date: Tue, 25 Feb 2014 19:03:11 -0800 Subject: [PATCH 05/51] reverting temp import module change --- cms/utils/django_load.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cms/utils/django_load.py b/cms/utils/django_load.py index 0b51e7a78e2..bb333379629 100644 --- a/cms/utils/django_load.py +++ b/cms/utils/django_load.py @@ -9,6 +9,7 @@ For documentation on how to use the functions described in this file, please refer to http://django-load.readthedocs.org/en/latest/index.html. """ +import imp import traceback # changed from django.conf import settings @@ -22,7 +23,7 @@ def get_module(app, modname, verbose, failfast): # the module *should* exist - raise an error if it doesn't app_mod = import_module(app) try: - module = import_module(module_name) + imp.find_module(modname, app_mod.__path__) except ImportError: # this ImportError will be due to the module not existing # so here we can silently ignore it. But an ImportError @@ -34,6 +35,8 @@ def get_module(app, modname, verbose, failfast): traceback.print_exc() # changed return None + module = import_module(module_name) + if verbose: print(u"Loaded %r from %r" % (modname, app)) return module From 406229dc353a67a384b8b975a26678d8f06b9f1b Mon Sep 17 00:00:00 2001 From: David Lee Date: Tue, 25 Feb 2014 20:19:09 -0800 Subject: [PATCH 06/51] adding tests --- cms/tests/settings.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cms/tests/settings.py b/cms/tests/settings.py index cfdc5b70a67..9843b9ffcbd 100644 --- a/cms/tests/settings.py +++ b/cms/tests/settings.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import with_statement +from cms import constants from cms.test_utils.testcases import CMSTestCase from cms.test_utils.util.context_managers import SettingsOverride from cms.utils import get_cms_setting @@ -27,3 +28,22 @@ def test_invalid_language_code(self): ImproperlyConfigured, get_cms_setting, 'LANGUAGES' ) + + def test_create_page_with_inheritance_override(self): + with SettingsOverride(CMS_TEMPLATE_INHERITANCE=True): + for template in get_cms_setting('TEMPLATES'): + if (template[0] == constants.TEMPLATE_INHERITANCE_MAGIC): + return + self.assertRaises( + ImproperlyConfigured, + get_cms_setting, 'TEMPLATES' + ) + + def test_create_page_without_inheritance_override(self): + with SettingsOverride(CMS_TEMPLATE_INHERITANCE=False): + for template in get_cms_setting('TEMPLATES'): + if (template[0] == constants.TEMPLATE_INHERITANCE_MAGIC): + self.assertRaises( + ImproperlyConfigured, + get_cms_setting, 'TEMPLATES' + ) From 40b705c3148d1d6bdee3d4b089d79def4c12a153 Mon Sep 17 00:00:00 2001 From: FinalAngel Date: Wed, 26 Feb 2014 13:36:54 +0100 Subject: [PATCH 07/51] remove tabs --- .../admin/cms/page/tree/menu_item.html | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cms/templates/admin/cms/page/tree/menu_item.html b/cms/templates/admin/cms/page/tree/menu_item.html index aeb69054451..b45357ca53f 100644 --- a/cms/templates/admin/cms/page/tree/menu_item.html +++ b/cms/templates/admin/cms/page/tree/menu_item.html @@ -3,9 +3,9 @@
{% if has_change_permission %} - {% language preview_language %} + {% language preview_language %} {{ page.get_admin_tree_title }} - {% endlanguage %} + {% endlanguage %} {% else %} {{ page.get_admin_tree_title }} {% endif %} @@ -24,9 +24,9 @@ {% if page.soft_root or page.is_home %}
{% endif %} {% if page.application_urls %}
{% endif %} - {% for lang in site_languages %} + {% for lang in site_languages %}
- {% if has_change_permission %} + {% if has_change_permission %} {% tree_publish_row page lang %} {% if lang in page.languages %} - {% endfor %} -
+ {% endfor %} +