Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #1348 corrected page_language_url on non CMS managed urls

The language chooser wasn't translating the urls on non managed CMS
views. simple_language_changer was deprecated since now that's the
default behavior.

Added the base 2.4 release notes.
  • Loading branch information...
commit 4cff31972e577c6715f9bcafb73cf29a3da0f223 1 parent dc00224
@rasca rasca authored
View
1  AUTHORS
@@ -88,6 +88,7 @@ Contributors (in alphabetical order):
* Ian Lewis
* indexofire
* Ionel Cristian Maries
+* Iván Raskovsky
* Ivan Vershigora
* izi
* Jameel Al-Aziz
View
17 cms/tests/menu_utils.py
@@ -31,6 +31,22 @@ def test_simple_language_changer(self):
output = tag.get_context(fake_context, 'ja')
url = output['content']
self.assertEqual(url, '/ja/')
+
+ def test_default_language_changer(self):
+ view = self.get_simple_view()
+ # check we maintain the view name
+ self.assertEqual(view.__name__, view.__name__)
+ request = self.get_request('/', 'en')
+ response = view(request)
+ self.assertEqual(response.content, '')
+ fake_context = {'request': request}
+ tag = DumbPageLanguageUrl()
+ output = tag.get_context(fake_context, 'en')
+ url = output['content']
+ self.assertEqual(url, '/en/')
+ output = tag.get_context(fake_context, 'ja')
+ url = output['content']
+ self.assertEqual(url, '/ja/')
def test_language_changer_decorator(self):
def lang_changer(lang):
@@ -58,4 +74,3 @@ def test_find_selected(self):
nodes = [root]
selected = find_selected(nodes)
self.assertEqual(selected, selectedchild)
-
View
10 docs/advanced/i18n.rst
@@ -98,6 +98,10 @@ For the language chooser to work the
simple_language_changer
=======================
+.. deprecated:: 2.3.1
+
+ ``simple_language_changer`` will be removed in 2.5.
+
If the URLs of your views don't actually change besides the language prefix,
you can use the :func:`menus.utils.simple_language_changer` view decorator,
instead of manually using `set_language_changer`::
@@ -132,6 +136,6 @@ If you put :setting:`CMS_HIDE_UNTRANSLATED` to ``False`` in your
not translated yet.
If :setting:`CMS_HIDE_UNTRANSLATED` is ``True`` in your ``settings.py``
-and you are on a page that doesn't yet have an English translatio and you view the
-German version then the language chooser will redirect to ``/``. The same goes
-for urls that are not handled by the cms and display a language chooser.
+and you are on a page that doesn't yet have an English translation and you view
+the German version then the language chooser will redirect to ``/``. The same
+goes for urls that are not handled by the cms and display a language chooser.
View
37 docs/upgrade/2.4.rst
@@ -0,0 +1,37 @@
+#################
+2.4 release notes
+#################
+
+*****************
+What's new in 2.4
+*****************
+
+..
+ New feature
+ ===========
+
+..
+ Feature description
+
+Minor improvements
+==================
+
+.. * Some minor improvement.
+
+
+******************************
+Backwards incompatible changes
+******************************
+
+New minimum requirements for dependencies
+=========================================
+
+.. * ``package`` must now be at version X.Y
+
+
+********************
+Pending deprecations
+********************
+
+* ``simple_language_changer`` will be removed in version 2.5. A bugfix makes
+ this redundant as every non managed url will behave like this.
View
11 docs/upgrade/index.rst
@@ -4,6 +4,15 @@ Upgrading a django CMS installation
***********
+2.4 Release
+***********
+
+.. toctree::
+ :maxdepth: 1
+
+ 2.4
+
+***********
2.3 Release
***********
@@ -28,4 +37,4 @@ Upgrade from 2.1.x
.. toctree::
:maxdepth: 1
- 2.1
+ 2.1
View
30 menus/templatetags/menu_tags.py
@@ -9,6 +9,7 @@
from django.core.urlresolvers import reverse
from django.utils.translation import activate, get_language, ugettext
from menus.menu_pool import menu_pool
+from menus.utils import NonManagedLanguageChanger
import urllib
register = template.Library()
@@ -357,21 +358,22 @@ def get_context(self, context, lang):
request = context['request']
except KeyError:
return {'template': 'cms/content.html'}
+
if hasattr(request, "_language_changer"):
- try:
- setattr(request._language_changer, 'request', request)
- except AttributeError:
- pass
url = "/%s" % lang + request._language_changer(lang)
else:
- page = request.current_page
- if page == "dummy":
- return {'content': ''}
- try:
- url = page.get_absolute_url(language=lang, fallback=False)
- url = "/" + lang + url
- except:
- # no localized path/slug.
- url = ''
- return {'content':url}
+ page = getattr(request, 'current_page', None)
+ if page:
+ if page == "dummy":
+ return {'content': ''}
+ try:
+ url = page.get_absolute_url(language=lang, fallback=False)
+ url = "/" + lang + url
+ except:
+ # no localized path/slug.
+ url = ''
+ else:
+ # this is a non cms managed url with no language_changer
+ url = "/%s" % lang + NonManagedLanguageChanger(request)(lang)
+ return {'content': url}
register.tag(PageLanguageUrl)
View
10 menus/utils.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+import warnings
+
from cms.models.titlemodels import Title
@@ -66,7 +68,7 @@ def _wrapped(request, *args, **kwargs):
return _wrapped
return _decorator
-class _SimpleLanguageChanger(object):
+class NonManagedLanguageChanger(object):
def __init__(self, request):
self.request = request
self._app_path = None
@@ -94,9 +96,11 @@ def get_page_path(self, lang):
return ''
def simple_language_changer(func):
+ warnings.warn("simple_language_chooser is deprecated and will be removed in 2.5!", DeprecationWarning)
+
def _wrapped(request, *args, **kwargs):
- set_language_changer(request, _SimpleLanguageChanger(request))
+ set_language_changer(request, NonManagedLanguageChanger(request))
return func(request, *args, **kwargs)
_wrapped.__name__ = func.__name__
_wrapped.__doc__ = func.__doc__
- return _wrapped
+ return _wrapped
Please sign in to comment.
Something went wrong with that request. Please try again.