Repository: django-cms/django-cms

Issue:
deleting a page with subpages give 500-
/home/nine-dev/app/local/lib/python2.7/site-packages/cms/models/pagemodel.py in mark_descendants_pending
                child.set_publisher_state(language, PUBLISHER_STATE_PENDING, published=False) ...
▶ Local vars
/home/nine-dev/app/local/lib/python2.7/site-packages/cms/models/pagemodel.py in set_publisher_state
        title = self.title_set.get(language=language) ...
▶ Local vars



Discussion:

Resolving patch:
diff --git a/cms/models/pagemodel.py b/cms/models/pagemodel.py
--- a/cms/models/pagemodel.py
+++ b/cms/models/pagemodel.py
@@ -682,10 +682,14 @@ def mark_descendants_pending(self, language):
         assert self.publisher_is_draft
         # Go through all children of our public instance
         public_page = self.publisher_public
+        from cms.models import Title
         if public_page:
             descendants = public_page.get_descendants()
             for child in descendants:
-                child.set_publisher_state(language, PUBLISHER_STATE_PENDING, published=False)
+                try:
+                    child.set_publisher_state(language, PUBLISHER_STATE_PENDING, published=False)
+                except Title.DoesNotExist:
+                    continue
                 draft = child.publisher_public
                 if draft and draft.is_published(language) and draft.get_publisher_state(
                         language) == PUBLISHER_STATE_DEFAULT:


Test patch:
diff --git a/cms/tests/admin.py b/cms/tests/admin.py
--- a/cms/tests/admin.py
+++ b/cms/tests/admin.py
@@ -298,6 +298,8 @@ def test_2apphooks_with_same_namespace(self):
 
     def test_delete(self):
         admin_user = self.get_superuser()
+        create_page("home", "nav_playground.html", "en",
+                           created_by=admin_user, published=True)
         page = create_page("delete-page", "nav_playground.html", "en",
                            created_by=admin_user, published=True)
         create_page('child-page', "nav_playground.html", "en",
@@ -311,6 +313,23 @@ def test_delete(self):
                 response = self.client.post(URL_CMS_PAGE_DELETE % page.pk, data)
             self.assertRedirects(response, URL_CMS_PAGE)
 
+    def test_delete_diff_language(self):
+        admin_user = self.get_superuser()
+        create_page("home", "nav_playground.html", "en",
+                           created_by=admin_user, published=True)
+        page = create_page("delete-page", "nav_playground.html", "en",
+                           created_by=admin_user, published=True)
+        create_page('child-page', "nav_playground.html", "de",
+                    created_by=admin_user, published=True, parent=page)
+        body = page.placeholders.get(slot='body')
+        add_plugin(body, 'TextPlugin', 'en', body='text')
+        page.publish('en')
+        with self.login_user_context(admin_user):
+            data = {'post': 'yes'}
+            with self.assertNumQueries(FuzzyInt(300, 382)):
+                response = self.client.post(URL_CMS_PAGE_DELETE % page.pk, data)
+            self.assertRedirects(response, URL_CMS_PAGE)
+
     def test_search_fields(self):
         superuser = self.get_superuser()
         from django.contrib.admin import site