diff --git a/core/wagtail_hooks.py b/core/wagtail_hooks.py index 41c9c225..8af5ee4d 100644 --- a/core/wagtail_hooks.py +++ b/core/wagtail_hooks.py @@ -1,12 +1,11 @@ -from wagtail.admin.widgets import Button, PageListingButton +from wagtail.admin.widgets import Button from wagtail import hooks -from wagtail.admin.wagtail_hooks import page_listing_buttons from django.conf import settings from django.templatetags.static import static from django.urls import reverse from django.utils.html import format_html -from core import helpers, models +from core import models @hooks.register('register_page_listing_more_buttons') @@ -26,35 +25,6 @@ def add_copy_button(page, page_perms, next_url=None, is_parent=False): ) -@helpers.replace_hook('register_page_listing_buttons', page_listing_buttons) -def update_default_listing_buttons(page, page_perms, next_url=None, button_url_name=None): - buttons = list(page_listing_buttons(page, page_perms, next_url)) - if isinstance(page, models.BasePage): - for button in buttons: - if (button_url_name and button_url_name == 'view_draft') or \ - helpers.get_button_url_name(button) == 'view_draft': - button.url = page.get_url(is_draft=True) - - else: - # limit buttons for non-subclasses-of-BasePage - allowed_urls = ['add_subpage'] - buttons = [ - button for button in buttons - if helpers.get_button_url_name(button) in allowed_urls - ] - # since the drop-down is removed by the above, add a delete - # button to this list - if page_perms.can_delete(): - buttons.append(PageListingButton( - 'Delete', - reverse('wagtailadmin_pages:delete', args=[page.id]), - attrs={ - 'title': "Delete '%s'" % page.get_admin_display_title() - }, - )) - return buttons - - @hooks.register('insert_editor_css') def editor_css(): return format_html( diff --git a/requirements.in b/requirements.in index 6cc30da5..793f51ba 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,4 @@ -django==4.1.13 +django==4.2.3 djangorestframework==3.14.* django-environ==0.* gunicorn==20.* @@ -10,10 +10,10 @@ psycopg2==2.9.* --no-binary psycopg2 django-pglocks==1.0.* boto3==1.24.* sigauth==5.2.2 -directory-healthcheck==3.* -directory-components==39.* -directory-constants==23.* -django-staff-sso-client==4.* +directory-healthcheck==3.2 +directory-components==40.* +directory-constants==24.* +django-staff-sso-client==4.2.1 html2text==2020.* pytube==9.2.2 django-filter>=2.4.0 @@ -25,9 +25,9 @@ requests[security]>=2.31.0 markdown==3.* bleach==3.* bleach-whitelist==0.* -wagtail==4.1.9 +wagtail==5.2.2 wagtail-markdown==0.11 -wagtail-modeltranslation==0.13.* +wagtail-modeltranslation==0.14.* django-modeltranslation==0.18.* urllib3==1.26.* w3lib==1.22 diff --git a/requirements.txt b/requirements.txt index d6de5cfb..103f1cbe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -66,17 +66,17 @@ cryptography==41.0.7 # via -r requirements.in defusedxml==0.7.1 # via willow -directory-components==39.1.4 +directory-components==40.0.0 # via -r requirements.in -directory-constants==23.1.1 +directory-constants==24.0.0 # via # -r requirements.in # directory-components -directory-healthcheck==3.1.2 +directory-healthcheck==3.2 # via -r requirements.in dj-database-url==2.1.0 # via -r requirements.in -django==4.1.13 +django==4.2.3 # via # -r requirements.in # directory-components @@ -105,7 +105,7 @@ django-celery-beat==2.5.0 # via -r requirements.in django-environ==0.11.2 # via -r requirements.in -django-filter==22.1 +django-filter==23.5 # via # -r requirements.in # wagtail @@ -127,7 +127,7 @@ django-staff-sso-client==4.2.1 # via -r requirements.in django-storages==1.13.2 # via -r requirements.in -django-taggit==3.1.0 +django-taggit==4.0.0 # via wagtail django-timezone-field==6.1.0 # via django-celery-beat @@ -145,7 +145,7 @@ docopt==0.6.2 # num2words draftjs-exporter==2.1.7 # via wagtail -drf-spectacular==0.26.5 +drf-spectacular==0.27.0 # via -r requirements.in ecs-logging==2.1.0 # via elastic-apm @@ -157,7 +157,7 @@ filetype==1.2.0 # via willow gevent==23.9.1 # via -r requirements.in -greenlet==3.0.1 +greenlet==3.0.2 # via gevent gunicorn==20.1.0 # via -r requirements.in @@ -167,7 +167,7 @@ html5lib==1.1 # via wagtail idna==3.6 # via requests -importlib-metadata==6.8.0 +importlib-metadata==7.0.0 # via markdown inflection==0.5.1 # via drf-spectacular @@ -204,8 +204,12 @@ openpyxl==3.1.2 packaging==23.2 # via bleach pillow==10.1.0 - # via wagtail -prompt-toolkit==3.0.41 + # via + # pillow-heif + # wagtail +pillow-heif==0.14.0 + # via willow +prompt-toolkit==3.0.43 # via click-repl psycogreen==1.0.2 # via -r requirements.in @@ -243,13 +247,14 @@ requests[security]==2.31.0 # via # -r requirements.in # notifications-python-client + # requests # requests-oauthlib # wagtail requests-oauthlib==1.3.1 # via django-staff-sso-client s3transfer==0.6.2 # via boto3 -sentry-sdk==1.38.0 +sentry-sdk==1.39.1 # via -r requirements.in sigauth==5.2.2 # via -r requirements.in @@ -269,11 +274,12 @@ sqlparse==0.4.4 # via django telepath==0.3.1 # via wagtail -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via # asgiref # dj-database-url # django-modeltranslation + # drf-spectacular # kombu tzdata==2023.3 # via @@ -295,7 +301,7 @@ vine==5.1.0 # kombu w3lib==1.22.0 # via -r requirements.in -wagtail==4.1.9 +wagtail==5.2.2 # via # -r requirements.in # wagtail-markdown @@ -303,7 +309,7 @@ wagtail==4.1.9 # wagtailmedia wagtail-markdown==0.11.0 # via -r requirements.in -wagtail-modeltranslation==0.13.0 +wagtail-modeltranslation==0.14.1 # via -r requirements.in wagtailmedia==0.14.5 # via -r requirements.in @@ -315,7 +321,7 @@ webencodings==0.5.1 # html5lib whitenoise==6.4.0 # via -r requirements.in -willow==1.6.3 +willow[heif]==1.6.3 # via # -r requirements.in # wagtail diff --git a/requirements_test.in b/requirements_test.in index d0893815..a48528f2 100644 --- a/requirements_test.in +++ b/requirements_test.in @@ -8,8 +8,8 @@ flake8==6.1.0 requests_mock freezegun==0.3.14 coveralls -factory-boy==2.* -wagtail-factories==2.0.1 +factory-boy==3.3.0 +wagtail-factories==4.1.0 django-debug-toolbar==3.2.* pip-tools pytest-codecov diff --git a/requirements_test.txt b/requirements_test.txt index 503eec13..92bd01db 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -65,6 +65,7 @@ click-repl==0.3.0 # via celery coverage[toml]==6.5.0 # via + # coverage # coveralls # pytest-codecov # pytest-cov @@ -76,17 +77,17 @@ cryptography==41.0.7 # via -r requirements.in defusedxml==0.7.1 # via willow -directory-components==39.1.4 +directory-components==40.0.0 # via -r requirements.in -directory-constants==23.1.1 +directory-constants==24.0.0 # via # -r requirements.in # directory-components -directory-healthcheck==3.1.2 +directory-healthcheck==3.2 # via -r requirements.in dj-database-url==2.1.0 # via -r requirements.in -django==4.1.13 +django==4.2.3 # via # -r requirements.in # directory-components @@ -118,7 +119,7 @@ django-debug-toolbar==3.2.4 # via -r requirements_test.in django-environ==0.11.2 # via -r requirements.in -django-filter==22.1 +django-filter==23.5 # via # -r requirements.in # wagtail @@ -140,7 +141,7 @@ django-staff-sso-client==4.2.1 # via -r requirements.in django-storages==1.13.2 # via -r requirements.in -django-taggit==3.1.0 +django-taggit==4.0.0 # via wagtail django-timezone-field==6.1.0 # via django-celery-beat @@ -159,7 +160,7 @@ docopt==0.6.2 # num2words draftjs-exporter==2.1.7 # via wagtail -drf-spectacular==0.26.5 +drf-spectacular==0.27.0 # via -r requirements.in ecs-logging==2.1.0 # via elastic-apm @@ -169,11 +170,11 @@ et-xmlfile==1.1.0 # via openpyxl exceptiongroup==1.2.0 # via pytest -factory-boy==2.12.0 +factory-boy==3.3.0 # via # -r requirements_test.in # wagtail-factories -faker==20.1.0 +faker==21.0.0 # via factory-boy filetype==1.2.0 # via willow @@ -187,7 +188,7 @@ gitdb==4.0.11 # via gitpython gitpython==3.1.40 # via -r requirements_test.in -greenlet==3.0.1 +greenlet==3.0.2 # via gevent gunicorn==20.1.0 # via -r requirements.in @@ -197,7 +198,7 @@ html5lib==1.1 # via wagtail idna==3.6 # via requests -importlib-metadata==6.8.0 +importlib-metadata==7.0.0 # via # build # markdown @@ -244,12 +245,16 @@ packaging==23.2 # pytest # pytest-sugar pillow==10.1.0 - # via wagtail + # via + # pillow-heif + # wagtail +pillow-heif==0.14.0 + # via willow pip-tools==7.3.0 # via -r requirements_test.in pluggy==1.3.0 # via pytest -prompt-toolkit==3.0.41 +prompt-toolkit==3.0.43 # via click-repl psycogreen==1.0.2 # via -r requirements.in @@ -314,6 +319,7 @@ requests[security]==2.31.0 # coveralls # notifications-python-client # pytest-codecov + # requests # requests-mock # requests-oauthlib # wagtail @@ -323,7 +329,7 @@ requests-oauthlib==1.3.1 # via django-staff-sso-client s3transfer==0.6.2 # via boto3 -sentry-sdk==1.38.0 +sentry-sdk==1.39.1 # via -r requirements.in sigauth==5.2.2 # via -r requirements.in @@ -349,7 +355,7 @@ sqlparse==0.4.4 # django-debug-toolbar telepath==0.3.1 # via wagtail -termcolor==2.3.0 +termcolor==2.4.0 # via pytest-sugar tomli==2.0.1 # via @@ -358,11 +364,12 @@ tomli==2.0.1 # pip-tools # pyproject-hooks # pytest -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via # asgiref # dj-database-url # django-modeltranslation + # drf-spectacular # kombu tzdata==2023.3 # via @@ -384,18 +391,18 @@ vine==5.1.0 # kombu w3lib==1.22.0 # via -r requirements.in -wagtail==4.1.9 +wagtail==5.2.2 # via # -r requirements.in # wagtail-factories # wagtail-markdown # wagtail-modeltranslation # wagtailmedia -wagtail-factories==2.0.1 +wagtail-factories==4.1.0 # via -r requirements_test.in wagtail-markdown==0.11.0 # via -r requirements.in -wagtail-modeltranslation==0.13.0 +wagtail-modeltranslation==0.14.1 # via -r requirements.in wagtailmedia==0.14.5 # via -r requirements.in @@ -409,7 +416,7 @@ wheel==0.42.0 # via pip-tools whitenoise==6.4.0 # via -r requirements.in -willow==1.6.3 +willow[heif]==1.6.3 # via # -r requirements.in # wagtail diff --git a/tests/conftest.py b/tests/conftest.py index 80ee2aff..b4ac80fa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -85,14 +85,13 @@ def wagtail_initial_data(request, en_locale): GroupPagePermission.objects.create( group=moderators_group, page=root, - permission_type='edit', + permission_type='change', ) GroupPagePermission.objects.create( group=moderators_group, page=root, permission_type='publish', ) - GroupPagePermission.objects.create( group=editors_group, page=root, @@ -101,7 +100,7 @@ def wagtail_initial_data(request, en_locale): GroupPagePermission.objects.create( group=editors_group, page=root, - permission_type='edit', + permission_type='change', ) # Also set up an Image (and implicitly also a Collection), diff --git a/tests/core/test_views.py b/tests/core/test_views.py index 0608d24c..3d4f3009 100644 --- a/tests/core/test_views.py +++ b/tests/core/test_views.py @@ -312,15 +312,6 @@ def test_add_page_prepopulate_missing_content_type( assert response.status_code == 404 -@pytest.mark.django_db -def test_list_page(admin_client, root_page): - url = reverse('wagtailadmin_explore', args=(root_page.pk,)) - - response = admin_client.get(url) - - assert response.status_code == 200 - - @pytest.mark.django_db def test_page_listing(translated_page, admin_client): url = reverse('wagtailadmin_pages:edit', args=(translated_page.pk,)) diff --git a/tests/core/test_wagtail_hooks.py b/tests/core/test_wagtail_hooks.py index 6e05a94b..7cc285de 100644 --- a/tests/core/test_wagtail_hooks.py +++ b/tests/core/test_wagtail_hooks.py @@ -1,55 +1,10 @@ -from unittest.mock import Mock - import pytest -import re -from django.utils import translation from django.urls import reverse from core import wagtail_hooks -@pytest.mark.django_db -def test_update_default_listing_buttons_from_base_page(page_with_reversion): - buttons = wagtail_hooks.update_default_listing_buttons( - page=page_with_reversion, page_perms=Mock() - ) - - expected_url = r'http://great.gov.uk/international/content/123-555-[0-9][0-9][0-9]/' - assert len(buttons) == 4 - assert re.match(expected_url, buttons[1].url) - - -@pytest.mark.django_db -def test_update_default_listing_buttons_from_base_page_button_url_name_view_draft( - page_with_reversion -): - button_url_name = 'view_draft' - buttons = wagtail_hooks.update_default_listing_buttons( - page=page_with_reversion, page_perms=Mock(), button_url_name=button_url_name, - ) - - expected_url = r'http://great[.]gov[.]uk/international/content/123-555-[0-9][0-9][0-9]/[?]draft_token=\w+' - assert len(buttons) == 4 - assert re.match(expected_url, buttons[1].url) - - -@pytest.mark.django_db -def test_update_default_listing_buttons_not_from_base_page( - settings, page_without_specific_type -): - translation.activate(settings.LANGUAGE_CODE) - - # For a page without a type, there should also be an 'Add child page' - # and 'Delete' button - buttons = wagtail_hooks.update_default_listing_buttons( - page=page_without_specific_type, page_perms=Mock() - ) - assert len(buttons) == 2 - assert buttons[0].label == 'Add child page' - assert buttons[1].label == 'Delete' - - @pytest.mark.django_db def test_add_copy_button(page_with_reversion): page = page_with_reversion