Permalink
Browse files

Merge pull request #1563 from kux/issue_1476

Fix for issue 1476
  • Loading branch information...
digi604 committed Dec 19, 2012
2 parents 36f7c76 + 52638c3 commit 314eedcf027954c938ba2d9035659d3141bd0414
Showing with 23 additions and 0 deletions.
  1. +3 −0 cms/admin/forms.py
  2. +20 −0 cms/tests/admin.py
View
@@ -104,6 +104,9 @@ def clean(self):
except Site.DoesNotExist:
site = None
raise ValidationError("No site found for current settings.")
+
+ if parent and parent.site != site:
+ raise ValidationError("Site doesn't match the parent's page site")
if site and not is_valid_page_slug(page, parent, lang, slug, site):
self._errors['slug'] = ErrorList([_('Another page with this slug already exists')])
View
@@ -989,6 +989,26 @@ def test_clean_overwrite_url(self):
form = PageForm(data, instance=instance)
self.assertTrue(form.is_valid(), form.errors.as_text())
+ def test_missmatching_site_parent_dotsite(self):
+ site0 = Site.objects.create(domain='foo.com', name='foo.com')
+ site1 = Site.objects.create(domain='foo.com', name='foo.com')
+ parent_page = Page.objects.create(
+ template='nav_playground.html',
+ site=site0)
+ new_page_data = {
+ 'title': 'Title',
+ 'slug': 'slug',
+ 'language': 'en',
+ 'site': site1.pk,
+ 'template': settings.CMS_TEMPLATES[0][0],
+ 'reverse_id': '',
+ 'parent': parent_page.pk,
+ }
+ form = PageForm(data=new_page_data, files=None)
+ self.assertFalse(form.is_valid())
+ self.assertIn(u"Site doesn't match the parent's page site",
+ form.errors['__all__'])
+
def test_reverse_id_error_location(self):
''' Test moving the reverse_id validation error to a field specific one '''

0 comments on commit 314eedc

Please sign in to comment.