Permalink
Browse files

Merge pull request #2720 from digi604/fix-2675

fixes #2675 (toolbar language must be in LANGUAGES)
  • Loading branch information...
2 parents 396beb5 + 4f8bb7b commit a9c6838d333d0f9ad0d183dca2834cb4b284fac7 @digi604 digi604 committed Feb 26, 2014
Showing with 21 additions and 1 deletion.
  1. +15 −0 cms/tests/toolbar.py
  2. +6 −1 cms/toolbar/toolbar.py
View
@@ -1,4 +1,5 @@
from __future__ import with_statement
+from cms.models import UserSettings
import re
from django.template.defaultfilters import truncatewords
import datetime
@@ -263,6 +264,20 @@ def test_user_settings(self):
response = self.client.get('/en/admin/cms/usersettings/')
self.assertEqual(response.status_code, 200)
+ def test_remove_lang(self):
+ page = create_page('test', 'nav_playground.html', 'en', published=True)
+ superuser = self.get_superuser()
+ with self.login_user_context(superuser):
+ response = self.client.get('/en/?edit')
+ self.assertEqual(response.status_code, 200)
+ setting = UserSettings.objects.get(user=superuser)
+ setting.language = 'it'
+ setting.save()
+ with SettingsOverride(LANGUAGES=(('en', 'english'),)):
+ response = self.client.get('/en/?edit')
+ self.assertEqual(response.status_code, 200)
+ self.assertNotContains(response, '/it/')
+
def test_get_alphabetical_insert_position(self):
page = create_page("toolbar-page", "nav_playground.html", "en",
published=True)
View
@@ -62,7 +62,12 @@ def __init__(self, request):
placeholder.save()
user_settings.clipboard = placeholder
user_settings.save()
- self.toolbar_language = user_settings.language
+ if (settings.USE_I18N and user_settings.language in dict(settings.LANGUAGES)) or (
+ not settings.USE_I18N and user_settings.language == settings.LANGUAGE_CODE):
+ self.toolbar_language = user_settings.language
+ else:
+ user_settings.language = self.language
+ user_settings.save()
self.clipboard = user_settings.clipboard
with force_language(self.language):
try:

0 comments on commit a9c6838

Please sign in to comment.