Skip to content

Commit

Permalink
removed flat urls
Browse files Browse the repository at this point in the history
  • Loading branch information
digi604 committed Oct 4, 2012
1 parent 4b968ce commit 3e4a6f9
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 61 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Expand Up @@ -119,6 +119,8 @@
- CMS_SITE_LANGUAGES setting removed
- CMS_FRONTEND_LANGUAGES setting removed
- MultilingualMiddleware has been removed
- CMS_FLAT_URLS has been removed




Expand Down
3 changes: 0 additions & 3 deletions cms/conf/__init__.py
Expand Up @@ -16,9 +16,6 @@ def patch_settings():
return
patch_settings.ALREADY_PATCHED = True

if getattr(settings, 'CMS_FLAT_URLS', False):
warnings.warn("CMS_FLAT_URLS are deprecated and will be removed in django CMS 2.4!", CMSDeprecationWarning)

if getattr(settings, 'CMS_MODERATOR', False):
warnings.warn("CMS_MODERATOR will be removed and replaced in django CMS 2.4!", CMSDeprecationWarning)

Expand Down
3 changes: 0 additions & 3 deletions cms/conf/global_settings.py
Expand Up @@ -64,9 +64,6 @@
# a tuple of python path to AppHook Classes. Overwrites the auto-discovered apphooks.
CMS_APPHOOKS = ()

#Should the tree of the pages be also be displayed in the urls? or should a flat slug structure be used?
CMS_FLAT_URLS = False

# Wheter the cms has a softroot functionionality
CMS_SOFTROOT = False

Expand Down
3 changes: 0 additions & 3 deletions cms/models/pagemodel.py
Expand Up @@ -116,9 +116,6 @@ def __unicode__(self):
def get_absolute_url(self, language=None, fallback=True):
if self.is_home():
return reverse('pages-root')
if settings.CMS_FLAT_URLS:
path = self.get_slug(language, fallback)
return urlutils.urljoin(reverse('pages-root'), path)
path = self.get_path(language, fallback)
return reverse('pages-details-by-slug', kwargs={"slug":path})

Expand Down
1 change: 0 additions & 1 deletion cms/test_utils/cli.py
Expand Up @@ -195,7 +195,6 @@ def configure(**extra):
CMS_APPHOOKS=[],
CMS_REDIRECTS = True,
CMS_SEO_FIELDS = True,
CMS_FLAT_URLS = False,
CMS_MENU_TITLE_OVERWRITE = True,
CMS_URL_OVERWRITE = True,
CMS_SHOW_END_DATE = True,
Expand Down
23 changes: 1 addition & 22 deletions cms/tests/page.py
Expand Up @@ -406,28 +406,7 @@ def test_edit_page_other_site_and_language(self):
page = Page.objects.get(title_set__slug=page_data['slug'])
with LanguageOverride(TESTLANG):
self.assertEqual(page.get_title(), 'changed title')

def test_flat_urls(self):
with SettingsOverride(CMS_FLAT_URLS=True):
home_slug = "home"
child_slug = "child"
grandchild_slug = "grandchild"
home = create_page(home_slug, "nav_playground.html", "en",
published=True, in_navigation=True)
home.publish()
child = create_page(child_slug, "nav_playground.html", "en",
parent=home, published=True, in_navigation=True)
child.publish()
grandchild = create_page(grandchild_slug, "nav_playground.html", "en",
parent=child, published=True, in_navigation=True)
grandchild.publish()
response = self.client.get(home.get_absolute_url())
self.assertEqual(response.status_code, 200)
response = self.client.get(child.get_absolute_url())
self.assertEqual(response.status_code, 200)
response = self.client.get(grandchild.get_absolute_url())
self.assertEqual(response.status_code, 200)
self.assertFalse(child.get_absolute_url() in grandchild.get_absolute_url())


def test_templates(self):
"""
Expand Down
15 changes: 7 additions & 8 deletions cms/utils/page.py
Expand Up @@ -20,15 +20,14 @@ def is_valid_page_slug(page, parent, lang, slug, site, path=None):
if settings.USE_I18N:
qs = qs.filter(language=lang)

if not settings.CMS_FLAT_URLS:
if parent:
if parent.is_home():
qs = qs.filter(Q(page__parent=parent) |
Q(page__parent__isnull=True))
else:
qs = qs.filter(page__parent=parent)
if parent:
if parent.is_home():
qs = qs.filter(Q(page__parent=parent) |
Q(page__parent__isnull=True))
else:
qs = qs.filter(page__parent__isnull=True)
qs = qs.filter(page__parent=parent)
else:
qs = qs.filter(page__parent__isnull=True)

if page.pk:
qs = qs.exclude(Q(language=lang) & Q(page=page))
Expand Down
6 changes: 1 addition & 5 deletions cms/utils/page_resolver.py
Expand Up @@ -73,11 +73,7 @@ def get_page_queryset_from_path(path, preview=False, site=None):

# title_set__path=path should be clear, get the pages where the path of the
# title object is equal to our path.
if settings.CMS_FLAT_URLS:
query = Q(title_set__slug=path)
else:
query = Q(title_set__path=path)
return pages.filter(query).distinct()
return pages.filter(title_set__path=path).distinct()


def get_page_from_path(path, preview=False):
Expand Down
16 changes: 0 additions & 16 deletions docs/getting_started/configuration.rst
Expand Up @@ -425,22 +425,6 @@ accessed.
Note: Don't use this too much. :mod:`django.contrib.redirects` is much more
flexible, handy, and is designed exactly for this purpose.

.. setting:: CMS_FLAT_URLS

CMS_FLAT_URLS
=============

.. deprecated:: 2.4

``CMS_FLAT_URLS`` will be removed in 2.4.

Default: ``False``

If this is enabled the slugs are not nested in the urls.

So a page with a "world" slug will have a "/world" url, even it is a child of
the "hello" page. If disabled the page would have the url: "/hello/world/"

.. setting:: CMS_SOFTROOT

CMS_SOFTROOT
Expand Down
8 changes: 8 additions & 0 deletions docs/upgrade/2.4.rst
Expand Up @@ -123,6 +123,14 @@ The following settings are not needed any more and have been removed:
Please remove them from your settings.py


CMS_FLAT_URLS
=============

Was marked deprecated in 2.3 and has now been removed.




..
Feature description
Expand Down

0 comments on commit 3e4a6f9

Please sign in to comment.