wagtail 7.2.1__py3-none-any.whl → 7.3rc1__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.
- wagtail/__init__.py +1 -1
- wagtail/actions/copy_for_translation.py +4 -2
- wagtail/admin/action_menu.py +4 -1
- wagtail/admin/api/actions/convert_alias.py +2 -2
- wagtail/admin/api/actions/copy.py +2 -2
- wagtail/admin/api/actions/copy_for_translation.py +2 -2
- wagtail/admin/api/actions/create_alias.py +2 -2
- wagtail/admin/api/actions/delete.py +1 -1
- wagtail/admin/api/actions/move.py +1 -1
- wagtail/admin/api/actions/publish.py +2 -2
- wagtail/admin/api/actions/revert_to_page_revision.py +2 -2
- wagtail/admin/api/actions/unpublish.py +1 -1
- wagtail/admin/api/filters.py +2 -2
- wagtail/admin/compare.py +22 -0
- wagtail/admin/forms/account.py +52 -1
- wagtail/admin/forms/comments.py +53 -0
- wagtail/admin/forms/models.py +36 -0
- wagtail/admin/forms/pages.py +7 -0
- wagtail/admin/forms/workflows.py +5 -2
- wagtail/admin/icons.py +4 -3
- wagtail/admin/locale/ar/LC_MESSAGES/django.mo +0 -0
- wagtail/admin/locale/ar/LC_MESSAGES/django.po +35 -0
- wagtail/admin/locale/en/LC_MESSAGES/django.po +262 -234
- wagtail/admin/locale/en/LC_MESSAGES/djangojs.po +72 -43
- wagtail/admin/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/admin/locale/it/LC_MESSAGES/django.po +566 -6
- wagtail/admin/locale/it/LC_MESSAGES/djangojs.mo +0 -0
- wagtail/admin/locale/it/LC_MESSAGES/djangojs.po +40 -2
- wagtail/admin/locale/nl/LC_MESSAGES/django.mo +0 -0
- wagtail/admin/locale/nl/LC_MESSAGES/django.po +2 -2
- wagtail/admin/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/admin/locale/sv/LC_MESSAGES/django.po +330 -15
- wagtail/admin/locale/sv/LC_MESSAGES/djangojs.mo +0 -0
- wagtail/admin/locale/sv/LC_MESSAGES/djangojs.po +3 -2
- wagtail/admin/panels/comment_panel.py +1 -51
- wagtail/admin/panels/title_field_panel.py +3 -1
- wagtail/admin/static/wagtailadmin/css/core.css +1 -1
- wagtail/admin/static/wagtailadmin/js/bulk-actions.js +1 -1
- wagtail/admin/static/wagtailadmin/js/comments.js +1 -1
- wagtail/admin/static/wagtailadmin/js/core.js +1 -1
- wagtail/admin/static/wagtailadmin/js/core.js.LICENSE.txt +1 -1
- wagtail/admin/static/wagtailadmin/js/draftail.js +1 -1
- wagtail/admin/static/wagtailadmin/js/privacy-switch.js +1 -1
- wagtail/admin/static/wagtailadmin/js/sidebar.js +1 -1
- wagtail/admin/static/wagtailadmin/js/telepath/blocks.js +1 -1
- wagtail/admin/static/wagtailadmin/js/userbar.js +1 -1
- wagtail/admin/static/wagtailadmin/js/userbar.js.LICENSE.txt +1 -1
- wagtail/admin/static/wagtailadmin/js/vendor.js +1 -1
- wagtail/admin/static/wagtailadmin/js/wagtailadmin.js +1 -1
- wagtail/admin/templates/wagtailadmin/base.html +1 -1
- wagtail/admin/templates/wagtailadmin/generic/edit_partials.html +100 -0
- wagtail/admin/templates/wagtailadmin/generic/form.html +26 -5
- wagtail/admin/templates/wagtailadmin/generic/includes/_loaded_revision_inputs.html +3 -0
- wagtail/admin/templates/wagtailadmin/generic/listing_results.html +1 -17
- wagtail/admin/templates/wagtailadmin/pages/create.html +14 -4
- wagtail/admin/templates/wagtailadmin/pages/edit.html +16 -3
- wagtail/admin/templates/wagtailadmin/pages/edit_partials.html +31 -0
- wagtail/admin/templates/wagtailadmin/pages/index_results.html +1 -9
- wagtail/admin/templates/wagtailadmin/shared/autosave/indicator.html +36 -0
- wagtail/admin/templates/wagtailadmin/shared/breadcrumbs.html +1 -1
- wagtail/admin/templates/wagtailadmin/shared/editing_sessions/list.html +2 -2
- wagtail/admin/templates/wagtailadmin/shared/editing_sessions/module.html +19 -3
- wagtail/admin/templates/wagtailadmin/shared/headers/_actions.html +5 -0
- wagtail/admin/templates/wagtailadmin/shared/headers/_history_icon_link.html +2 -2
- wagtail/admin/templates/wagtailadmin/shared/headers/slim_header.html +8 -9
- wagtail/admin/templates/wagtailadmin/shared/listing/filter_partials.html +19 -0
- wagtail/admin/templates/wagtailadmin/shared/side_panel_toggle.html +3 -3
- wagtail/admin/templates/wagtailadmin/shared/side_panels/includes/side_panel.html +3 -0
- wagtail/admin/templates/wagtailadmin/shared/side_panels/includes/status/privacy.html +18 -6
- wagtail/admin/templates/wagtailadmin/shared/side_panels/includes/status/usage.html +11 -4
- wagtail/admin/templates/wagtailadmin/shared/side_panels/includes/status/workflow.html +22 -1
- wagtail/admin/templates/wagtailadmin/shared/side_panels/preview.html +1 -0
- wagtail/admin/templates/wagtailadmin/shared/side_panels.html +1 -2
- wagtail/admin/templates/wagtailadmin/shared/unsaved_changes_warning.html +20 -20
- wagtail/admin/templates/wagtailadmin/userbar/base.html +2 -0
- wagtail/admin/templates/wagtailadmin/userbar/item_accessibility.html +1 -1
- wagtail/admin/templatetags/wagtailadmin_tags.py +6 -14
- wagtail/admin/tests/pages/test_create_page.py +298 -1
- wagtail/admin/tests/pages/test_custom_listing.py +48 -2
- wagtail/admin/tests/pages/test_edit_page.py +721 -7
- wagtail/admin/tests/pages/test_explorer_view.py +9 -5
- wagtail/admin/tests/pages/test_page_search.py +15 -0
- wagtail/admin/tests/pages/test_revisions.py +4 -0
- wagtail/admin/tests/test_account_management.py +88 -2
- wagtail/admin/tests/test_collections_views.py +15 -15
- wagtail/admin/tests/test_compare.py +34 -0
- wagtail/admin/tests/test_editing_sessions.py +230 -8
- wagtail/admin/tests/test_forms.py +192 -1
- wagtail/admin/tests/test_icon_sprite.py +22 -2
- wagtail/admin/tests/test_page_chooser.py +13 -13
- wagtail/admin/tests/test_reports_views.py +4 -1
- wagtail/admin/tests/test_userbar.py +69 -5
- wagtail/admin/tests/test_views_generic.py +5 -5
- wagtail/admin/tests/test_workflows.py +14 -12
- wagtail/admin/tests/viewsets/test_model_viewset.py +13 -0
- wagtail/admin/ui/autosave.py +5 -0
- wagtail/admin/ui/editing_sessions.py +3 -0
- wagtail/admin/ui/side_panels.py +19 -20
- wagtail/admin/userbar.py +48 -27
- wagtail/admin/views/bulk_action/dispatcher.py +2 -2
- wagtail/admin/views/chooser.py +6 -6
- wagtail/admin/views/editing_sessions.py +20 -7
- wagtail/admin/views/generic/__init__.py +1 -0
- wagtail/admin/views/generic/chooser.py +5 -5
- wagtail/admin/views/generic/mixins.py +143 -26
- wagtail/admin/views/generic/models.py +157 -27
- wagtail/admin/views/generic/ordering.py +1 -1
- wagtail/admin/views/generic/preview.py +4 -4
- wagtail/admin/views/home.py +3 -1
- wagtail/admin/views/pages/create.py +77 -29
- wagtail/admin/views/pages/edit.py +160 -34
- wagtail/admin/views/pages/preview.py +4 -4
- wagtail/admin/views/pages/revisions.py +3 -0
- wagtail/admin/views/pages/search.py +4 -4
- wagtail/admin/views/pages/usage.py +2 -2
- wagtail/admin/views/tags.py +2 -2
- wagtail/admin/views/workflows.py +73 -54
- wagtail/admin/viewsets/model.py +34 -8
- wagtail/admin/widgets/button.py +11 -4
- wagtail/admin/widgets/chooser.py +6 -4
- wagtail/admin/widgets/slug.py +1 -1
- wagtail/api/v2/filters.py +27 -21
- wagtail/api/v2/pagination.py +4 -4
- wagtail/api/v2/views.py +7 -7
- wagtail/blocks/list_block.py +0 -8
- wagtail/blocks/migrations/migrate_operation.py +8 -1
- wagtail/blocks/stream_block.py +2 -10
- wagtail/blocks/struct_block.py +192 -12
- wagtail/compat.py +2 -2
- wagtail/contrib/forms/locale/en/LC_MESSAGES/django.po +1 -1
- wagtail/contrib/forms/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/forms/locale/it/LC_MESSAGES/django.po +40 -2
- wagtail/contrib/frontend_cache/backends/azure.py +6 -6
- wagtail/contrib/frontend_cache/backends/cloudfront.py +2 -2
- wagtail/contrib/frontend_cache/utils.py +1 -1
- wagtail/contrib/redirects/forms.py +1 -1
- wagtail/contrib/redirects/locale/en/LC_MESSAGES/django.po +14 -14
- wagtail/contrib/redirects/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/redirects/locale/it/LC_MESSAGES/django.po +15 -2
- wagtail/contrib/redirects/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/redirects/locale/sv/LC_MESSAGES/django.po +16 -3
- wagtail/contrib/redirects/middleware.py +11 -7
- wagtail/contrib/redirects/models.py +17 -1
- wagtail/contrib/redirects/tests/test_import_admin_views.py +3 -3
- wagtail/contrib/redirects/tests/test_redirects.py +56 -8
- wagtail/contrib/search_promotions/locale/en/LC_MESSAGES/django.po +6 -6
- wagtail/contrib/search_promotions/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/search_promotions/locale/it/LC_MESSAGES/django.po +43 -2
- wagtail/contrib/search_promotions/tests.py +1 -1
- wagtail/contrib/search_promotions/views/settings.py +24 -25
- wagtail/contrib/settings/jinja2tags.py +2 -2
- wagtail/contrib/settings/locale/en/LC_MESSAGES/django.po +2 -2
- wagtail/contrib/settings/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/settings/locale/it/LC_MESSAGES/django.po +6 -2
- wagtail/contrib/settings/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/settings/locale/sv/LC_MESSAGES/django.po +3 -2
- wagtail/contrib/settings/tests/generic/test_admin.py +118 -2
- wagtail/contrib/settings/tests/site_specific/test_admin.py +78 -15
- wagtail/contrib/settings/tests/site_specific/test_model.py +2 -2
- wagtail/contrib/settings/views.py +7 -0
- wagtail/contrib/simple_translation/locale/en/LC_MESSAGES/django.po +1 -1
- wagtail/contrib/simple_translation/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/simple_translation/locale/it/LC_MESSAGES/django.po +5 -2
- wagtail/contrib/styleguide/locale/en/LC_MESSAGES/django.po +7 -7
- wagtail/contrib/styleguide/tests.py +2 -0
- wagtail/contrib/styleguide/views.py +4 -5
- wagtail/contrib/table_block/locale/ar/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/table_block/locale/ar/LC_MESSAGES/django.po +5 -1
- wagtail/contrib/table_block/locale/en/LC_MESSAGES/django.po +1 -1
- wagtail/contrib/table_block/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/table_block/locale/it/LC_MESSAGES/django.po +5 -2
- wagtail/contrib/typed_table_block/blocks.py +37 -0
- wagtail/contrib/typed_table_block/locale/en/LC_MESSAGES/django.po +10 -10
- wagtail/contrib/typed_table_block/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/contrib/typed_table_block/locale/sv/LC_MESSAGES/django.po +4 -3
- wagtail/contrib/typed_table_block/tests.py +108 -0
- wagtail/coreutils.py +4 -4
- wagtail/documents/__init__.py +4 -4
- wagtail/documents/locale/en/LC_MESSAGES/django.po +15 -15
- wagtail/documents/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/documents/locale/it/LC_MESSAGES/django.po +32 -2
- wagtail/documents/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/documents/locale/sv/LC_MESSAGES/django.po +32 -4
- wagtail/documents/models.py +1 -1
- wagtail/documents/tests/test_admin_views.py +19 -4
- wagtail/documents/tests/test_search.py +0 -2
- wagtail/documents/tests/test_views.py +6 -4
- wagtail/documents/views/bulk_actions/add_tags.py +1 -1
- wagtail/embeds/finders/facebook.py +3 -3
- wagtail/embeds/finders/instagram.py +3 -3
- wagtail/embeds/finders/oembed.py +7 -2
- wagtail/embeds/locale/en/LC_MESSAGES/django.po +1 -1
- wagtail/embeds/oembed_providers.py +8 -0
- wagtail/embeds/tests/test_embeds.py +35 -0
- wagtail/images/__init__.py +4 -4
- wagtail/images/admin_urls.py +3 -3
- wagtail/images/blocks.py +1 -1
- wagtail/images/formats.py +2 -2
- wagtail/images/image_operations.py +2 -2
- wagtail/images/locale/en/LC_MESSAGES/django.po +44 -40
- wagtail/images/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/images/locale/it/LC_MESSAGES/django.po +50 -4
- wagtail/images/locale/nl/LC_MESSAGES/django.mo +0 -0
- wagtail/images/locale/nl/LC_MESSAGES/django.po +3 -3
- wagtail/images/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/images/locale/sv/LC_MESSAGES/django.po +49 -6
- wagtail/images/models.py +11 -10
- wagtail/images/templates/wagtailimages/images/index_results.html +1 -1
- wagtail/images/templates/wagtailimages/images/url_generator.html +17 -38
- wagtail/images/templates/wagtailimages/images/url_generator_output.html +28 -0
- wagtail/images/templatetags/wagtailimages_tags.py +4 -4
- wagtail/images/tests/test_admin_views.py +432 -59
- wagtail/images/tests/test_image_operations.py +2 -2
- wagtail/images/tests/test_models.py +0 -2
- wagtail/images/views/bulk_actions/add_tags.py +1 -1
- wagtail/images/views/images.py +72 -39
- wagtail/locale/en/LC_MESSAGES/django.po +103 -105
- wagtail/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/locale/it/LC_MESSAGES/django.po +105 -2
- wagtail/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/locale/sv/LC_MESSAGES/django.po +95 -12
- wagtail/locales/locale/en/LC_MESSAGES/django.po +1 -1
- wagtail/locales/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/locales/locale/it/LC_MESSAGES/django.po +13 -2
- wagtail/locales/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/locales/locale/sv/LC_MESSAGES/django.po +4 -3
- wagtail/locales/tests.py +5 -5
- wagtail/models/i18n.py +4 -6
- wagtail/models/media.py +18 -0
- wagtail/models/pages.py +65 -11
- wagtail/models/reference_index.py +15 -0
- wagtail/models/revisions.py +40 -12
- wagtail/models/workflows.py +0 -3
- wagtail/permission_policies/base.py +2 -2
- wagtail/permission_policies/collections.py +2 -2
- wagtail/project_template/requirements.txt +2 -2
- wagtail/search/locale/en/LC_MESSAGES/django.po +1 -1
- wagtail/signal_handlers.py +1 -0
- wagtail/sites/locale/en/LC_MESSAGES/django.po +1 -1
- wagtail/sites/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/sites/locale/sv/LC_MESSAGES/django.po +3 -2
- wagtail/sites/tests.py +7 -7
- wagtail/snippets/action_menu.py +2 -1
- wagtail/snippets/locale/en/LC_MESSAGES/django.po +23 -13
- wagtail/snippets/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/snippets/locale/sv/LC_MESSAGES/django.po +12 -1
- wagtail/snippets/tests/test_chooser_block.py +197 -0
- wagtail/snippets/tests/test_chooser_panel.py +149 -0
- wagtail/snippets/tests/test_chooser_views.py +375 -0
- wagtail/snippets/tests/test_chooser_widget.py +22 -0
- wagtail/snippets/tests/test_compare_revisions_view.py +167 -0
- wagtail/snippets/tests/test_copy_view.py +38 -0
- wagtail/snippets/tests/test_create_view.py +1159 -0
- wagtail/snippets/tests/test_delete_view.py +225 -0
- wagtail/snippets/tests/test_edit_view.py +2882 -0
- wagtail/snippets/tests/test_history_view.py +182 -0
- wagtail/snippets/tests/test_index_view.py +105 -0
- wagtail/snippets/tests/test_list_view.py +786 -0
- wagtail/snippets/tests/test_locking.py +28 -0
- wagtail/snippets/tests/test_permissions.py +167 -0
- wagtail/snippets/tests/test_preview.py +3 -3
- wagtail/snippets/tests/test_revert_view.py +343 -0
- wagtail/snippets/tests/test_snippet_models.py +112 -0
- wagtail/snippets/tests/test_unpublish_view.py +228 -0
- wagtail/snippets/tests/test_unschedule_view.py +151 -0
- wagtail/snippets/tests/test_viewset.py +38 -5
- wagtail/snippets/views/snippets.py +78 -30
- wagtail/snippets/widgets.py +2 -2
- wagtail/templatetags/wagtailcore_tags.py +2 -2
- wagtail/test/dummy_external_storage.py +1 -1
- wagtail/test/testapp/fixtures/test.json +22 -0
- wagtail/test/testapp/fixtures/test_empty.json +2 -0
- wagtail/test/testapp/fixtures/test_explorable_pages.json +10 -0
- wagtail/test/testapp/fixtures/test_specific.json +9 -0
- wagtail/test/testapp/migrations/0059_nopromotepage.py +25 -0
- wagtail/test/testapp/models.py +7 -0
- wagtail/test/testapp/views.py +5 -0
- wagtail/test/utils/page_tests.py +7 -7
- wagtail/test/utils/wagtail_factories/builder.py +2 -2
- wagtail/tests/streamfield_migrations/test_migrations.py +35 -0
- wagtail/tests/test_blocks.py +321 -61
- wagtail/tests/test_collection_model.py +12 -0
- wagtail/tests/test_page_model.py +190 -1
- wagtail/tests/test_page_privacy.py +5 -0
- wagtail/tests/test_reference_index.py +42 -0
- wagtail/tests/test_revision_model.py +118 -1
- wagtail/tests/test_utils.py +2 -2
- wagtail/users/locale/en/LC_MESSAGES/django.po +14 -14
- wagtail/users/locale/id_ID/LC_MESSAGES/django.mo +0 -0
- wagtail/users/locale/id_ID/LC_MESSAGES/django.po +6 -2
- wagtail/users/locale/it/LC_MESSAGES/django.mo +0 -0
- wagtail/users/locale/it/LC_MESSAGES/django.po +14 -2
- wagtail/users/locale/sv/LC_MESSAGES/django.mo +0 -0
- wagtail/users/locale/sv/LC_MESSAGES/django.po +48 -17
- wagtail/users/tests/test_admin_views.py +39 -25
- wagtail/users/utils.py +4 -1
- wagtail/users/views/groups.py +19 -5
- wagtail/users/wagtail_hooks.py +1 -1
- wagtail/utils/loading.py +2 -2
- wagtail-7.3rc1.data/data/AGENTS.md +21 -0
- wagtail-7.3rc1.data/data/CHANGELOG.txt +4941 -0
- wagtail-7.3rc1.data/data/CODE_OF_CONDUCT.md +71 -0
- wagtail-7.3rc1.data/data/CONTRIBUTORS.md +999 -0
- wagtail-7.3rc1.data/data/SPONSORS.md +55 -0
- {wagtail-7.2.1.dist-info → wagtail-7.3rc1.dist-info}/METADATA +6 -6
- {wagtail-7.2.1.dist-info → wagtail-7.3rc1.dist-info}/RECORD +310 -280
- {wagtail-7.2.1.dist-info → wagtail-7.3rc1.dist-info}/WHEEL +1 -1
- wagtail/images/static/wagtailimages/js/image-url-generator.js +0 -1
- wagtail/snippets/tests/test_snippets.py +0 -6377
- {wagtail-7.2.1.dist-info → wagtail-7.3rc1.dist-info}/entry_points.txt +0 -0
- {wagtail-7.2.1.dist-info → wagtail-7.3rc1.dist-info}/licenses/LICENSE +0 -0
- {wagtail-7.2.1.dist-info → wagtail-7.3rc1.dist-info}/top_level.txt +0 -0
|
@@ -762,7 +762,7 @@ class TestAvifQualityFilter(TestCase):
|
|
|
762
762
|
with patch("PIL.Image.Image.save") as save:
|
|
763
763
|
fil.run(image, f)
|
|
764
764
|
|
|
765
|
-
save.assert_called_with(f, "AVIF", quality=
|
|
765
|
+
save.assert_called_with(f, "AVIF", quality=61)
|
|
766
766
|
|
|
767
767
|
def test_avif_quality_filter(self):
|
|
768
768
|
fil = Filter(spec="width-400|avifquality-40|format-avif")
|
|
@@ -842,7 +842,7 @@ class TestJPEGQualityFilter(TestCase):
|
|
|
842
842
|
with patch("PIL.Image.Image.save") as save:
|
|
843
843
|
fil.run(image, f)
|
|
844
844
|
|
|
845
|
-
save.assert_called_with(f, "JPEG", quality=
|
|
845
|
+
save.assert_called_with(f, "JPEG", quality=76, optimize=True, progressive=True)
|
|
846
846
|
|
|
847
847
|
def test_jpeg_quality_filter(self):
|
|
848
848
|
fil = Filter(spec="width-400|jpegquality-40")
|
|
@@ -1356,7 +1356,6 @@ class TestIssue613(WagtailTestUtils, TestCase):
|
|
|
1356
1356
|
# Add an image with some tags
|
|
1357
1357
|
image = self.add_image(tags="hello")
|
|
1358
1358
|
|
|
1359
|
-
# TODO: remove this when https://github.com/kaedroho/django-modelsearch/pull/40 is merged and released
|
|
1360
1359
|
search_backend.refresh_indexes()
|
|
1361
1360
|
|
|
1362
1361
|
# Search for it by tag
|
|
@@ -1385,7 +1384,6 @@ class TestIssue613(WagtailTestUtils, TestCase):
|
|
|
1385
1384
|
# Add an image with some tags
|
|
1386
1385
|
image = self.edit_image(tags="hello")
|
|
1387
1386
|
|
|
1388
|
-
# TODO: remove this when https://github.com/kaedroho/django-modelsearch/pull/40 is merged and released
|
|
1389
1387
|
search_backend.refresh_indexes()
|
|
1390
1388
|
|
|
1391
1389
|
# Search for it by tag
|
|
@@ -27,7 +27,7 @@ class AddTagsBulkAction(ImageBulkAction):
|
|
|
27
27
|
return {"tags": self.cleaned_form.cleaned_data["tags"].split(",")}
|
|
28
28
|
|
|
29
29
|
@classmethod
|
|
30
|
-
def execute_action(cls, images, tags=
|
|
30
|
+
def execute_action(cls, images, tags=None, **kwargs):
|
|
31
31
|
num_parent_objects = 0
|
|
32
32
|
if not tags:
|
|
33
33
|
return
|
wagtail/images/views/images.py
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import os
|
|
2
3
|
from tempfile import SpooledTemporaryFile
|
|
3
4
|
|
|
4
5
|
from django.conf import settings
|
|
5
6
|
from django.core.exceptions import PermissionDenied
|
|
6
|
-
from django.
|
|
7
|
+
from django.core.serializers.json import DjangoJSONEncoder
|
|
8
|
+
from django.http import (
|
|
9
|
+
FileResponse,
|
|
10
|
+
HttpResponse,
|
|
11
|
+
HttpResponseBadRequest,
|
|
12
|
+
HttpResponseForbidden,
|
|
13
|
+
)
|
|
7
14
|
from django.shortcuts import get_object_or_404
|
|
8
15
|
from django.urls import reverse
|
|
9
16
|
from django.urls.exceptions import NoReverseMatch
|
|
10
17
|
from django.utils.functional import cached_property
|
|
11
18
|
from django.utils.translation import gettext as _
|
|
12
19
|
from django.utils.translation import gettext_lazy, ngettext
|
|
13
|
-
from django.views import View
|
|
14
20
|
|
|
15
21
|
from wagtail.admin import messages
|
|
16
22
|
from wagtail.admin.auth import PermissionPolicyChecker
|
|
@@ -315,66 +321,69 @@ class URLGeneratorView(generic.InspectView):
|
|
|
315
321
|
model = get_image_model()
|
|
316
322
|
pk_url_kwarg = "image_id"
|
|
317
323
|
header_icon = "image"
|
|
324
|
+
output_only = False
|
|
318
325
|
page_title = gettext_lazy("Generate URL")
|
|
319
326
|
template_name = "wagtailimages/images/url_generator.html"
|
|
327
|
+
output_template_name = "wagtailimages/images/url_generator_output.html"
|
|
320
328
|
index_url_name = "wagtailimages:index"
|
|
321
329
|
edit_url_name = "wagtailimages:edit"
|
|
322
330
|
|
|
331
|
+
invalid_filter_error = gettext_lazy(
|
|
332
|
+
"The filter options you have selected are not valid."
|
|
333
|
+
)
|
|
334
|
+
|
|
323
335
|
def get_page_subtitle(self):
|
|
324
336
|
return self.object.title
|
|
325
337
|
|
|
326
338
|
def get_fields(self):
|
|
327
339
|
return []
|
|
328
340
|
|
|
341
|
+
def get_template_names(self):
|
|
342
|
+
if self.output_only:
|
|
343
|
+
self.template_name = self.output_template_name
|
|
344
|
+
return super().get_template_names()
|
|
345
|
+
|
|
329
346
|
def get(self, request, image_id, *args, **kwargs):
|
|
330
347
|
self.object = get_object_or_404(self.model, id=image_id)
|
|
331
348
|
|
|
332
349
|
if not permission_policy.user_has_permission_for_instance(
|
|
333
350
|
request.user, "change", self.object
|
|
334
351
|
):
|
|
352
|
+
if self.output_only:
|
|
353
|
+
return HttpResponseForbidden(
|
|
354
|
+
"You do not have permission to generate a URL for this image."
|
|
355
|
+
)
|
|
356
|
+
|
|
335
357
|
raise PermissionDenied
|
|
336
358
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
)
|
|
359
|
+
data = {
|
|
360
|
+
"filter_method": request.GET.get("filter_method", "original"),
|
|
361
|
+
"width": request.GET.get("width", self.object.width),
|
|
362
|
+
"height": request.GET.get("height", self.object.height),
|
|
363
|
+
"closeness": request.GET.get("closeness", "0"),
|
|
364
|
+
}
|
|
344
365
|
|
|
345
|
-
|
|
366
|
+
self.filter_spec = self.get_filter_spec(**data)
|
|
346
367
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
368
|
+
# Parse the filter spec to make sure it's valid
|
|
369
|
+
try:
|
|
370
|
+
Filter(spec=self.filter_spec).operations
|
|
371
|
+
except InvalidFilterSpecError as e:
|
|
372
|
+
if self.output_only:
|
|
373
|
+
return HttpResponseBadRequest(
|
|
374
|
+
f"Invalid filter spec: `{self.filter_spec}`. {str(e)}."
|
|
375
|
+
)
|
|
376
|
+
messages.error(request, self.invalid_filter_error)
|
|
351
377
|
|
|
378
|
+
self.form = URLGeneratorForm(initial=data)
|
|
352
379
|
|
|
353
|
-
|
|
354
|
-
def get(self, request, image_id, filter_spec):
|
|
355
|
-
# Get the image
|
|
356
|
-
Image = get_image_model()
|
|
357
|
-
try:
|
|
358
|
-
image = Image.objects.get(id=image_id)
|
|
359
|
-
except Image.DoesNotExist:
|
|
360
|
-
return JsonResponse({"error": "Cannot find image."}, status=404)
|
|
380
|
+
return self.render_to_response(self.get_context_data())
|
|
361
381
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
request.user, "change", image
|
|
365
|
-
):
|
|
366
|
-
return JsonResponse(
|
|
367
|
-
{
|
|
368
|
-
"error": "You do not have permission to generate a URL for this image."
|
|
369
|
-
},
|
|
370
|
-
status=403,
|
|
371
|
-
)
|
|
382
|
+
def get_context_data(self, **kwargs):
|
|
383
|
+
context = super().get_context_data(**kwargs)
|
|
372
384
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
Filter(spec=filter_spec).operations
|
|
376
|
-
except InvalidFilterSpecError:
|
|
377
|
-
return JsonResponse({"error": "Invalid filter spec."}, status=400)
|
|
385
|
+
filter_spec = self.filter_spec
|
|
386
|
+
image_id = self.object.pk
|
|
378
387
|
|
|
379
388
|
# Generate url
|
|
380
389
|
signature = generate_signature(image_id, filter_spec)
|
|
@@ -389,10 +398,34 @@ class GenerateURLView(View):
|
|
|
389
398
|
# Generate preview url
|
|
390
399
|
preview_url = reverse("wagtailimages:preview", args=(image_id, filter_spec))
|
|
391
400
|
|
|
392
|
-
|
|
393
|
-
{"
|
|
401
|
+
message_labels = json.dumps(
|
|
402
|
+
{"400": self.invalid_filter_error},
|
|
403
|
+
cls=DjangoJSONEncoder,
|
|
394
404
|
)
|
|
395
405
|
|
|
406
|
+
context["form"] = self.form
|
|
407
|
+
context["message_labels"] = message_labels
|
|
408
|
+
context["preview_url"] = preview_url
|
|
409
|
+
context["result_url"] = site_root_url + url
|
|
410
|
+
|
|
411
|
+
return context
|
|
412
|
+
|
|
413
|
+
def get_filter_spec(self, filter_method, width, height, closeness):
|
|
414
|
+
match filter_method:
|
|
415
|
+
case "width":
|
|
416
|
+
return f"{filter_method}-{width}"
|
|
417
|
+
case "height":
|
|
418
|
+
return f"{filter_method}-{height}"
|
|
419
|
+
case "min" | "max":
|
|
420
|
+
return f"{filter_method}-{width}x{height}"
|
|
421
|
+
case "fill":
|
|
422
|
+
spec = f"{filter_method}-{width}x{height}"
|
|
423
|
+
if closeness != "0":
|
|
424
|
+
spec += f"-c{closeness}"
|
|
425
|
+
return spec
|
|
426
|
+
case _:
|
|
427
|
+
return filter_method
|
|
428
|
+
|
|
396
429
|
|
|
397
430
|
def preview(request, image_id, filter_spec):
|
|
398
431
|
image = get_object_or_404(get_image_model(), id=image_id)
|