Repository: django-cms/django-cms

Issue:
If delete title: unpublish sub titles.
If you hit delete translation: sub titles are not unpublished and set to pending



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
@@ -608,19 +608,24 @@ def unpublish(self, language):
         public_page.save()
         # trigger update home
         self.save()
-        # Go through all children of our public instance
-        descendants = public_page.get_descendants()
-        for child in descendants:
-            child.set_publisher_state(language, PUBLISHER_STATE_PENDING, published=False)
-            draft = child.publisher_public
-            if draft and draft.is_published(language) and draft.get_publisher_state(
-                    language) == PUBLISHER_STATE_DEFAULT:
-                draft.set_publisher_state(language, PUBLISHER_STATE_PENDING)
+        self.mark_descendants_pending(language)
         from cms.signals import post_unpublish
-
         post_unpublish.send(sender=Page, instance=self, language=language)
         return True
 
+    def mark_descendants_pending(self, language):
+        assert self.publisher_is_draft
+        # Go through all children of our public instance
+        public_page = self.publisher_public
+        if public_page:
+            descendants = public_page.get_descendants()
+            for child in descendants:
+                child.set_publisher_state(language, PUBLISHER_STATE_PENDING, published=False)
+                draft = child.publisher_public
+                if draft and draft.is_published(language) and draft.get_publisher_state(
+                        language) == PUBLISHER_STATE_DEFAULT:
+                    draft.set_publisher_state(language, PUBLISHER_STATE_PENDING)
+
     def revert(self, language):
         """Revert the draft version to the same state as the public version
         """
diff --git a/cms/signals/title.py b/cms/signals/title.py
--- a/cms/signals/title.py
+++ b/cms/signals/title.py
@@ -91,6 +91,8 @@ def pre_delete_title(instance, **kwargs):
         instance.page.languages = ",".join(languages)
         instance.page._publisher_keep_state = True
         instance.page.save(no_signals=True)
+    if instance.publisher_is_draft:
+        instance.page.mark_descendants_pending(instance.language)
 
 
 def post_delete_title(instance, **kwargs):


Test patch:
diff --git a/cms/tests/publisher.py b/cms/tests/publisher.py
--- a/cms/tests/publisher.py
+++ b/cms/tests/publisher.py
@@ -393,6 +393,13 @@ def test_unpublish_unpublish(self):
         self.assertObjectExist(drafts, title_set__title=name)
         self.assertObjectExist(published, title_set__title=name)
 
+    def test_delete_title_unpublish(self):
+        page = self.create_page('test', published=True)
+        sub_page = self.create_page('test2', published=True, parent=page)
+        self.assertTrue(sub_page.publisher_public.is_published('en'))
+        page.title_set.all().delete()
+        self.assertFalse(sub_page.publisher_public.is_published('en', force_reload=True))
+
     def test_modify_child_while_pending(self):
         home = self.create_page("Home", published=True, in_navigation=True)
         child = self.create_page("Child", published=True, parent=home,