Browse Source

Remove Page.get_static_site_paths (#8536)

Fixes #8535
yass19 2 years ago
parent
commit
0221457a67

+ 1 - 0
CHANGELOG.txt

@@ -9,6 +9,7 @@ Changelog
  * Maintenance: Update djhtml (html formatting) library to v 1.5.2 (Loveth Omokaro)
  * Maintenance: Re-enable `strictPropertyInitialization` in tsconfig (Thibaud Colas)
  * Maintenance: Refactor accessibility checker userbar item (Albina Starykova)
+ * Maintenance: Removed unused `Page.get_static_site_paths` method (Yosr Karoui)
 
 
 4.2 (xx.xx.xxxx) - IN DEVELOPMENT

+ 1 - 0
CONTRIBUTORS.rst

@@ -685,6 +685,7 @@ Contributors
 * Nick Lee
 * Beniamin Bucur
 * Ananjan-R
+* Yosr Karoui
 
 Translators
 ===========

+ 7 - 4
docs/releases/5.0.md

@@ -27,10 +27,13 @@ depth: 1
 
 ### Maintenance
 
- * Maintenance: Update djhtml (html formatting) library to v 1.5.2 (Loveth Omokaro)
- * Maintenance: Re-enable `strictPropertyInitialization` in tsconfig (Thibaud Colas)
- * Maintenance: Refactor accessibility checker userbar item (Albina Starykova)
+ * Update djhtml (html formatting) library to v 1.5.2 (Loveth Omokaro)
+ * Re-enable `strictPropertyInitialization` in tsconfig (Thibaud Colas)
+ * Refactor accessibility checker userbar item (Albina Starykova)
+ * Removed unused `Page.get_static_site_paths` method (Yosr Karoui)
 
 ## Upgrade considerations
 
-### ...
+### `Page.get_static_site_paths` method removed
+
+The undocumented `Page.get_static_site_paths` method (which returns a generator of URL paths for use by static site generator packages) has been removed. Packages relying on this functionality should provide their own fallback implementation.

+ 0 - 13
wagtail/models/__init__.py

@@ -2523,19 +2523,6 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
             }
         ]
 
-    def get_static_site_paths(self):
-        """
-        This is a generator of URL paths to feed into a static site generator
-        Override this if you would like to create static versions of subpages
-        """
-        # Yield path for this page
-        yield "/"
-
-        # Yield paths for child pages
-        for child in self.get_children().live():
-            for path in child.specific.get_static_site_paths():
-                yield "/" + child.slug + path
-
     def get_ancestors(self, inclusive=False):
         """
         Returns a queryset of the current page's ancestors, starting at the root page

+ 0 - 12
wagtail/test/testapp/models.py

@@ -517,18 +517,6 @@ class EventIndex(Page):
 
         return super().route(request, path_components)
 
-    def get_static_site_paths(self):
-        # Get page count
-        page_count = self.get_paginator().num_pages
-
-        # Yield a path for each page
-        for page in range(page_count):
-            yield "/%d/" % (page + 1)
-
-        # Yield from superclass
-        for path in super().get_static_site_paths():
-            yield path
-
     def get_sitemap_urls(self, request=None):
         # Add past events url to sitemap
         return super().get_sitemap_urls(request=request) + [

+ 0 - 58
wagtail/tests/test_page_model.py

@@ -838,64 +838,6 @@ class TestServeView(TestCase):
         self.assertContains(response, "bad googlebot no cookie")
 
 
-class TestStaticSitePaths(TestCase):
-    def setUp(self):
-        self.root_page = Page.objects.get(id=1)
-
-        # For simple tests
-        self.home_page = self.root_page.add_child(
-            instance=SimplePage(title="Homepage", slug="home2", content="hello")
-        )
-        self.about_page = self.home_page.add_child(
-            instance=SimplePage(title="About us", slug="about", content="hello")
-        )
-        self.contact_page = self.home_page.add_child(
-            instance=SimplePage(title="Contact", slug="contact", content="hello")
-        )
-
-        # For custom tests
-        self.event_index = self.root_page.add_child(
-            instance=EventIndex(title="Events", slug="events")
-        )
-        for i in range(20):
-            self.event_index.add_child(
-                instance=EventPage(
-                    title="Event " + str(i),
-                    slug="event" + str(i),
-                    location="the moon",
-                    audience="public",
-                    cost="free",
-                    date_from="2001-01-01",
-                )
-            )
-
-    def test_local_static_site_paths(self):
-        paths = list(self.about_page.get_static_site_paths())
-
-        self.assertEqual(paths, ["/"])
-
-    def test_child_static_site_paths(self):
-        paths = list(self.home_page.get_static_site_paths())
-
-        self.assertEqual(paths, ["/", "/about/", "/contact/"])
-
-    def test_custom_static_site_paths(self):
-        paths = list(self.event_index.get_static_site_paths())
-
-        # Event index path
-        expected_paths = ["/"]
-
-        # One path for each page of results
-        expected_paths.extend(["/" + str(i + 1) + "/" for i in range(5)])
-
-        # One path for each event page
-        expected_paths.extend(["/event" + str(i) + "/" for i in range(20)])
-
-        paths.sort()
-        expected_paths.sort()
-        self.assertEqual(paths, expected_paths)
-
-
 class TestMovePage(TestCase):
     fixtures = ["test.json"]