Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request django-cms#1 from digi604/new_toolbar
plugin in plugins merge
  • Loading branch information
Angelo Dini committed Oct 30, 2012
2 parents 7527aaa + 2067f4c commit 20bbd65
Show file tree
Hide file tree
Showing 355 changed files with 19,889 additions and 14,408 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -30,7 +30,7 @@ eggs
parts
bin
/dist
*.rst~
*~
/docs/*.html
distribute-*.tar.gz
include/
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -4,10 +4,10 @@ python:
- "2.6"
- "2.7"
env:
- DJANGO="django>=1.3,<1.4"
- DJANGO="django>=1.4,<1.5"
- DJANGO=test_requirements/django-1.3.txt
- DJANGO=test_requirements/django-1.4.txt
install:
- pip install -q $DJANGO django-mptt==0.5.1 django-reversion==1.6 django-classy-tags==0.3.4.1 django-sekizai==0.6.1 html5lib==0.95 jinja2==2.6 PIL==1.1.7 pygments==1.5 south==0.7.5 sphinx==1.1.3 argparse
- pip install -q -r $DJANGO --use-mirrors
script:
python runtests.py
notifications:
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -92,6 +92,7 @@ Contributors (in alphabetical order):
* Ian Lewis
* indexofire
* Ionel Cristian Maries
* Iván Raskovsky
* Ivan Vershigora
* izi
* Jameel Al-Aziz
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.txt
Expand Up @@ -110,6 +110,18 @@

- fixed an incompatibility with Python 2.5

==== 2.4.0 ===-

- CMS_LANGUAGE setting has changed
- CMS_HIDE_UNTRANSLATED setting removed
- CMS_LANGUAGE_FALLBACK setting removed
- CMS_LANGUAGE_CONF setting removed
- CMS_SITE_LANGUAGES setting removed
- CMS_FRONTEND_LANGUAGES setting removed
- MultilingualMiddleware has been removed
- CMS_FLAT_URLS has been removed





Expand Down
27 changes: 10 additions & 17 deletions cms/admin/forms.py
Expand Up @@ -3,6 +3,7 @@
from cms.forms.widgets import UserSelectAdminWidget
from cms.models import (Page, PagePermission, PageUser, ACCESS_PAGE,
PageUserGroup)
from cms.utils.i18n import get_language_tuple, get_language_list
from cms.utils.mail import mail_page_user_change
from cms.utils.page import is_valid_page_slug
from cms.utils.page_resolver import get_page_from_path, is_valid_url
Expand Down Expand Up @@ -60,7 +61,7 @@ class PageAddForm(forms.ModelForm):
help_text=_('The default title'))
slug = forms.CharField(label=_("Slug"), widget=forms.TextInput(),
help_text=_('The part of the title that is used in the URL'))
language = forms.ChoiceField(label=_("Language"), choices=settings.CMS_LANGUAGES,
language = forms.ChoiceField(label=_("Language"), choices=get_language_tuple(),
help_text=_('The current language of the content fields.'))

class Meta:
Expand All @@ -74,13 +75,7 @@ def __init__(self, *args, **kwargs):
if not self.fields['site'].initial:
self.fields['site'].initial = Site.objects.get_current().pk
site_id = self.fields['site'].initial
languages = []
language_mappings = dict(settings.LANGUAGES)
if site_id in settings.CMS_SITE_LANGUAGES:
for lang in settings.CMS_SITE_LANGUAGES[site_id]:
languages.append((lang, language_mappings.get(lang, lang)))
else:
languages = settings.CMS_LANGUAGES
languages = get_language_tuple(site_id)
self.fields['language'].choices = languages
if not self.fields['language'].initial:
self.fields['language'].initial = get_language()
Expand All @@ -92,10 +87,7 @@ def __init__(self, *args, **kwargs):

def clean(self):
cleaned_data = self.cleaned_data
if 'slug' in cleaned_data.keys():
slug = cleaned_data['slug']
else:
slug = ""
slug = cleaned_data.get('slug', '')

page = self.instance
lang = cleaned_data.get('language', None)
Expand All @@ -121,17 +113,18 @@ def clean(self):
#AdminFormsTests.test_clean_overwrite_url validates the form with when no page instance available
#Looks like just a theoretical corner case
title = page.get_title_obj(lang)
if title:
if title and slug:
oldslug = title.slug
title.slug = self.cleaned_data['slug']
title.slug = slug
title.save()
try:
is_valid_url(title.path,page)
except ValidationError,e:
title.slug = oldslug
title.save()
del cleaned_data['published']
self._errors['published'] = ErrorList(e.messages)
if 'slug' in cleaned_data:
del cleaned_data['slug']
self._errors['slug'] = ErrorList(e.messages)
return cleaned_data

def clean_slug(self):
Expand All @@ -142,7 +135,7 @@ def clean_slug(self):

def clean_language(self):
language = self.cleaned_data['language']
if not language in dict(settings.CMS_LANGUAGES).keys():
if not language in get_language_list():
raise ValidationError("Given language does not match language settings.")
return language

Expand Down

0 comments on commit 20bbd65

Please sign in to comment.