浏览代码

[refactor] Update code and tests in page bulk actions to work with changes in page bulk action url and reusable templatetags

Shohan 3 年之前
父节点
当前提交
0415ab4023

+ 1 - 1
wagtail/admin/templates/wagtailadmin/pages/index.html

@@ -21,7 +21,7 @@
             {% paginate pages base_url=pagination_base_url %}
         {% endif %}
         {% trans "Select all pages in listing" as select_all_text %}
-        {% include 'wagtailadmin/bulk_actions/footer.html' with select_all_obj_text=select_all_text %}
+        {% include 'wagtailadmin/bulk_actions/footer.html' with select_all_obj_text=select_all_text bulk_action_register_hook='register_page_bulk_action' %}
     </form>
 {% endblock %}
 

+ 1 - 9
wagtail/admin/templates/wagtailadmin/pages/search.html

@@ -21,13 +21,5 @@
     <div id="page-results">
         {% include "wagtailadmin/pages/search_results.html" %}
     </div>
-    <footer class="footer bulk-actions-choices hidden">
-        <div class="footer__container">
-            <div class="bulk-actions-filter-checkbox">
-                <input type="checkbox" aria-label="Bulk action checkbox" />
-            </div>
-            <ul>{% page_bulk_action_choices %}</ul>
-            <span class="num-pages"></span>
-        </div>
-    </footer>
+    {% include 'wagtailadmin/bulk_actions/footer.html' with bulk_action_register_hook='register_page_bulk_action' %}
 {% endblock %}

+ 1 - 1
wagtail/admin/templatetags/wagtailadmin_tags.py

@@ -506,7 +506,7 @@ def bulk_action_filters(context):
                         takes_context=True)
 def bulk_action_choices(context, hook_name):
     corresponding_urls = {
-        'register_page_bulk_action': 'wagtailadmin_bulk_action',
+        'register_page_bulk_action': 'wagtailadmin_page_bulk_action',
     }
     if hook_name not in corresponding_urls:
         return {'buttons': []}

+ 1 - 1
wagtail/admin/tests/pages/test_bulk_actions/test_bulk_delete.py

@@ -43,7 +43,7 @@ class TestBulkDelete(TestCase, WagtailTestUtils):
             for grandchild_page in grandchild_pages:
                 child_page.add_child(instance=grandchild_page)
 
-        self.url = reverse('wagtailadmin_bulk_action', args=('delete', )) + '?'
+        self.url = reverse('wagtailadmin_page_bulk_action', args=('delete', )) + '?'
         for child_page in self.pages_to_be_deleted:
             self.url += f'&id={child_page.id}'
 

+ 2 - 2
wagtail/admin/tests/pages/test_bulk_actions/test_bulk_move.py

@@ -58,7 +58,7 @@ class TestBulkMove(TestCase, WagtailTestUtils):
 
         self.pages_to_be_moved = [self.test_page_b, self.test_page_b_1]
 
-        self.url = reverse('wagtailadmin_bulk_action', args=('move', )) + f'?id={self.test_page_b.id}&id={self.test_page_b_1.id}'
+        self.url = reverse('wagtailadmin_page_bulk_action', args=('move', )) + f'?id={self.test_page_b.id}&id={self.test_page_b_1.id}'
 
         # Login
         self.user = self.login()
@@ -119,7 +119,7 @@ class TestBulkMove(TestCase, WagtailTestUtils):
         self.assertFalse(can_bulk_delete)
 
         response = self.client.get(
-            reverse('wagtailadmin_bulk_action', args=('move', )) + f'?id={self.unpublished_page.id}'
+            reverse('wagtailadmin_page_bulk_action', args=('move', )) + f'?id={self.unpublished_page.id}'
         )
 
         self.assertEqual(response.status_code, 200)

+ 3 - 3
wagtail/admin/tests/pages/test_bulk_actions/test_bulk_publish.py

@@ -27,7 +27,7 @@ class TestBulkPublish(TestCase, WagtailTestUtils):
         for child_page in self.child_pages:
             self.root_page.add_child(instance=child_page)
 
-        self.url = reverse('wagtailadmin_bulk_action', args=('publish', )) + '?'
+        self.url = reverse('wagtailadmin_page_bulk_action', args=('publish', )) + '?'
         for child_page in self.pages_to_be_published:
             self.url += f'id={child_page.id}&'
         self.redirect_url = reverse('wagtailadmin_explore', args=(self.root_page.id, ))
@@ -50,7 +50,7 @@ class TestBulkPublish(TestCase, WagtailTestUtils):
         This tests that the publish view returns an error if the page id is invalid
         """
         # Request confirm publish page but with illegal page id
-        response = self.client.get(reverse('wagtailadmin_bulk_action', args=('publish', )))
+        response = self.client.get(reverse('wagtailadmin_page_bulk_action', args=('publish', )))
 
         # Check that the user received a 404 response
         self.assertEqual(response.status_code, 404)
@@ -193,7 +193,7 @@ class TestBulkPublishIncludingDescendants(TestCase, WagtailTestUtils):
             for grandchild_page in grandchild_pages:
                 child_page.add_child(instance=grandchild_page)
 
-        self.url = reverse('wagtailadmin_bulk_action', args=('publish', )) + '?'
+        self.url = reverse('wagtailadmin_page_bulk_action', args=('publish', )) + '?'
         for child_page in self.pages_to_be_published:
             self.url += f'&id={child_page.id}'
 

+ 3 - 3
wagtail/admin/tests/pages/test_bulk_actions/test_bulk_unpublish.py

@@ -27,7 +27,7 @@ class TestBulkUnpublish(TestCase, WagtailTestUtils):
         for child_page in self.child_pages:
             self.root_page.add_child(instance=child_page)
 
-        self.url = reverse('wagtailadmin_bulk_action', args=('unpublish', )) + '?'
+        self.url = reverse('wagtailadmin_page_bulk_action', args=('unpublish', )) + '?'
         for child_page in self.pages_to_be_unpublished:
             self.url += f'&id={child_page.id}'
         self.redirect_url = reverse('wagtailadmin_explore', args=(self.root_page.id, ))
@@ -51,7 +51,7 @@ class TestBulkUnpublish(TestCase, WagtailTestUtils):
         This tests that the unpublish view returns an error if the page id is invalid
         """
         # Request confirm unpublish page but with illegal page id
-        response = self.client.get(reverse('wagtailadmin_bulk_action', args=('unpublish', )))
+        response = self.client.get(reverse('wagtailadmin_page_bulk_action', args=('unpublish', )))
 
         # Check that the user received a 404 response
         self.assertEqual(response.status_code, 404)
@@ -195,7 +195,7 @@ class TestBulkUnpublishIncludingDescendants(TestCase, WagtailTestUtils):
             for grandchild_page in grandchild_pages:
                 child_page.add_child(instance=grandchild_page)
 
-        self.url = reverse('wagtailadmin_bulk_action', args=('unpublish', )) + '?'
+        self.url = reverse('wagtailadmin_page_bulk_action', args=('unpublish', )) + '?'
         for child_page in self.pages_to_be_unpublished:
             self.url += f'&id={child_page.id}'
         self.redirect_url = reverse('wagtailadmin_explore', args=(self.root_page.id, ))

+ 1 - 1
wagtail/admin/urls/__init__.py

@@ -36,7 +36,7 @@ urlpatterns = [
     path('pages/<int:parent_page_id>/', listing.index, name='wagtailadmin_explore'),
 
     # bulk actions
-    path('pages/multiple/<str:action>/', bulk_actions, name='wagtailadmin_bulk_action'),
+    path('pages/multiple/<str:action>/', bulk_actions, name='wagtailadmin_page_bulk_action'),
 
     path('pages/', include(wagtailadmin_pages_urls, namespace='wagtailadmin_pages')),