wagtail 6.3.2__py3-none-any.whl → 6.4rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. wagtail/__init__.py +1 -1
  2. wagtail/actions/publish_revision.py +4 -5
  3. wagtail/admin/auth.py +0 -2
  4. wagtail/admin/checks.py +1 -1
  5. wagtail/admin/filters.py +3 -1
  6. wagtail/admin/forms/account.py +21 -11
  7. wagtail/admin/forms/collections.py +2 -9
  8. wagtail/admin/forms/formsets.py +32 -0
  9. wagtail/admin/forms/pages.py +5 -1
  10. wagtail/admin/forms/workflows.py +2 -13
  11. wagtail/admin/locale/ar/LC_MESSAGES/django.mo +0 -0
  12. wagtail/admin/locale/ar/LC_MESSAGES/django.po +68 -1
  13. wagtail/admin/locale/ar/LC_MESSAGES/djangojs.mo +0 -0
  14. wagtail/admin/locale/ar/LC_MESSAGES/djangojs.po +5 -1
  15. wagtail/admin/locale/en/LC_MESSAGES/django.po +312 -356
  16. wagtail/admin/locale/en/LC_MESSAGES/djangojs.po +21 -16
  17. wagtail/admin/menu.py +0 -13
  18. wagtail/admin/panels/base.py +2 -2
  19. wagtail/admin/panels/group.py +4 -1
  20. wagtail/admin/panels/inline_panel.py +5 -2
  21. wagtail/admin/panels/model_utils.py +36 -0
  22. wagtail/admin/panels/page_utils.py +2 -40
  23. wagtail/admin/panels/signal_handlers.py +0 -2
  24. wagtail/admin/static/wagtailadmin/css/core.css +1 -1
  25. wagtail/admin/static/wagtailadmin/css/panels/draftail.css +1 -1
  26. wagtail/admin/static/wagtailadmin/css/panels/streamfield.css +1 -1
  27. wagtail/admin/static/wagtailadmin/js/comments.js +1 -1
  28. wagtail/admin/static/wagtailadmin/js/core.js +1 -1
  29. wagtail/admin/static/wagtailadmin/js/core.js.LICENSE.txt +1 -8
  30. wagtail/admin/static/wagtailadmin/js/draftail.js +1 -1
  31. wagtail/admin/static/wagtailadmin/js/modal-workflow.js +1 -1
  32. wagtail/admin/static/wagtailadmin/js/page-chooser-modal.js +1 -1
  33. wagtail/admin/static/wagtailadmin/js/privacy-switch.js +1 -1
  34. wagtail/admin/static/wagtailadmin/js/sidebar.js +1 -1
  35. wagtail/admin/static/wagtailadmin/js/telepath/blocks.js +1 -1
  36. wagtail/admin/static/wagtailadmin/js/userbar.js +1 -1
  37. wagtail/admin/static/wagtailadmin/js/userbar.js.LICENSE.txt +1 -1
  38. wagtail/admin/static/wagtailadmin/js/vendor.js +1 -1
  39. wagtail/admin/static/wagtailadmin/js/vendor.js.LICENSE.txt +7 -0
  40. wagtail/admin/templates/wagtailadmin/404.html +4 -0
  41. wagtail/admin/templates/wagtailadmin/chooser/browse.html +2 -1
  42. wagtail/admin/templates/wagtailadmin/chooser/tables/parent_page_cell.html +1 -1
  43. wagtail/admin/templates/wagtailadmin/collections/_privacy_switch.html +8 -1
  44. wagtail/admin/templates/wagtailadmin/generic/confirm_delete.html +15 -9
  45. wagtail/admin/templates/wagtailadmin/generic/confirm_unpublish.html +21 -25
  46. wagtail/admin/templates/wagtailadmin/generic/form.html +1 -1
  47. wagtail/admin/templates/wagtailadmin/generic/preview_error.html +3 -0
  48. wagtail/admin/templates/wagtailadmin/generic/revisions/compare.html +63 -76
  49. wagtail/admin/templates/wagtailadmin/pages/_editor_js.html +0 -2
  50. wagtail/admin/templates/wagtailadmin/pages/edit.html +1 -5
  51. wagtail/admin/templates/wagtailadmin/panels/inline_panel_child.html +1 -0
  52. wagtail/admin/templates/wagtailadmin/permissions/includes/collection_member_permissions_form.html +1 -1
  53. wagtail/admin/templates/wagtailadmin/permissions/includes/collection_member_permissions_formset.html +6 -22
  54. wagtail/admin/templates/wagtailadmin/shared/formatted_field.html +2 -2
  55. wagtail/admin/templates/wagtailadmin/shared/header.html +2 -2
  56. wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.html +32 -39
  57. wagtail/admin/templates/wagtailadmin/shared/revisions/confirm_unschedule.html +13 -17
  58. wagtail/admin/templates/wagtailadmin/shared/side_panels/includes/status/privacy.html +15 -3
  59. wagtail/admin/templates/wagtailadmin/shared/side_panels/preview.html +1 -1
  60. wagtail/admin/templates/wagtailadmin/skeleton.html +4 -2
  61. wagtail/admin/templates/wagtailadmin/workflows/create.html +1 -1
  62. wagtail/admin/templates/wagtailadmin/workflows/edit.html +1 -1
  63. wagtail/admin/templates/wagtailadmin/workflows/includes/workflow_pages_form.html +1 -1
  64. wagtail/admin/templates/wagtailadmin/workflows/includes/workflow_pages_formset.html +6 -23
  65. wagtail/admin/templatetags/wagtailadmin_tags.py +12 -0
  66. wagtail/admin/templatetags/wagtailuserbar.py +2 -3
  67. wagtail/admin/tests/pages/test_create_page.py +110 -1
  68. wagtail/admin/tests/pages/test_edit_page.py +3 -2
  69. wagtail/admin/tests/pages/test_explorer_view.py +18 -0
  70. wagtail/admin/tests/pages/test_page_usage.py +24 -20
  71. wagtail/admin/tests/pages/test_preview.py +69 -1
  72. wagtail/admin/tests/pages/test_revisions.py +40 -6
  73. wagtail/admin/tests/test_account_management.py +39 -1
  74. wagtail/admin/tests/test_audit_log.py +4 -2
  75. wagtail/admin/tests/test_block_preview.py +224 -0
  76. wagtail/admin/tests/test_edit_handlers.py +23 -6
  77. wagtail/admin/tests/test_page_chooser.py +50 -3
  78. wagtail/admin/tests/test_privacy.py +49 -26
  79. wagtail/admin/tests/test_site_summary.py +15 -10
  80. wagtail/admin/tests/test_templatetags.py +19 -0
  81. wagtail/admin/tests/test_userbar.py +82 -1
  82. wagtail/admin/tests/test_views_generic.py +27 -12
  83. wagtail/admin/tests/test_workflows.py +69 -0
  84. wagtail/admin/tests/tests.py +23 -4
  85. wagtail/admin/tests/ui/test_sidebar.py +1 -1
  86. wagtail/admin/tests/viewsets/test_model_viewset.py +15 -13
  87. wagtail/admin/ui/side_panels.py +7 -4
  88. wagtail/admin/urls/__init__.py +6 -0
  89. wagtail/admin/urls/pages.py +1 -1
  90. wagtail/admin/userbar.py +21 -1
  91. wagtail/admin/views/account.py +5 -0
  92. wagtail/admin/views/chooser.py +5 -1
  93. wagtail/admin/views/collections.py +0 -2
  94. wagtail/admin/views/generic/base.py +20 -10
  95. wagtail/admin/views/generic/history.py +0 -1
  96. wagtail/admin/views/generic/models.py +79 -21
  97. wagtail/admin/views/generic/preview.py +50 -1
  98. wagtail/admin/views/mixins.py +4 -2
  99. wagtail/admin/views/pages/bulk_actions/delete.py +11 -23
  100. wagtail/admin/views/pages/bulk_actions/page_bulk_action.py +17 -0
  101. wagtail/admin/views/pages/bulk_actions/publish.py +11 -31
  102. wagtail/admin/views/pages/bulk_actions/unpublish.py +11 -31
  103. wagtail/admin/views/pages/create.py +1 -0
  104. wagtail/admin/views/pages/edit.py +38 -30
  105. wagtail/admin/views/pages/revisions.py +43 -114
  106. wagtail/admin/views/pages/utils.py +0 -1
  107. wagtail/admin/views/tags.py +6 -2
  108. wagtail/admin/views/workflows.py +8 -6
  109. wagtail/admin/viewsets/model.py +0 -4
  110. wagtail/admin/viewsets/pages.py +0 -1
  111. wagtail/admin/widgets/tags.py +1 -0
  112. wagtail/api/v2/tests/test_documents.py +4 -2
  113. wagtail/api/v2/tests/test_images.py +4 -2
  114. wagtail/api/v2/tests/test_pages.py +8 -4
  115. wagtail/blocks/base.py +59 -1
  116. wagtail/blocks/field_block.py +6 -0
  117. wagtail/blocks/list_block.py +4 -0
  118. wagtail/blocks/static_block.py +3 -0
  119. wagtail/blocks/stream_block.py +5 -1
  120. wagtail/blocks/struct_block.py +6 -0
  121. wagtail/compat.py +16 -0
  122. wagtail/contrib/forms/forms.py +27 -7
  123. wagtail/contrib/forms/locale/en/LC_MESSAGES/django.po +2 -2
  124. wagtail/contrib/forms/tests/test_models.py +7 -5
  125. wagtail/contrib/forms/tests/test_views.py +75 -0
  126. wagtail/contrib/frontend_cache/tasks.py +83 -0
  127. wagtail/contrib/frontend_cache/tests.py +47 -32
  128. wagtail/contrib/frontend_cache/utils.py +2 -70
  129. wagtail/contrib/redirects/base_formats.py +2 -2
  130. wagtail/contrib/redirects/locale/ar/LC_MESSAGES/django.mo +0 -0
  131. wagtail/contrib/redirects/locale/ar/LC_MESSAGES/django.po +3 -0
  132. wagtail/contrib/redirects/locale/en/LC_MESSAGES/django.po +24 -37
  133. wagtail/contrib/redirects/templates/wagtailredirects/add.html +1 -24
  134. wagtail/contrib/redirects/templates/wagtailredirects/confirm_delete.html +3 -13
  135. wagtail/contrib/redirects/tests/test_redirects.py +122 -110
  136. wagtail/contrib/redirects/tests/test_signal_handlers.py +75 -69
  137. wagtail/contrib/redirects/urls.py +2 -2
  138. wagtail/contrib/redirects/views.py +35 -73
  139. wagtail/contrib/search_promotions/admin_urls.py +10 -3
  140. wagtail/contrib/search_promotions/forms.py +55 -26
  141. wagtail/contrib/search_promotions/locale/en/LC_MESSAGES/django.po +44 -54
  142. wagtail/contrib/search_promotions/templates/wagtailsearchpromotions/add.html +21 -31
  143. wagtail/contrib/search_promotions/templates/wagtailsearchpromotions/confirm_delete.html +3 -12
  144. wagtail/contrib/search_promotions/templates/wagtailsearchpromotions/edit.html +11 -34
  145. wagtail/contrib/search_promotions/templates/wagtailsearchpromotions/includes/searchpromotion_form.html +1 -0
  146. wagtail/contrib/search_promotions/templates/wagtailsearchpromotions/includes/searchpromotions_formset.js +2 -1
  147. wagtail/contrib/search_promotions/templates/wagtailsearchpromotions/index.html +0 -1
  148. wagtail/contrib/search_promotions/tests.py +814 -13
  149. wagtail/contrib/search_promotions/views/__init__.py +1 -0
  150. wagtail/contrib/search_promotions/views/reports.py +56 -0
  151. wagtail/contrib/search_promotions/views/settings.py +258 -0
  152. wagtail/contrib/search_promotions/wagtail_hooks.py +12 -1
  153. wagtail/contrib/settings/locale/ar/LC_MESSAGES/django.mo +0 -0
  154. wagtail/contrib/settings/locale/ar/LC_MESSAGES/django.po +6 -1
  155. wagtail/contrib/settings/locale/en/LC_MESSAGES/django.po +3 -3
  156. wagtail/contrib/settings/templates/wagtailsettings/edit.html +1 -5
  157. wagtail/contrib/settings/tests/generic/test_admin.py +2 -5
  158. wagtail/contrib/settings/tests/generic/test_register.py +1 -1
  159. wagtail/contrib/settings/tests/site_specific/test_admin.py +2 -5
  160. wagtail/contrib/settings/tests/site_specific/test_register.py +1 -1
  161. wagtail/contrib/settings/views.py +9 -23
  162. wagtail/contrib/simple_translation/locale/en/LC_MESSAGES/django.po +1 -1
  163. wagtail/contrib/styleguide/locale/en/LC_MESSAGES/django.po +1 -1
  164. wagtail/contrib/table_block/locale/en/LC_MESSAGES/django.po +1 -1
  165. wagtail/contrib/table_block/tests.py +4 -1
  166. wagtail/contrib/typed_table_block/blocks.py +3 -0
  167. wagtail/contrib/typed_table_block/locale/en/LC_MESSAGES/django.po +10 -10
  168. wagtail/contrib/typed_table_block/static/typed_table_block/js/typed_table_block.js +1 -1
  169. wagtail/contrib/typed_table_block/tests.py +33 -0
  170. wagtail/documents/locale/en/LC_MESSAGES/django.po +26 -26
  171. wagtail/documents/migrations/0011_add_choose_permissions.py +1 -0
  172. wagtail/documents/models.py +1 -0
  173. wagtail/documents/signal_handlers.py +6 -2
  174. wagtail/documents/static/wagtaildocs/js/add-multiple.js +1 -1
  175. wagtail/documents/templates/wagtaildocs/documents/edit.html +1 -3
  176. wagtail/documents/templates/wagtaildocs/multiple/add.html +7 -1
  177. wagtail/documents/tests/test_admin_views.py +74 -33
  178. wagtail/documents/tests/test_views.py +21 -12
  179. wagtail/documents/views/chooser.py +1 -0
  180. wagtail/documents/views/documents.py +1 -2
  181. wagtail/documents/views/multiple.py +0 -1
  182. wagtail/documents/views/serve.py +9 -2
  183. wagtail/documents/wagtail_hooks.py +6 -1
  184. wagtail/embeds/locale/en/LC_MESSAGES/django.po +1 -1
  185. wagtail/embeds/oembed_providers.py +0 -64
  186. wagtail/fields.py +3 -0
  187. wagtail/images/apps.py +2 -1
  188. wagtail/images/blocks.py +6 -2
  189. wagtail/images/forms.py +40 -3
  190. wagtail/images/locale/ar/LC_MESSAGES/django.mo +0 -0
  191. wagtail/images/locale/ar/LC_MESSAGES/django.po +4 -0
  192. wagtail/images/locale/en/LC_MESSAGES/django.po +49 -49
  193. wagtail/images/migrations/0023_add_choose_permissions.py +1 -0
  194. wagtail/images/rich_text/contentstate.py +1 -0
  195. wagtail/images/rich_text/editor_html.py +1 -0
  196. wagtail/images/signal_handlers.py +17 -10
  197. wagtail/images/static/wagtailimages/js/add-multiple.js +1 -1
  198. wagtail/images/static/wagtailimages/js/image-block.js +1 -1
  199. wagtail/images/static/wagtailimages/js/image-chooser-telepath.js +1 -1
  200. wagtail/images/static/wagtailimages/js/image-chooser.js +1 -1
  201. wagtail/images/static/wagtailimages/js/image-url-generator.js +1 -1
  202. wagtail/images/static/wagtailimages/js/vendor/jquery.fileupload-image.js +1 -1
  203. wagtail/images/tasks.py +18 -0
  204. wagtail/images/templates/wagtailimages/images/edit.html +1 -3
  205. wagtail/images/templates/wagtailimages/images/url_generator.html +1 -1
  206. wagtail/images/templates/wagtailimages/multiple/add.html +7 -2
  207. wagtail/images/templates/wagtailimages/widgets/image_chooser.html +1 -1
  208. wagtail/images/tests/test_admin_views.py +53 -29
  209. wagtail/images/tests/test_blocks.py +3 -2
  210. wagtail/images/tests/test_models.py +12 -10
  211. wagtail/images/tests/tests.py +10 -0
  212. wagtail/images/views/chooser.py +1 -0
  213. wagtail/images/views/images.py +1 -3
  214. wagtail/images/views/multiple.py +0 -1
  215. wagtail/images/views/serve.py +18 -2
  216. wagtail/images/widgets.py +3 -0
  217. wagtail/locale/en/LC_MESSAGES/django.po +228 -216
  218. wagtail/locales/locale/en/LC_MESSAGES/django.po +1 -1
  219. wagtail/management/commands/publish_scheduled.py +1 -1
  220. wagtail/migrations/0087_alter_grouppagepermission_unique_together_and_more.py +16 -8
  221. wagtail/models/__init__.py +300 -119
  222. wagtail/models/i18n.py +2 -2
  223. wagtail/models/panels.py +37 -0
  224. wagtail/models/sites.py +7 -6
  225. wagtail/permission_policies/pages.py +2 -2
  226. wagtail/project_template/project_name/settings/base.py +4 -0
  227. wagtail/project_template/requirements.txt +1 -1
  228. wagtail/query.py +145 -0
  229. wagtail/search/backends/database/mysql/mysql.py +25 -17
  230. wagtail/search/backends/database/postgres/postgres.py +44 -83
  231. wagtail/search/backends/database/sqlite/sqlite.py +25 -17
  232. wagtail/search/backends/elasticsearch7.py +4 -0
  233. wagtail/search/locale/en/LC_MESSAGES/django.po +1 -1
  234. wagtail/search/query.py +8 -2
  235. wagtail/search/signal_handlers.py +6 -9
  236. wagtail/search/tasks.py +10 -0
  237. wagtail/search/tests/test_elasticsearch7_backend.py +21 -0
  238. wagtail/search/tests/test_index_functions.py +10 -6
  239. wagtail/search/tests/test_postgres_backend.py +0 -14
  240. wagtail/signal_handlers.py +5 -20
  241. wagtail/sites/locale/en/LC_MESSAGES/django.po +1 -1
  242. wagtail/snippets/locale/en/LC_MESSAGES/django.po +3 -13
  243. wagtail/snippets/tests/test_preview.py +5 -0
  244. wagtail/snippets/tests/test_snippets.py +100 -45
  245. wagtail/snippets/tests/test_usage.py +29 -24
  246. wagtail/snippets/tests/test_viewset.py +1 -1
  247. wagtail/snippets/views/snippets.py +0 -12
  248. wagtail/tasks.py +41 -0
  249. wagtail/templates/wagtailcore/shared/block_preview.html +29 -0
  250. wagtail/test/earlypage/__init__.py +0 -0
  251. wagtail/test/earlypage/migrations/0001_initial.py +37 -0
  252. wagtail/test/earlypage/migrations/__init__.py +0 -0
  253. wagtail/test/earlypage/models.py +14 -0
  254. wagtail/test/settings.py +3 -0
  255. wagtail/test/testapp/fixtures/test.json +7 -0
  256. wagtail/test/testapp/fixtures/test_specific.json +6 -3
  257. wagtail/test/testapp/models.py +58 -44
  258. wagtail/test/testapp/templates/tests/custom_block_preview.html +16 -0
  259. wagtail/test/testapp/templates/tests/static_block_preview.html +5 -0
  260. wagtail/test/testapp/wagtail_hooks.py +9 -0
  261. wagtail/tests/test_blocks.py +189 -2
  262. wagtail/tests/test_hooks.py +166 -1
  263. wagtail/tests/test_management_commands.py +54 -13
  264. wagtail/tests/test_page_allowed_http_methods.py +32 -0
  265. wagtail/tests/test_page_model.py +68 -0
  266. wagtail/tests/test_page_privacy.py +10 -0
  267. wagtail/tests/test_page_queryset.py +79 -0
  268. wagtail/tests/test_reference_index.py +84 -75
  269. wagtail/tests/test_streamfield.py +30 -0
  270. wagtail/tests/test_utils.py +61 -0
  271. wagtail/users/forms.py +2 -9
  272. wagtail/users/locale/en/LC_MESSAGES/django.po +17 -17
  273. wagtail/users/templates/wagtailusers/groups/create.html +0 -5
  274. wagtail/users/templates/wagtailusers/groups/includes/page_permissions_form.html +1 -1
  275. wagtail/users/templates/wagtailusers/groups/includes/page_permissions_formset.html +6 -6
  276. wagtail/users/tests/test_admin_views.py +96 -4
  277. wagtail/users/tests/test_utils.py +76 -0
  278. wagtail/users/utils.py +43 -11
  279. wagtail/utils/setup.py +2 -2
  280. wagtail/utils/templates.py +26 -0
  281. wagtail/utils/widgets.py +1 -0
  282. wagtail/views.py +9 -1
  283. wagtail/wagtail_hooks.py +67 -29
  284. {wagtail-6.3.2.dist-info → wagtail-6.4rc1.dist-info}/METADATA +2 -2
  285. {wagtail-6.3.2.dist-info → wagtail-6.4rc1.dist-info}/RECORD +289 -276
  286. wagtail/admin/static/wagtailadmin/js/expanding-formset.js +0 -1
  287. wagtail/admin/static/wagtailadmin/js/vendor/rangy-core.js +0 -1
  288. wagtail/admin/static/wagtailadmin/js/vendor/uuidv4.min.js +0 -1
  289. wagtail/contrib/search_promotions/views.py +0 -323
  290. wagtail/images/static/wagtailimages/js/vendor/canvas-to-blob.min.js +0 -1
  291. wagtail/users/static/wagtailusers/js/group-form.js +0 -1
  292. wagtail/users/templates/wagtailusers/groups/includes/group_form_js.html +0 -3
  293. {wagtail-6.3.2.dist-info → wagtail-6.4rc1.dist-info}/LICENSE +0 -0
  294. {wagtail-6.3.2.dist-info → wagtail-6.4rc1.dist-info}/WHEEL +0 -0
  295. {wagtail-6.3.2.dist-info → wagtail-6.4rc1.dist-info}/entry_points.txt +0 -0
  296. {wagtail-6.3.2.dist-info → wagtail-6.4rc1.dist-info}/top_level.txt +0 -0
@@ -1,16 +1,6 @@
1
- {% extends "wagtailadmin/base.html" %}
1
+ {% extends "wagtailadmin/generic/confirm_delete.html" %}
2
2
  {% load i18n %}
3
3
  {% block titletag %}{% blocktrans trimmed with title=redirect.title %}Delete redirect {{ title }}{% endblocktrans %}{% endblock %}
4
- {% block content %}
5
- {% trans "Delete" as delete_str %}
6
- {% include "wagtailadmin/shared/header.html" with title=delete_str subtitle=redirect.title icon="redirect" %}
7
-
8
- <div class="row row-flush nice-padding">
9
- <p>{% trans "Are you sure you want to delete this redirect?" %}</p>
10
- <form action="{% url 'wagtailredirects:delete' redirect.id %}" method="POST">
11
- {% csrf_token %}
12
- <input type="submit" value="{% trans 'Yes, delete' %}" class="button serious" />
13
- </form>
14
- </div>
15
-
4
+ {% block confirmation_message %}
5
+ <p>{% trans "Are you sure you want to delete this redirect?" %}</p>
16
6
  {% endblock %}
@@ -801,14 +801,15 @@ class TestRedirectsAddView(WagtailTestUtils, TestCase):
801
801
  self.assertTemplateUsed(response, "wagtailredirects/add.html")
802
802
 
803
803
  def test_add(self):
804
- response = self.post(
805
- {
806
- "old_path": "/test",
807
- "site": "",
808
- "is_permanent": "on",
809
- "redirect_link": "http://www.test.com/",
810
- }
811
- )
804
+ with self.captureOnCommitCallbacks(execute=True):
805
+ response = self.post(
806
+ {
807
+ "old_path": "/test",
808
+ "site": "",
809
+ "is_permanent": "on",
810
+ "redirect_link": "http://www.test.com/",
811
+ }
812
+ )
812
813
 
813
814
  # Should redirect back to index
814
815
  self.assertRedirects(response, reverse("wagtailredirects:index"))
@@ -827,15 +828,16 @@ class TestRedirectsAddView(WagtailTestUtils, TestCase):
827
828
  self.assertEqual(PURGED_URLS, {"http://localhost/test"})
828
829
 
829
830
  def test_add_with_site(self):
830
- localhost = Site.objects.get(hostname="localhost")
831
- response = self.post(
832
- {
833
- "old_path": "/test",
834
- "site": localhost.id,
835
- "is_permanent": "on",
836
- "redirect_link": "http://www.test.com/",
837
- }
838
- )
831
+ with self.captureOnCommitCallbacks(execute=True):
832
+ localhost = Site.objects.get(hostname="localhost")
833
+ response = self.post(
834
+ {
835
+ "old_path": "/test",
836
+ "site": localhost.id,
837
+ "is_permanent": "on",
838
+ "redirect_link": "http://www.test.com/",
839
+ }
840
+ )
839
841
 
840
842
  # Should redirect back to index
841
843
  self.assertRedirects(response, reverse("wagtailredirects:index"))
@@ -849,72 +851,76 @@ class TestRedirectsAddView(WagtailTestUtils, TestCase):
849
851
  self.assertEqual(PURGED_URLS, {"http://localhost/test"})
850
852
 
851
853
  def test_add_validation_error(self):
852
- response = self.post(
853
- {
854
- "old_path": "",
855
- "site": "",
856
- "is_permanent": "on",
857
- "redirect_link": "http://www.test.com/",
858
- }
859
- )
854
+ with self.captureOnCommitCallbacks(execute=True):
855
+ response = self.post(
856
+ {
857
+ "old_path": "",
858
+ "site": "",
859
+ "is_permanent": "on",
860
+ "redirect_link": "http://www.test.com/",
861
+ }
862
+ )
860
863
 
861
864
  # Should not redirect to index
862
865
  self.assertEqual(response.status_code, 200)
863
866
  self.assertEqual(PURGED_URLS, set())
864
867
 
865
868
  def test_cannot_add_duplicate_with_no_site(self):
866
- models.Redirect.objects.create(
867
- old_path="/test", site=None, redirect_link="http://elsewhere.com/"
868
- )
869
- response = self.post(
870
- {
871
- "old_path": "/test",
872
- "site": "",
873
- "is_permanent": "on",
874
- "redirect_link": "http://www.test.com/",
875
- }
876
- )
869
+ with self.captureOnCommitCallbacks(execute=True):
870
+ models.Redirect.objects.create(
871
+ old_path="/test", site=None, redirect_link="http://elsewhere.com/"
872
+ )
873
+ response = self.post(
874
+ {
875
+ "old_path": "/test",
876
+ "site": "",
877
+ "is_permanent": "on",
878
+ "redirect_link": "http://www.test.com/",
879
+ }
880
+ )
877
881
 
878
882
  # Should not redirect to index
879
883
  self.assertEqual(response.status_code, 200)
880
884
  self.assertEqual(PURGED_URLS, set())
881
885
 
882
886
  def test_cannot_add_duplicate_on_same_site(self):
883
- localhost = Site.objects.get(hostname="localhost")
884
- models.Redirect.objects.create(
885
- old_path="/test", site=localhost, redirect_link="http://elsewhere.com/"
886
- )
887
- response = self.post(
888
- {
889
- "old_path": "/test",
890
- "site": localhost.pk,
891
- "is_permanent": "on",
892
- "redirect_link": "http://www.test.com/",
893
- }
894
- )
887
+ with self.captureOnCommitCallbacks(execute=True):
888
+ localhost = Site.objects.get(hostname="localhost")
889
+ models.Redirect.objects.create(
890
+ old_path="/test", site=localhost, redirect_link="http://elsewhere.com/"
891
+ )
892
+ response = self.post(
893
+ {
894
+ "old_path": "/test",
895
+ "site": localhost.pk,
896
+ "is_permanent": "on",
897
+ "redirect_link": "http://www.test.com/",
898
+ }
899
+ )
895
900
 
896
901
  # Should not redirect to index
897
902
  self.assertEqual(response.status_code, 200)
898
903
  self.assertEqual(PURGED_URLS, set())
899
904
 
900
905
  def test_can_reuse_path_on_other_site(self):
901
- localhost = Site.objects.get(hostname="localhost")
902
- contact_page = Page.objects.get(url_path="/home/contact-us/")
903
- other_site = Site.objects.create(
904
- hostname="other.example.com", port=80, root_page=contact_page
905
- )
906
+ with self.captureOnCommitCallbacks(execute=True):
907
+ localhost = Site.objects.get(hostname="localhost")
908
+ contact_page = Page.objects.get(url_path="/home/contact-us/")
909
+ other_site = Site.objects.create(
910
+ hostname="other.example.com", port=80, root_page=contact_page
911
+ )
906
912
 
907
- models.Redirect.objects.create(
908
- old_path="/test", site=localhost, redirect_link="http://elsewhere.com/"
909
- )
910
- response = self.post(
911
- {
912
- "old_path": "/test",
913
- "site": other_site.pk,
914
- "is_permanent": "on",
915
- "redirect_link": "http://www.test.com/",
916
- }
917
- )
913
+ models.Redirect.objects.create(
914
+ old_path="/test", site=localhost, redirect_link="http://elsewhere.com/"
915
+ )
916
+ response = self.post(
917
+ {
918
+ "old_path": "/test",
919
+ "site": other_site.pk,
920
+ "is_permanent": "on",
921
+ "redirect_link": "http://www.test.com/",
922
+ }
923
+ )
918
924
 
919
925
  # Should redirect back to index
920
926
  self.assertRedirects(response, reverse("wagtailredirects:index"))
@@ -926,14 +932,15 @@ class TestRedirectsAddView(WagtailTestUtils, TestCase):
926
932
  self.assertEqual(PURGED_URLS, redirects.get().old_links())
927
933
 
928
934
  def test_add_long_redirect(self):
929
- response = self.post(
930
- {
931
- "old_path": "/test",
932
- "site": "",
933
- "is_permanent": "on",
934
- "redirect_link": "https://www.google.com/search?q=this+is+a+very+long+url+because+it+has+a+huge+search+term+appended+to+the+end+of+it+even+though+someone+should+really+not+be+doing+something+so+crazy+without+first+seeing+a+psychiatrist",
935
- }
936
- )
935
+ with self.captureOnCommitCallbacks(execute=True):
936
+ response = self.post(
937
+ {
938
+ "old_path": "/test",
939
+ "site": "",
940
+ "is_permanent": "on",
941
+ "redirect_link": "https://www.google.com/search?q=this+is+a+very+long+url+because+it+has+a+huge+search+term+appended+to+the+end+of+it+even+though+someone+should+really+not+be+doing+something+so+crazy+without+first+seeing+a+psychiatrist",
942
+ }
943
+ )
937
944
 
938
945
  # Should redirect back to index
939
946
  self.assertRedirects(response, reverse("wagtailredirects:index"))
@@ -1002,14 +1009,15 @@ class TestRedirectsEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
1002
1009
  self.assertEqual(self.get(redirect_id=100000).status_code, 404)
1003
1010
 
1004
1011
  def test_edit(self):
1005
- response = self.post(
1006
- {
1007
- "old_path": "/test",
1008
- "is_permanent": "on",
1009
- "site": "",
1010
- "redirect_link": "http://www.test.com/ive-been-edited",
1011
- }
1012
- )
1012
+ with self.captureOnCommitCallbacks(execute=True):
1013
+ response = self.post(
1014
+ {
1015
+ "old_path": "/test",
1016
+ "is_permanent": "on",
1017
+ "site": "",
1018
+ "redirect_link": "http://www.test.com/ive-been-edited",
1019
+ }
1020
+ )
1013
1021
 
1014
1022
  # Should redirect back to index
1015
1023
  self.assertRedirects(response, reverse("wagtailredirects:index"))
@@ -1025,16 +1033,17 @@ class TestRedirectsEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
1025
1033
  self.assertEqual(PURGED_URLS, {"http://localhost/test"})
1026
1034
 
1027
1035
  def test_edit_with_site(self):
1028
- localhost = Site.objects.get(hostname="localhost")
1029
-
1030
- response = self.post(
1031
- {
1032
- "old_path": "/test",
1033
- "is_permanent": "on",
1034
- "site": localhost.id,
1035
- "redirect_link": "http://www.test.com/ive-been-edited",
1036
- }
1037
- )
1036
+ with self.captureOnCommitCallbacks(execute=True):
1037
+ localhost = Site.objects.get(hostname="localhost")
1038
+
1039
+ response = self.post(
1040
+ {
1041
+ "old_path": "/test",
1042
+ "is_permanent": "on",
1043
+ "site": localhost.id,
1044
+ "redirect_link": "http://www.test.com/ive-been-edited",
1045
+ }
1046
+ )
1038
1047
 
1039
1048
  # Should redirect back to index
1040
1049
  self.assertRedirects(response, reverse("wagtailredirects:index"))
@@ -1049,31 +1058,33 @@ class TestRedirectsEditView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
1049
1058
  self.assertEqual(PURGED_URLS, {"http://localhost/test"})
1050
1059
 
1051
1060
  def test_edit_validation_error(self):
1052
- response = self.post(
1053
- {
1054
- "old_path": "",
1055
- "is_permanent": "on",
1056
- "site": "",
1057
- "redirect_link": "http://www.test.com/ive-been-edited",
1058
- }
1059
- )
1061
+ with self.captureOnCommitCallbacks(execute=True):
1062
+ response = self.post(
1063
+ {
1064
+ "old_path": "",
1065
+ "is_permanent": "on",
1066
+ "site": "",
1067
+ "redirect_link": "http://www.test.com/ive-been-edited",
1068
+ }
1069
+ )
1060
1070
 
1061
1071
  # Should not redirect to index
1062
1072
  self.assertEqual(response.status_code, 200)
1063
1073
  self.assertEqual(PURGED_URLS, set())
1064
1074
 
1065
1075
  def test_edit_duplicate(self):
1066
- models.Redirect.objects.create(
1067
- old_path="/othertest", site=None, redirect_link="http://elsewhere.com/"
1068
- )
1069
- response = self.post(
1070
- {
1071
- "old_path": "/othertest",
1072
- "is_permanent": "on",
1073
- "site": "",
1074
- "redirect_link": "http://www.test.com/ive-been-edited",
1075
- }
1076
- )
1076
+ with self.captureOnCommitCallbacks(execute=True):
1077
+ models.Redirect.objects.create(
1078
+ old_path="/othertest", site=None, redirect_link="http://elsewhere.com/"
1079
+ )
1080
+ response = self.post(
1081
+ {
1082
+ "old_path": "/othertest",
1083
+ "is_permanent": "on",
1084
+ "site": "",
1085
+ "redirect_link": "http://www.test.com/ive-been-edited",
1086
+ }
1087
+ )
1077
1088
 
1078
1089
  # Should not redirect to index
1079
1090
  self.assertEqual(response.status_code, 200)
@@ -1153,7 +1164,8 @@ class TestRedirectsDeleteView(WagtailTestUtils, TestCase):
1153
1164
  self.assertEqual(self.get(redirect_id=100000).status_code, 404)
1154
1165
 
1155
1166
  def test_delete(self):
1156
- response = self.post()
1167
+ with self.captureOnCommitCallbacks(execute=True):
1168
+ response = self.post()
1157
1169
 
1158
1170
  # Should redirect back to index
1159
1171
  self.assertRedirects(response, reverse("wagtailredirects:index"))
@@ -41,28 +41,29 @@ class TestAutocreateRedirects(WagtailTestUtils, TestCase):
41
41
  page.save(log_action="wagtail.publish", user=self.user, clean=False)
42
42
 
43
43
  def test_golden_path(self):
44
- # the page we'll be triggering the change for here is...
45
- test_subject = self.event_index
46
-
47
- # identify 'draft' pages in this section
48
- drafts = test_subject.get_descendants().not_live()
49
- self.assertEqual(len(drafts), 4)
50
-
51
- # gather urls for 'live' pages in this branch
52
- request = get_dummy_request()
53
- branch_urls = []
54
- for page in (
55
- test_subject.get_descendants(inclusive=True)
56
- .live()
57
- .specific(defer=True)
58
- .iterator()
59
- ):
60
- main_url = page.get_url(request).rstrip("/")
61
- branch_urls.extend(
62
- main_url + path.rstrip("/") for path in page.get_cached_paths()
63
- )
64
-
65
- self.trigger_page_slug_changed_signal(test_subject)
44
+ with self.captureOnCommitCallbacks(execute=True):
45
+ # the page we'll be triggering the change for here is...
46
+ test_subject = self.event_index
47
+
48
+ # identify 'draft' pages in this section
49
+ drafts = test_subject.get_descendants().not_live()
50
+ self.assertEqual(len(drafts), 4)
51
+
52
+ # gather urls for 'live' pages in this branch
53
+ request = get_dummy_request()
54
+ branch_urls = []
55
+ for page in (
56
+ test_subject.get_descendants(inclusive=True)
57
+ .live()
58
+ .specific(defer=True)
59
+ .iterator()
60
+ ):
61
+ main_url = page.get_url(request).rstrip("/")
62
+ branch_urls.extend(
63
+ main_url + path.rstrip("/") for path in page.get_cached_paths()
64
+ )
65
+
66
+ self.trigger_page_slug_changed_signal(test_subject)
66
67
 
67
68
  # gather all of the redirects that were created
68
69
  redirects = Redirect.objects.all()
@@ -97,32 +98,34 @@ class TestAutocreateRedirects(WagtailTestUtils, TestCase):
97
98
  )
98
99
 
99
100
  def test_no_redirects_created_when_page_is_root_for_all_sites_it_belongs_to(self):
100
- self.trigger_page_slug_changed_signal(self.home_page)
101
+ with self.captureOnCommitCallbacks(execute=True):
102
+ self.trigger_page_slug_changed_signal(self.home_page)
101
103
  self.assertFalse(Redirect.objects.exists())
102
104
  self.assertEqual(len(PURGED_URLS), 0)
103
105
 
104
106
  def test_handling_of_existing_redirects(self):
105
- # the page we'll be triggering the change for here is...
106
- test_subject = self.event_index
107
-
108
- descendants = test_subject.get_descendants().live()
109
-
110
- # but before we do, let's add some redirects that we'll expect to conflict
111
- # with ones created by the signal handler
112
- redirect1 = Redirect.objects.create(
113
- old_path=Redirect.normalise_path(descendants.first().specific.url),
114
- site=self.site,
115
- redirect_link="/some-place",
116
- automatically_created=False,
117
- )
118
- redirect2 = Redirect.objects.create(
119
- old_path=Redirect.normalise_path(descendants.last().specific.url),
120
- site=self.site,
121
- redirect_link="/some-other-place",
122
- automatically_created=True,
123
- )
107
+ with self.captureOnCommitCallbacks(execute=True):
108
+ # the page we'll be triggering the change for here is...
109
+ test_subject = self.event_index
110
+
111
+ descendants = test_subject.get_descendants().live()
112
+
113
+ # but before we do, let's add some redirects that we'll expect to conflict
114
+ # with ones created by the signal handler
115
+ redirect1 = Redirect.objects.create(
116
+ old_path=Redirect.normalise_path(descendants.first().specific.url),
117
+ site=self.site,
118
+ redirect_link="/some-place",
119
+ automatically_created=False,
120
+ )
121
+ redirect2 = Redirect.objects.create(
122
+ old_path=Redirect.normalise_path(descendants.last().specific.url),
123
+ site=self.site,
124
+ redirect_link="/some-other-place",
125
+ automatically_created=True,
126
+ )
124
127
 
125
- self.trigger_page_slug_changed_signal(test_subject)
128
+ self.trigger_page_slug_changed_signal(test_subject)
126
129
 
127
130
  # pre-existing manually-created redirects should be preserved
128
131
  from_db = Redirect.objects.get(id=redirect1.id)
@@ -163,17 +166,18 @@ class TestAutocreateRedirects(WagtailTestUtils, TestCase):
163
166
  )
164
167
 
165
168
  def test_redirect_creation_for_custom_route_paths(self):
166
- # Add a page that has overridden get_route_paths()
167
- homepage = Page.objects.get(id=2)
168
- routable_page = homepage.add_child(
169
- instance=RoutablePageTest(
170
- title="Routable Page",
171
- live=True,
169
+ with self.captureOnCommitCallbacks(execute=True):
170
+ # Add a page that has overridden get_route_paths()
171
+ homepage = Page.objects.get(id=2)
172
+ routable_page = homepage.add_child(
173
+ instance=RoutablePageTest(
174
+ title="Routable Page",
175
+ live=True,
176
+ )
172
177
  )
173
- )
174
178
 
175
- # Move from below the homepage to below the event index
176
- routable_page.move(self.event_index, pos="last-child")
179
+ # Move from below the homepage to below the event index
180
+ routable_page.move(self.event_index, pos="last-child")
177
181
 
178
182
  # Redirects should have been created for each path returned by get_route_paths()
179
183
  self.assertEqual(
@@ -206,23 +210,24 @@ class TestAutocreateRedirects(WagtailTestUtils, TestCase):
206
210
  )
207
211
 
208
212
  def test_no_redirects_created_when_pages_are_moved_to_a_different_site(self):
209
- # Add a new home page
210
- homepage_2 = Page(
211
- title="Second home",
212
- slug="second-home",
213
- )
214
- root_page = Page.objects.get(depth=1)
215
- root_page.add_child(instance=homepage_2)
216
-
217
- # Create a site with the above as the root_page
218
- Site.objects.create(
219
- root_page=homepage_2,
220
- hostname="newsite.com",
221
- port=80,
222
- )
213
+ with self.captureOnCommitCallbacks(execute=True):
214
+ # Add a new home page
215
+ homepage_2 = Page(
216
+ title="Second home",
217
+ slug="second-home",
218
+ )
219
+ root_page = Page.objects.get(depth=1)
220
+ root_page.add_child(instance=homepage_2)
221
+
222
+ # Create a site with the above as the root_page
223
+ Site.objects.create(
224
+ root_page=homepage_2,
225
+ hostname="newsite.com",
226
+ port=80,
227
+ )
223
228
 
224
- # Move the event index to the new site
225
- self.event_index.move(homepage_2, pos="last-child")
229
+ # Move the event index to the new site
230
+ self.event_index.move(homepage_2, pos="last-child")
226
231
 
227
232
  # No redirects should have been created
228
233
  self.assertFalse(Redirect.objects.exists())
@@ -230,6 +235,7 @@ class TestAutocreateRedirects(WagtailTestUtils, TestCase):
230
235
 
231
236
  @override_settings(WAGTAILREDIRECTS_AUTO_CREATE=False)
232
237
  def test_no_redirects_created_if_disabled(self):
233
- self.trigger_page_slug_changed_signal(self.event_index)
238
+ with self.captureOnCommitCallbacks(execute=True):
239
+ self.trigger_page_slug_changed_signal(self.event_index)
234
240
  self.assertFalse(Redirect.objects.exists())
235
241
  self.assertEqual(len(PURGED_URLS), 0)
@@ -6,9 +6,9 @@ app_name = "wagtailredirects"
6
6
  urlpatterns = [
7
7
  path("", views.IndexView.as_view(), name="index"),
8
8
  path("results/", views.IndexView.as_view(results_only=True), name="index_results"),
9
- path("add/", views.add, name="add"),
9
+ path("add/", views.CreateView.as_view(), name="add"),
10
10
  path("<int:redirect_id>/", views.EditView.as_view(), name="edit"),
11
- path("<int:redirect_id>/delete/", views.delete, name="delete"),
11
+ path("<int:redirect_id>/delete/", views.DeleteView.as_view(), name="delete"),
12
12
  path("import/", views.start_import, name="start_import"),
13
13
  path("import/process/", views.process_import, name="process_import"),
14
14
  ]