Permalink
Browse files

Merge branch 'develop' into no-seo

Conflicts:
	CHANGELOG.txt
  • Loading branch information...
2 parents c43a66c + 7d0182d commit 1b2bdaf437b79453e8b6ec3c2bc6c6248822db57 @digi604 committed May 3, 2013
Showing with 17 additions and 15 deletions.
  1. +1 −0 CHANGELOG.txt
  2. +1 −0 cms/tests/rendering.py
  3. +10 −9 cms/views.py
  4. +5 −6 docs/advanced/i18n.rst
View
1 CHANGELOG.txt
@@ -154,6 +154,7 @@ Please see Install/2.4 release notes *before* attempting to upgrade to version 2
- New frontend editing
- New Toolbar
- Plugin API for creating new plugins and moving has changed
+- render_to_response replaced with TemplateResponse in cms.views
- CMS_SEO_FIELDS removed and seo fields better integrated
- meta_keywords field removed as not relevant anymore
- CMS_MENU_TITLE_OVERWRITE default changed to True
View
1 cms/tests/rendering.py
@@ -144,6 +144,7 @@ def test_details_view(self):
with SettingsOverride(CMS_TEMPLATES=[(TEMPLATE_NAME, '')]):
from cms.views import details
response = details(self.get_request(self.test_page), '')
+ response.render()
r = self.strip_rendered(response.content)
self.assertEqual(r, u'|'+self.test_data['text_main']+u'|'+self.test_data['text_sub']+u'|')
View
19 cms/views.py
@@ -1,24 +1,25 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
+from django.template.response import TemplateResponse
from cms.apphook_pool import apphook_pool
from cms.appresolver import get_app_urls
from cms.models import Title
from cms.utils import get_template_from_request, get_language_from_request
-from cms.utils.i18n import get_fallback_languages, force_language, get_public_languages, get_redirect_on_fallback, get_language_list, is_language_prefix_patterns_used
+from cms.utils.i18n import get_fallback_languages, force_language, get_public_languages, get_redirect_on_fallback, \
+ get_language_list, is_language_prefix_patterns_used
from cms.utils.page_resolver import get_page_from_request
from cms.test_utils.util.context_managers import SettingsOverride
from django.conf import settings
-from django.conf.urls.defaults import patterns
+from django.conf.urls import patterns
from django.core.urlresolvers import resolve, Resolver404, reverse
from django.http import Http404, HttpResponseRedirect
-from django.shortcuts import render_to_response
from django.template.context import RequestContext
-from django.utils import translation
from django.utils.http import urlquote
+
def _handle_no_page(request, slug):
if not slug and settings.DEBUG:
- return render_to_response("cms/new.html", RequestContext(request))
+ return TemplateResponse(request, "cms/new.html", RequestContext(request))
raise Http404('CMS: Page not found for "%s"' % slug)
@@ -51,7 +52,7 @@ def details(request, slug):
attrs = '?preview=1'
if 'draft' in request.GET:
attrs += '&draft=1'
- # Check that the language is in FRONTEND_LANGUAGES:
+ # Check that the language is in FRONTEND_LANGUAGES:
if not current_language in user_languages:
#are we on root?
if not slug:
@@ -113,11 +114,11 @@ def details(request, slug):
return view(request, *args, **kwargs)
except Resolver404:
pass
- # Check if the page has a redirect url defined for this language.
+ # Check if the page has a redirect url defined for this language.
redirect_url = page.get_redirect(language=current_language)
if redirect_url:
if (is_language_prefix_patterns_used() and redirect_url[0] == "/"
- and not redirect_url.startswith('/%s/' % current_language)):
+ and not redirect_url.startswith('/%s/' % current_language)):
# add language prefix to url
redirect_url = "/%s/%s" % (current_language, redirect_url.lstrip("/"))
# prevent redirect to self
@@ -145,4 +146,4 @@ def details(request, slug):
if not context['has_view_permissions']:
return _handle_no_page(request, slug)
- return render_to_response(template_name, context_instance=context)
+ return TemplateResponse(request, template_name, context)
View
11 docs/advanced/i18n.rst
@@ -47,15 +47,14 @@ By default if someone visits a page at `http://www.mysite.fr/` django determines
- language in from browser
- LANGUAGE_CODE from settings
-No if i have a German browser and visit a page that is only English and French, it will choose the language that is
-in LANGUAGE_CODE. If this is English but i only speak French i have to switch the language. No if after sometime
-i visit the page again. The page will display in English again and I have to switch again. The same is for every
-link that points to `/` will switch to English again. To fix this behavior the cms ships with a middleware:
+When visiting a page that is only English and French with a German browser, the language from LANGUAGE_CODE will be used.
+If this is English, but the visitor only speaks French, the visitor will have to switch the language.
+Visiting the same page now again after some time, will show it in English again, because the browser session which was
+used to store the language selection doesn't exist anymore. To prevent this issue, a middleware exists which stores the
+language selection in a cookie. Add the following middleware to `MIDDLEWARE_CLASSES`:
`cms.middleware.language.LanguageCookieMiddleware`
-add this to you middleware settings fix this.
-
****************
Language Chooser
****************

0 comments on commit 1b2bdaf

Please sign in to comment.